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