2019-09-10 14:00:04 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }:
|
2010-02-06 13:08:15 +00:00
|
|
|
|
|
|
|
{
|
2014-06-28 14:04:49 +00:00
|
|
|
name = "login";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2019-02-22 15:14:13 +00:00
|
|
|
maintainers = [ eelco ];
|
2015-07-12 10:09:40 +00:00
|
|
|
};
|
2010-02-06 13:08:15 +00:00
|
|
|
|
2022-03-20 23:15:30 +00:00
|
|
|
nodes.machine =
|
2018-07-20 20:56:59 +00:00
|
|
|
{ pkgs, lib, ... }:
|
2014-04-14 12:02:44 +00:00
|
|
|
{ boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
|
2019-09-06 23:33:33 +00:00
|
|
|
sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
|
2014-04-14 12:02:44 +00:00
|
|
|
};
|
2010-02-06 13:08:15 +00:00
|
|
|
|
2019-09-10 14:00:04 +00:00
|
|
|
testScript = ''
|
2023-03-16 00:50:15 +00:00
|
|
|
machine.start(allow_reboot = True)
|
2023-03-16 00:42:00 +00:00
|
|
|
|
2019-09-10 14:00:04 +00:00
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
|
|
|
|
machine.screenshot("postboot")
|
|
|
|
|
|
|
|
with subtest("create user"):
|
|
|
|
machine.succeed("useradd -m alice")
|
|
|
|
machine.succeed("(echo foobar; echo foobar) | passwd alice")
|
|
|
|
|
|
|
|
with subtest("Check whether switching VTs works"):
|
|
|
|
machine.fail("pgrep -f 'agetty.*tty2'")
|
|
|
|
machine.send_key("alt-f2")
|
|
|
|
machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
|
|
|
|
machine.wait_for_unit("getty@tty2.service")
|
|
|
|
machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
|
|
|
|
|
|
|
|
with subtest("Log in as alice on a virtual console"):
|
2022-06-04 04:22:03 +00:00
|
|
|
machine.wait_until_tty_matches("2", "login: ")
|
2019-09-10 14:00:04 +00:00
|
|
|
machine.send_chars("alice\n")
|
2022-06-04 04:22:03 +00:00
|
|
|
machine.wait_until_tty_matches("2", "login: alice")
|
2019-09-10 14:00:04 +00:00
|
|
|
machine.wait_until_succeeds("pgrep login")
|
2022-06-04 04:22:03 +00:00
|
|
|
machine.wait_until_tty_matches("2", "Password: ")
|
2019-09-10 14:00:04 +00:00
|
|
|
machine.send_chars("foobar\n")
|
|
|
|
machine.wait_until_succeeds("pgrep -u alice bash")
|
|
|
|
machine.send_chars("touch done\n")
|
|
|
|
machine.wait_for_file("/home/alice/done")
|
|
|
|
|
|
|
|
with subtest("Systemd gives and removes device ownership as needed"):
|
|
|
|
machine.succeed("getfacl /dev/snd/timer | grep -q alice")
|
|
|
|
machine.send_key("alt-f1")
|
|
|
|
machine.wait_until_succeeds("[ $(fgconsole) = 1 ]")
|
|
|
|
machine.fail("getfacl /dev/snd/timer | grep -q alice")
|
|
|
|
machine.succeed("chvt 2")
|
|
|
|
machine.wait_until_succeeds("getfacl /dev/snd/timer | grep -q alice")
|
|
|
|
|
|
|
|
with subtest("Virtual console logout"):
|
|
|
|
machine.send_chars("exit\n")
|
|
|
|
machine.wait_until_fails("pgrep -u alice bash")
|
2021-01-05 08:25:53 +00:00
|
|
|
machine.screenshot("getty")
|
2019-09-10 14:00:04 +00:00
|
|
|
|
|
|
|
with subtest("Check whether ctrl-alt-delete works"):
|
2023-03-16 00:42:00 +00:00
|
|
|
boot_id1 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
|
|
|
|
assert boot_id1 != ""
|
|
|
|
|
|
|
|
machine.reboot()
|
|
|
|
|
|
|
|
boot_id2 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
|
|
|
|
assert boot_id2 != ""
|
|
|
|
|
|
|
|
assert boot_id1 != boot_id2
|
2019-09-10 14:00:04 +00:00
|
|
|
'';
|
2014-04-14 12:02:44 +00:00
|
|
|
})
|