Only apply the test-driver patch if nixpkgs doesn't have it yet.
This commit is contained in:
parent
283d1d1030
commit
3ed3a26b56
2 changed files with 26 additions and 24 deletions
20
nix/lib.nix
20
nix/lib.nix
|
|
@ -441,10 +441,22 @@ in
|
||||||
upstream = hostPkgs.callPackage "${nixpkgs}/nixos/lib/test-driver" { };
|
upstream = hostPkgs.callPackage "${nixpkgs}/nixos/lib/test-driver" { };
|
||||||
in
|
in
|
||||||
upstream.overrideAttrs (_: {
|
upstream.overrideAttrs (_: {
|
||||||
# Until github.com/NixOS/nixpkgs#228220 gets merged
|
# Try to apply the patch for backwards compat.
|
||||||
patches = [
|
# It is included upstream starting from NixOS 23.05.
|
||||||
../test/0001-nixos-test-driver-include-a-timeout-for-the-recv-cal.patch
|
# github.com/NixOS/nixpkgs#228220
|
||||||
];
|
postPatch =
|
||||||
|
let
|
||||||
|
patch = "${lib.getBin hostPkgs.patch}/bin/patch";
|
||||||
|
patchFile = ../test/0001-nixos-test-driver-include-a-timeout-for-the-recv-cal.patch;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
echo "Try to apply patch ${patchFile}..."
|
||||||
|
if ${patch} --reverse -p1 --silent --force --dry-run --input=${patchFile}; then
|
||||||
|
echo "Patch already present, ignoring..."
|
||||||
|
else
|
||||||
|
${patch} -p1 < ${patchFile}
|
||||||
|
fi
|
||||||
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
runTest = { nodes, vlans, testScript, extraDriverArgs }: ''
|
runTest = { nodes, vlans, testScript, extraDriverArgs }: ''
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ index 9de98c217a5..4b34ac423d1 100644
|
||||||
@@ -99,7 +100,7 @@ def _perform_ocr_on_screenshot(
|
@@ -99,7 +100,7 @@ def _perform_ocr_on_screenshot(
|
||||||
+ "-blur 1x65535"
|
+ "-blur 1x65535"
|
||||||
)
|
)
|
||||||
|
|
||||||
- tess_args = f"-c debug_file=/dev/null --psm 11"
|
- tess_args = f"-c debug_file=/dev/null --psm 11"
|
||||||
+ tess_args = "-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'"
|
cmd = f"convert {magick_args} '{screenshot_path}' 'tiff:{screenshot_path}.tiff'"
|
||||||
ret = subprocess.run(cmd, shell=True, capture_output=True)
|
ret = subprocess.run(cmd, shell=True, capture_output=True)
|
||||||
@@ -154,6 +155,7 @@ class StartCommand:
|
@@ -154,6 +155,7 @@ class StartCommand:
|
||||||
|
|
@ -40,18 +40,18 @@ index 9de98c217a5..4b34ac423d1 100644
|
||||||
@@ -524,8 +526,10 @@ class Machine:
|
@@ -524,8 +526,10 @@ class Machine:
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
timeout_str = f"timeout {timeout}"
|
timeout_str = f"timeout {timeout}"
|
||||||
|
|
||||||
+ # While sh is bash on NixOS, this is not the case for every distro.
|
+ # 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.
|
+ # We explicitely call bash here to allow for the driver to boot other distros as well.
|
||||||
out_command = (
|
out_command = (
|
||||||
- f"{timeout_str} sh -c {shlex.quote(command)} | (base64 --wrap 0; echo)\n"
|
- 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"
|
+ f"{timeout_str} bash -c {shlex.quote(command)} | (base64 --wrap 0; echo)\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
assert self.shell
|
assert self.shell
|
||||||
@@ -719,6 +723,15 @@ class Machine:
|
@@ -719,6 +723,15 @@ class Machine:
|
||||||
self.wait_for_unit(jobname)
|
self.wait_for_unit(jobname)
|
||||||
|
|
||||||
def connect(self) -> None:
|
def connect(self) -> None:
|
||||||
+ def shell_ready(timeout_secs: int) -> bool:
|
+ def shell_ready(timeout_secs: int) -> bool:
|
||||||
+ """We sent some data from the backdoor service running on the guest
|
+ """We sent some data from the backdoor service running on the guest
|
||||||
|
|
@ -64,10 +64,10 @@ index 9de98c217a5..4b34ac423d1 100644
|
||||||
+
|
+
|
||||||
if self.connected:
|
if self.connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -728,8 +741,11 @@ class Machine:
|
@@ -728,8 +741,11 @@ class Machine:
|
||||||
assert self.shell
|
assert self.shell
|
||||||
|
|
||||||
tic = time.time()
|
tic = time.time()
|
||||||
- self.shell.recv(1024)
|
- self.shell.recv(1024)
|
||||||
- # TODO: Timeout
|
- # TODO: Timeout
|
||||||
|
|
@ -77,17 +77,7 @@ index 9de98c217a5..4b34ac423d1 100644
|
||||||
+
|
+
|
||||||
+ self.log(self.shell.recv(1024).decode())
|
+ self.log(self.shell.recv(1024).decode())
|
||||||
toc = time.time()
|
toc = time.time()
|
||||||
|
|
||||||
self.log("connected to guest root shell")
|
|
||||||
@@ -950,7 +966,7 @@ class Machine:
|
|
||||||
Prepares the machine to be reconnected which is useful if the
|
|
||||||
machine was started with `allow_reboot = True`
|
|
||||||
"""
|
|
||||||
- self.send_key(f"ctrl-alt-delete")
|
|
||||||
+ self.send_key("ctrl-alt-delete")
|
|
||||||
self.connected = False
|
|
||||||
|
|
||||||
def wait_for_x(self) -> None:
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
||||||
|
self.log("connected to guest root shell")
|
||||||
|
--
|
||||||
|
2.39.2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue