nixos/tests/test-driver: add shell_interact

(cherry picked from commit 5a589b5ba8941d734e9c3aebbf2be2f50d7c32a5)
This commit is contained in:
Patrick Hilhorst 2021-06-02 14:19:08 +02:00 committed by github-actions[bot]
parent 2d1b9ef5e7
commit e3e37d20ce

View File

@ -21,6 +21,7 @@ import shutil
import socket import socket
import subprocess import subprocess
import sys import sys
import telnetlib
import tempfile import tempfile
import time import time
import traceback import traceback
@ -455,6 +456,15 @@ class Machine:
return (status_code, output) return (status_code, output)
output += chunk output += chunk
def shell_interact(self) -> None:
"""Allows you to interact with the guest shell
Should only be used during testing, not in the production test."""
self.connect()
telnet = telnetlib.Telnet()
telnet.sock = self.shell # type: ignore
telnet.interact()
def succeed(self, *commands: str) -> str: def succeed(self, *commands: str) -> str:
"""Execute each command and check that it succeeds.""" """Execute each command and check that it succeeds."""
output = "" output = ""