at 23.11-pre 2.6 kB view raw
1import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }: 2 3{ 4 name = "login"; 5 meta = with pkgs.lib.maintainers; { 6 maintainers = [ eelco ]; 7 }; 8 9 nodes.machine = 10 { pkgs, lib, ... }: 11 { boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest; 12 sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then 13 }; 14 15 testScript = '' 16 machine.start(allow_reboot = True) 17 18 machine.wait_for_unit("multi-user.target") 19 machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'") 20 machine.screenshot("postboot") 21 22 with subtest("create user"): 23 machine.succeed("useradd -m alice") 24 machine.succeed("(echo foobar; echo foobar) | passwd alice") 25 26 with subtest("Check whether switching VTs works"): 27 machine.fail("pgrep -f 'agetty.*tty2'") 28 machine.send_key("alt-f2") 29 machine.wait_until_succeeds("[ $(fgconsole) = 2 ]") 30 machine.wait_for_unit("getty@tty2.service") 31 machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'") 32 33 with subtest("Log in as alice on a virtual console"): 34 machine.wait_until_tty_matches("2", "login: ") 35 machine.send_chars("alice\n") 36 machine.wait_until_tty_matches("2", "login: alice") 37 machine.wait_until_succeeds("pgrep login") 38 machine.wait_until_tty_matches("2", "Password: ") 39 machine.send_chars("foobar\n") 40 machine.wait_until_succeeds("pgrep -u alice bash") 41 machine.send_chars("touch done\n") 42 machine.wait_for_file("/home/alice/done") 43 44 with subtest("Systemd gives and removes device ownership as needed"): 45 machine.succeed("getfacl /dev/snd/timer | grep -q alice") 46 machine.send_key("alt-f1") 47 machine.wait_until_succeeds("[ $(fgconsole) = 1 ]") 48 machine.fail("getfacl /dev/snd/timer | grep -q alice") 49 machine.succeed("chvt 2") 50 machine.wait_until_succeeds("getfacl /dev/snd/timer | grep -q alice") 51 52 with subtest("Virtual console logout"): 53 machine.send_chars("exit\n") 54 machine.wait_until_fails("pgrep -u alice bash") 55 machine.screenshot("getty") 56 57 with subtest("Check whether ctrl-alt-delete works"): 58 boot_id1 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip() 59 assert boot_id1 != "" 60 61 machine.reboot() 62 63 boot_id2 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip() 64 assert boot_id2 != "" 65 66 assert boot_id1 != boot_id2 67 ''; 68})