From 5a589b5ba8941d734e9c3aebbf2be2f50d7c32a5 Mon Sep 17 00:00:00 2001 From: Patrick Hilhorst Date: Wed, 2 Jun 2021 14:19:08 +0200 Subject: [PATCH] nixos/tests/test-driver: add shell_interact --- nixos/lib/test-driver/test-driver.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index e216e566f286..90ae2e558ef5 100644 --- a/nixos/lib/test-driver/test-driver.py +++ b/nixos/lib/test-driver/test-driver.py @@ -21,6 +21,7 @@ import shutil import socket import subprocess import sys +import telnetlib import tempfile import time import traceback @@ -455,6 +456,15 @@ class Machine: return (status_code, output) 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: """Execute each command and check that it succeeds.""" output = ""