about summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorworldofpeace <worldofpeace@protonmail.ch>2019-11-07 20:23:27 +0000
committerGitHub <noreply@github.com>2019-11-07 20:23:27 +0000
commit1e7ddf233a5c85ec2a49b8bdabf57ca0c028c9ac (patch)
treeced7d78a92f351447f6d5094ec7de613a13630e8 /nixos/lib
parent31315ec730db037d3e558ced42959b26ed557432 (diff)
parent9915a8ca45ff0867739d2cefe0be622d8c817368 (diff)
Merge pull request #72943 from marijanp/port-test-driver-python
Port remaining test-driver functions to python
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/test-driver.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index bd52233964b73..93b8eebd2e12c 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -507,6 +507,11 @@ class Machine:
             if ret.returncode != 0:
                 raise Exception("Cannot convert screenshot")
 
+    def dump_tty_contents(self, tty):
+        """Debugging: Dump the contents of the TTY<n>
+        """
+        self.execute("fold -w 80 /dev/vcs{} | systemd-cat".format(tty))
+
     def get_screen_text(self):
         if shutil.which("tesseract") is None:
             raise Exception("get_screen_text used but enableOCR is false")
@@ -679,6 +684,14 @@ class Machine:
     def sleep(self, secs):
         time.sleep(secs)
 
+    def forward_port(self, host_port=8080, guest_port=80):
+        """Forward a TCP port on the host to a TCP port on the guest.
+        Useful during interactive testing.
+        """
+        self.send_monitor_command(
+            "hostfwd_add tcp::{}-:{}".format(host_port, guest_port)
+        )
+
     def block(self):
         """Make the machine unreachable by shutting down eth1 (the multicast
         interface used to talk to the other VMs).  We keep eth0 up so that