From 363d7f3ae857aeb863bc2e00fb487591b7d5db2b Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Mon, 15 Nov 2021 12:11:18 -0800 Subject: [PATCH] nixos/test-driver: add timeout parameter to execute --- nixos/lib/test-driver/test-driver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index a7c0484060f2..1d45e001bb4c 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())