Merge pull request #62 from numtide/auto_update_deps

Bump flake.lock and Cargo.lock
This commit is contained in:
Ramses 2024-01-08 12:22:39 +01:00 committed by GitHub
commit 9e1b47f8de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 148 deletions

44
Cargo.lock generated
View file

@ -61,9 +61,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.78"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca87830a3e3fb156dc96cfbd31cb620265dd053be734723f22b760d6cc3c3051"
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "autocfg"
@ -100,9 +100,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.4.12"
version = "4.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d"
checksum = "52bdc885e4cacc7f7c9eedc1ef6da641603180c783c41a15c264944deeaab642"
dependencies = [
"clap_builder",
"clap_derive",
@ -245,9 +245,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "libc"
version = "0.2.151"
version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "libdbus-sys"
@ -312,18 +312,18 @@ checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
[[package]]
name = "proc-macro2"
version = "1.0.73"
version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dd5e8a1f1029c43224ad5898e50140c2aebb1705f19e67c918ebf5b9e797fe1"
checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.34"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a37c9326af5ed140c86a46655b5278de879853be5573c01df185b6f49a580a"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
@ -393,18 +393,18 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]]
name = "serde"
version = "1.0.193"
version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.193"
version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
dependencies = [
"proc-macro2",
"quote",
@ -413,9 +413,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.109"
version = "1.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9"
checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4"
dependencies = [
"itoa",
"ryu",
@ -440,9 +440,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "2.0.44"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d27c2c202598d05175a6dd3af46824b7f747f8d8e9b14c623f19fa5069735d"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
@ -477,18 +477,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.53"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2cd5904763bad08ad5513ddbb12cf2ae273ca53fa9f68e843e236ec6dfccc09"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.53"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcf4a824cce0aeacd6f38ae6f24234c8e80d68632338ebaa1443b5df9e29e19"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2",
"quote",

60
flake.lock generated
View file

@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1703439018,
"narHash": "sha256-VT+06ft/x3eMZ1MJxWzQP3zXFGcrxGo5VR2rB7t88hs=",
"lastModified": 1704300976,
"narHash": "sha256-QLMpTrHxsND2T8+khAhLCqzOY/h2SzWS0s4Z7N2ds/E=",
"owner": "ipetkov",
"repo": "crane",
"rev": "afdcd41180e3dfe4dac46b5ee396e3b12ccc967a",
"rev": "0efe36f9232e0961512572883ba9c995aa1f54b1",
"type": "github"
},
"original": {
@ -22,17 +22,17 @@
},
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems"
]
},
"locked": {
"lastModified": 1701787589,
"narHash": "sha256-ce+oQR4Zq9VOsLoh9bZT8Ip9PaMLcjjBUHVPzW5d7Cw=",
"lastModified": 1704648272,
"narHash": "sha256-zCDhWGl3bVpBKpDZ0p3NuGksZVg69BAChsY5W4KARL4=",
"owner": "numtide",
"repo": "devshell",
"rev": "44ddedcbcfc2d52a76b64fb6122f209881bd3e1e",
"rev": "f54745fd4aae92443817ddc566ce06572b178b5a",
"type": "github"
},
"original": {
@ -58,6 +58,24 @@
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
@ -98,11 +116,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1703637592,
"narHash": "sha256-8MXjxU0RfFfzl57Zy3OfXCITS0qWDNLzlBAdwxGZwfY=",
"lastModified": 1704538339,
"narHash": "sha256-1734d3mQuux9ySvwf6axRWZRBhtcZA9Q8eftD6EZg6U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cfc3698c31b1fb9cdcf10f36c9643460264d0ca8",
"rev": "46ae0210ce163b3cba6c7da08840c1d63de9c701",
"type": "github"
},
"original": {
@ -141,11 +159,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1703939133,
"narHash": "sha256-Gxe+mfOT6bL7wLC/tuT2F+V+Sb44jNr8YsJ3cyIl4Mo=",
"lastModified": 1704668415,
"narHash": "sha256-BMzNHFod53iiU4lkR5WHwqQCFmaCLq85sUCskXneXlA=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "9d3d7e18c6bc4473d7520200d4ddab12f8402d38",
"rev": "44493e2b3c3ebcd39a9947e9ed9f2c2af164ec4c",
"type": "github"
},
"original": {
@ -158,7 +176,7 @@
"inputs": {
"crane": "crane",
"devshell": "devshell",
"flake-utils": "flake-utils",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",
"rust-overlay": "rust-overlay",
@ -175,11 +193,11 @@
]
},
"locked": {
"lastModified": 1704075545,
"narHash": "sha256-L3zgOuVKhPjKsVLc3yTm2YJ6+BATyZBury7wnhyc8QU=",
"lastModified": 1704680242,
"narHash": "sha256-5bD6iSPDgVTLly2gy2oJVwzuyuFZOz2p4qt8c8UoYIE=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "a0df72e106322b67e9c6e591fe870380bd0da0d5",
"rev": "2037779e018ebc2d381001a891e2a793fce7a74f",
"type": "github"
},
"original": {
@ -225,11 +243,11 @@
]
},
"locked": {
"lastModified": 1702979157,
"narHash": "sha256-RnFBbLbpqtn4AoJGXKevQMCGhra4h6G2MPcuTSZZQ+g=",
"lastModified": 1704649711,
"narHash": "sha256-+qxqJrZwvZGilGiLQj3QbYssPdYCwl7ejwMImgH7VBQ=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "2961375283668d867e64129c22af532de8e77734",
"rev": "04f25d7bec9fb29d2c3bacaa48a3304840000d36",
"type": "github"
},
"original": {

View file

@ -313,28 +313,7 @@ in
]};
'';
test-driver =
let
upstream = hostPkgs.callPackage "${nixpkgs}/nixos/lib/test-driver" { };
in
upstream.overrideAttrs (_: {
# Try to apply the patch for backwards compat.
# It is included upstream starting from NixOS 23.05.
# 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 grep --quiet --fixed-strings "bash" test_driver/machine.py; then
echo "Patch already present, ignoring..."
else
${patch} -p1 < ${patchFile}
fi
'';
});
test-driver = hostPkgs.callPackage "${nixpkgs}/nixos/lib/test-driver" { };
runTest = { nodes, vlans, testScript, extraDriverArgs }: ''
${lib.getBin test-driver}/bin/nixos-test-driver \

View file

@ -1,4 +1,5 @@
{ nixosModulesPath
, lib
, ...
}:
{
@ -12,4 +13,17 @@
"/security/acme/"
"/services/web-servers/nginx/"
];
options =
# We need to ignore a bunch of options that are used in NixOS modules but
# that don't apply to system-manager configs.
# TODO: can we print an informational message for things like kernel modules
# to inform users that they need to be enabled in the host system?
{
boot = lib.mkOption {
type = lib.types.raw;
};
};
}

View file

@ -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