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