summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorCole Helbling <cole.helbling@determinate.systems>2021-11-15 12:11:18 -0800
committerCole Helbling <cole.helbling@determinate.systems>2021-11-17 16:11:03 -0800
commit363d7f3ae857aeb863bc2e00fb487591b7d5db2b (patch)
treeaa22071de8ee4b73d3d8d1564b9a030833e56c32 /nixos/lib
parent51befa6cdc7bf7d6866a6368ecbbccb1d972bb30 (diff)
downloadnixpkgs-363d7f3ae857aeb863bc2e00fb487591b7d5db2b.tar
nixpkgs-363d7f3ae857aeb863bc2e00fb487591b7d5db2b.tar.gz
nixpkgs-363d7f3ae857aeb863bc2e00fb487591b7d5db2b.tar.bz2
nixpkgs-363d7f3ae857aeb863bc2e00fb487591b7d5db2b.tar.lz
nixpkgs-363d7f3ae857aeb863bc2e00fb487591b7d5db2b.tar.xz
nixpkgs-363d7f3ae857aeb863bc2e00fb487591b7d5db2b.tar.zst
nixpkgs-363d7f3ae857aeb863bc2e00fb487591b7d5db2b.zip
nixos/test-driver: add timeout parameter to execute
Diffstat (limited to 'nixos/lib')
-rwxr-xr-xnixos/lib/test-driver/test-driver.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index a7c0484060f..1d45e001bb4 100755
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -597,9 +597,14 @@ class Machine:
                 break
         return "".join(output_buffer)
 
-    def execute(self, command: str, check_return: bool = True) -> Tuple[int, str]:
+    def execute(
+        self, command: str, check_return: bool = True, timeout: Optional[int] = 900
+    ) -> Tuple[int, str]:
         self.connect()
 
+        if timeout is not None:
+            command = "timeout {} sh -c {}".format(timeout, shlex.quote(command))
+
         out_command = f"( set -euo pipefail; {command} ) | (base64 --wrap 0; echo)\n"
         assert self.shell
         self.shell.send(out_command.encode())