···868 # to match multiline regexes.
869 console = io.StringIO()
870871- def console_matches() -> bool:
872 nonlocal console
873 try:
874 # This will return as soon as possible and
···884 if timeout is not None:
885 retry(console_matches, timeout)
886 else:
887- while not console_matches():
888 pass
889890 def send_key(
···868 # to match multiline regexes.
869 console = io.StringIO()
870871+ def console_matches(_: Any) -> bool:
872 nonlocal console
873 try:
874 # This will return as soon as possible and
···884 if timeout is not None:
885 retry(console_matches, timeout)
886 else:
887+ while not console_matches(False):
888 pass
889890 def send_key(
+13-4
nixos/tests/systemd-initrd-vconsole.nix
···2 name = "systemd-initrd-vconsole";
34 nodes.machine = { pkgs, ... }: {
5- boot.kernelParams = [ "rd.systemd.unit=rescue.target" ];
67 boot.initrd.systemd = {
8 enable = true;
···20 machine.start()
21 machine.wait_for_console_text("Press Enter for maintenance")
22 machine.send_console("\n")
23- machine.wait_for_console_text("Logging in with home")
00000000002425 # Check keymap
26- machine.send_console("(printf '%s to receive text: \\n' Ready && read text && echo \"$text\") </dev/tty1\n")
27 machine.wait_for_console_text("Ready to receive text:")
28 for key in "asdfjkl;\n":
29 machine.send_key(key)
30 machine.wait_for_console_text("arstneio")
31- machine.send_console("systemctl poweroff\n")
32 '';
33})
···2 name = "systemd-initrd-vconsole";
34 nodes.machine = { pkgs, ... }: {
5+ boot.kernelParams = lib.mkAfter [ "rd.systemd.unit=rescue.target" "loglevel=3" "udev.log_level=3" "systemd.log_level=warning" ];
67 boot.initrd.systemd = {
8 enable = true;
···20 machine.start()
21 machine.wait_for_console_text("Press Enter for maintenance")
22 machine.send_console("\n")
23+24+ # Wait for shell to become ready
25+ for _ in range(300):
26+ machine.send_console("printf '%s to receive commands:\\n' Ready\n")
27+ try:
28+ machine.wait_for_console_text("Ready to receive commands:", timeout=1)
29+ break
30+ except Exception:
31+ continue
32+ else:
33+ raise RuntimeError("Rescue shell never became ready")
3435 # Check keymap
36+ machine.send_console("(printf '%s to receive text:\\n' Ready && read text && echo \"$text\") </dev/tty1\n")
37 machine.wait_for_console_text("Ready to receive text:")
38 for key in "asdfjkl;\n":
39 machine.send_key(key)
40 machine.wait_for_console_text("arstneio")
041 '';
42})