Drop support for old test-driver
This commit is contained in:
parent
a8db3b881b
commit
107ed51c8e
2 changed files with 1 additions and 105 deletions
|
|
@ -1,83 +0,0 @@
|
|||
From 4147b878bcdd6fc8e8b6395215c71a0ebd0b23c1 Mon Sep 17 00:00:00 2001
|
||||
From: r-vdp <ramses@well-founded.dev>
|
||||
Date: Wed, 26 Apr 2023 00:44:23 +0200
|
||||
Subject: [PATCH] nixos-test-driver: include a timeout for the recv call, do
|
||||
not assume sh == bash
|
||||
|
||||
---
|
||||
test_driver/machine.py | 26 +++++++++++++++++++++-----
|
||||
1 file changed, 21 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/test_driver/machine.py b/test_driver/machine.py
|
||||
index 9de98c217a5..4b34ac423d1 100644
|
||||
--- a/test_driver/machine.py
|
||||
+++ b/test_driver/machine.py
|
||||
@@ -7,6 +7,7 @@ import io
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
+import select
|
||||
import shlex
|
||||
import shutil
|
||||
import socket
|
||||
@@ -99,7 +100,7 @@ def _perform_ocr_on_screenshot(
|
||||
+ "-blur 1x65535"
|
||||
)
|
||||
|
||||
- tess_args = f"-c debug_file=/dev/null --psm 11"
|
||||
+ tess_args = "-c debug_file=/dev/null --psm 11"
|
||||
|
||||
cmd = f"convert {magick_args} '{screenshot_path}' 'tiff:{screenshot_path}.tiff'"
|
||||
ret = subprocess.run(cmd, shell=True, capture_output=True)
|
||||
@@ -154,6 +155,7 @@ class StartCommand:
|
||||
# qemu options
|
||||
qemu_opts = (
|
||||
" -device virtio-serial"
|
||||
+ # Note: virtconsole will map to /dev/hvc0 in Linux guests
|
||||
" -device virtconsole,chardev=shell"
|
||||
" -device virtio-rng-pci"
|
||||
" -serial stdio"
|
||||
@@ -524,8 +526,10 @@ class Machine:
|
||||
if timeout is not None:
|
||||
timeout_str = f"timeout {timeout}"
|
||||
|
||||
+ # While sh is bash on NixOS, this is not the case for every distro.
|
||||
+ # We explicitely call bash here to allow for the driver to boot other distros as well.
|
||||
out_command = (
|
||||
- f"{timeout_str} sh -c {shlex.quote(command)} | (base64 --wrap 0; echo)\n"
|
||||
+ f"{timeout_str} bash -c {shlex.quote(command)} | (base64 --wrap 0; echo)\n"
|
||||
)
|
||||
|
||||
assert self.shell
|
||||
@@ -719,6 +723,15 @@ class Machine:
|
||||
self.wait_for_unit(jobname)
|
||||
|
||||
def connect(self) -> None:
|
||||
+ def shell_ready(timeout_secs: int) -> bool:
|
||||
+ """We sent some data from the backdoor service running on the guest
|
||||
+ to indicate that the backdoor shell is ready.
|
||||
+ As soon as we read some data from the socket here, we assume that
|
||||
+ our root shell is operational.
|
||||
+ """
|
||||
+ (ready, _, _) = select.select([self.shell], [], [], timeout_secs)
|
||||
+ return bool(ready)
|
||||
+
|
||||
if self.connected:
|
||||
return
|
||||
|
||||
@@ -728,8 +741,11 @@ class Machine:
|
||||
assert self.shell
|
||||
|
||||
tic = time.time()
|
||||
- self.shell.recv(1024)
|
||||
- # TODO: Timeout
|
||||
+ # TODO: do we want to bail after a set number of attempts?
|
||||
+ while not shell_ready(timeout_secs=30):
|
||||
+ self.log("Guest root shell did not produce any data yet...")
|
||||
+
|
||||
+ self.log(self.shell.recv(1024).decode())
|
||||
toc = time.time()
|
||||
|
||||
self.log("connected to guest root shell")
|
||||
--
|
||||
2.39.2
|
||||
Loading…
Add table
Add a link
Reference in a new issue