mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-16 22:49:25 +03:00
Merge pull request #237840 from lilyinstarlight/fix/systemd-initrd-vconsole-test
nixos/tests/systemd-initrd-vconsole: fix test and improve reliability
This commit is contained in:
commit
4f992e8da0
2 changed files with 15 additions and 6 deletions
|
@ -868,7 +868,7 @@ class Machine:
|
||||||
# to match multiline regexes.
|
# to match multiline regexes.
|
||||||
console = io.StringIO()
|
console = io.StringIO()
|
||||||
|
|
||||||
def console_matches() -> bool:
|
def console_matches(_: Any) -> bool:
|
||||||
nonlocal console
|
nonlocal console
|
||||||
try:
|
try:
|
||||||
# This will return as soon as possible and
|
# This will return as soon as possible and
|
||||||
|
@ -884,7 +884,7 @@ class Machine:
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
retry(console_matches, timeout)
|
retry(console_matches, timeout)
|
||||||
else:
|
else:
|
||||||
while not console_matches():
|
while not console_matches(False):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def send_key(
|
def send_key(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
||||||
name = "systemd-initrd-vconsole";
|
name = "systemd-initrd-vconsole";
|
||||||
|
|
||||||
nodes.machine = { pkgs, ... }: {
|
nodes.machine = { pkgs, ... }: {
|
||||||
boot.kernelParams = [ "rd.systemd.unit=rescue.target" ];
|
boot.kernelParams = lib.mkAfter [ "rd.systemd.unit=rescue.target" "loglevel=3" "udev.log_level=3" "systemd.log_level=warning" ];
|
||||||
|
|
||||||
boot.initrd.systemd = {
|
boot.initrd.systemd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -20,14 +20,23 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
||||||
machine.start()
|
machine.start()
|
||||||
machine.wait_for_console_text("Press Enter for maintenance")
|
machine.wait_for_console_text("Press Enter for maintenance")
|
||||||
machine.send_console("\n")
|
machine.send_console("\n")
|
||||||
machine.wait_for_console_text("Logging in with home")
|
|
||||||
|
# Wait for shell to become ready
|
||||||
|
for _ in range(300):
|
||||||
|
machine.send_console("printf '%s to receive commands:\\n' Ready\n")
|
||||||
|
try:
|
||||||
|
machine.wait_for_console_text("Ready to receive commands:", timeout=1)
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Rescue shell never became ready")
|
||||||
|
|
||||||
# Check keymap
|
# Check keymap
|
||||||
machine.send_console("(printf '%s to receive text: \\n' Ready && read text && echo \"$text\") </dev/tty1\n")
|
machine.send_console("(printf '%s to receive text:\\n' Ready && read text && echo \"$text\") </dev/tty1\n")
|
||||||
machine.wait_for_console_text("Ready to receive text:")
|
machine.wait_for_console_text("Ready to receive text:")
|
||||||
for key in "asdfjkl;\n":
|
for key in "asdfjkl;\n":
|
||||||
machine.send_key(key)
|
machine.send_key(key)
|
||||||
machine.wait_for_console_text("arstneio")
|
machine.wait_for_console_text("arstneio")
|
||||||
machine.send_console("systemctl poweroff\n")
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue