lol

Merge pull request #237840 from lilyinstarlight/fix/systemd-initrd-vconsole-test

nixos/tests/systemd-initrd-vconsole: fix test and improve reliability

authored by

Jörg Thalheim and committed by
GitHub
4f992e8d cc3e5198

+15 -6
+2 -2
nixos/lib/test-driver/test_driver/machine.py
··· 868 868 # to match multiline regexes. 869 869 console = io.StringIO() 870 870 871 - def console_matches() -> bool: 871 + def console_matches(_: Any) -> bool: 872 872 nonlocal console 873 873 try: 874 874 # This will return as soon as possible and ··· 884 884 if timeout is not None: 885 885 retry(console_matches, timeout) 886 886 else: 887 - while not console_matches(): 887 + while not console_matches(False): 888 888 pass 889 889 890 890 def send_key(
+13 -4
nixos/tests/systemd-initrd-vconsole.nix
··· 2 2 name = "systemd-initrd-vconsole"; 3 3 4 4 nodes.machine = { pkgs, ... }: { 5 - boot.kernelParams = [ "rd.systemd.unit=rescue.target" ]; 5 + boot.kernelParams = lib.mkAfter [ "rd.systemd.unit=rescue.target" "loglevel=3" "udev.log_level=3" "systemd.log_level=warning" ]; 6 6 7 7 boot.initrd.systemd = { 8 8 enable = true; ··· 20 20 machine.start() 21 21 machine.wait_for_console_text("Press Enter for maintenance") 22 22 machine.send_console("\n") 23 - machine.wait_for_console_text("Logging in with home") 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") 24 34 25 35 # Check keymap 26 - machine.send_console("(printf '%s to receive text: \\n' Ready && read text && echo \"$text\") </dev/tty1\n") 36 + machine.send_console("(printf '%s to receive text:\\n' Ready && read text && echo \"$text\") </dev/tty1\n") 27 37 machine.wait_for_console_text("Ready to receive text:") 28 38 for key in "asdfjkl;\n": 29 39 machine.send_key(key) 30 40 machine.wait_for_console_text("arstneio") 31 - machine.send_console("systemctl poweroff\n") 32 41 ''; 33 42 })