2014-04-14 13:02:44 +01:00
|
|
|
import ./make-test.nix ({ pkgs, latestKernel ? false, ... }:
|
2010-02-06 13:08:15 +00:00
|
|
|
|
|
|
|
{
|
2014-06-28 15:04:49 +01:00
|
|
|
name = "login";
|
2015-07-12 11:09:40 +01:00
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2019-02-22 15:14:13 +00:00
|
|
|
maintainers = [ eelco ];
|
2015-07-12 11:09:40 +01:00
|
|
|
};
|
2010-02-06 13:08:15 +00:00
|
|
|
|
2014-04-14 13:02:44 +01:00
|
|
|
machine =
|
2018-07-20 21:56:59 +01:00
|
|
|
{ pkgs, lib, ... }:
|
2014-04-14 13:02:44 +01:00
|
|
|
{ boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
|
2019-09-07 00:33:33 +01:00
|
|
|
sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
|
2014-04-14 13:02:44 +01:00
|
|
|
};
|
2010-02-06 13:08:15 +00:00
|
|
|
|
|
|
|
testScript =
|
|
|
|
''
|
2014-04-18 00:22:38 +01:00
|
|
|
$machine->waitForUnit('multi-user.target');
|
|
|
|
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty1'");
|
2012-10-04 17:34:44 +01:00
|
|
|
$machine->screenshot("postboot");
|
|
|
|
|
2011-01-06 17:28:35 +00:00
|
|
|
subtest "create user", sub {
|
|
|
|
$machine->succeed("useradd -m alice");
|
|
|
|
$machine->succeed("(echo foobar; echo foobar) | passwd alice");
|
|
|
|
};
|
2010-02-06 13:08:15 +00:00
|
|
|
|
2012-10-04 17:34:44 +01:00
|
|
|
# Check whether switching VTs works.
|
|
|
|
subtest "virtual console switching", sub {
|
2014-04-18 00:22:38 +01:00
|
|
|
$machine->fail("pgrep -f 'agetty.*tty2'");
|
2012-10-04 17:34:44 +01:00
|
|
|
$machine->sendKeys("alt-f2");
|
|
|
|
$machine->waitUntilSucceeds("[ \$(fgconsole) = 2 ]");
|
|
|
|
$machine->waitForUnit('getty@tty2.service');
|
2014-04-18 00:22:38 +01:00
|
|
|
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty2'");
|
2012-10-04 17:34:44 +01:00
|
|
|
};
|
|
|
|
|
2011-01-06 17:28:35 +00:00
|
|
|
# Log in as alice on a virtual console.
|
|
|
|
subtest "virtual console login", sub {
|
2016-11-30 04:58:21 +00:00
|
|
|
$machine->waitUntilTTYMatches(2, "login: ");
|
2011-01-06 17:28:35 +00:00
|
|
|
$machine->sendChars("alice\n");
|
2016-11-30 04:58:21 +00:00
|
|
|
$machine->waitUntilTTYMatches(2, "login: alice");
|
2011-01-06 17:28:35 +00:00
|
|
|
$machine->waitUntilSucceeds("pgrep login");
|
2016-11-30 04:58:21 +00:00
|
|
|
$machine->waitUntilTTYMatches(2, "Password: ");
|
2011-01-06 17:28:35 +00:00
|
|
|
$machine->sendChars("foobar\n");
|
|
|
|
$machine->waitUntilSucceeds("pgrep -u alice bash");
|
|
|
|
$machine->sendChars("touch done\n");
|
|
|
|
$machine->waitForFile("/home/alice/done");
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2012-10-04 17:34:44 +01:00
|
|
|
# Check whether systemd gives and removes device ownership as
|
|
|
|
# needed.
|
2011-01-06 17:28:35 +00:00
|
|
|
subtest "device permissions", sub {
|
2019-10-11 22:20:57 +01:00
|
|
|
$machine->succeed("getfacl -p /dev/snd/timer | grep -q alice");
|
2012-10-04 17:34:44 +01:00
|
|
|
$machine->sendKeys("alt-f1");
|
|
|
|
$machine->waitUntilSucceeds("[ \$(fgconsole) = 1 ]");
|
2019-10-11 22:20:57 +01:00
|
|
|
$machine->fail("getfacl -p /dev/snd/timer | grep -q alice");
|
2011-01-06 17:28:35 +00:00
|
|
|
$machine->succeed("chvt 2");
|
2019-10-11 22:20:57 +01:00
|
|
|
$machine->waitUntilSucceeds("getfacl -p /dev/snd/timer | grep -q alice");
|
2011-01-06 17:28:35 +00:00
|
|
|
};
|
2010-03-09 11:38:24 +00:00
|
|
|
|
|
|
|
# Log out.
|
2011-01-06 17:28:35 +00:00
|
|
|
subtest "virtual console logout", sub {
|
|
|
|
$machine->sendChars("exit\n");
|
|
|
|
$machine->waitUntilFails("pgrep -u alice bash");
|
|
|
|
$machine->screenshot("mingetty");
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-02-06 13:08:15 +00:00
|
|
|
# Check whether ctrl-alt-delete works.
|
2011-01-06 17:28:35 +00:00
|
|
|
subtest "ctrl-alt-delete", sub {
|
|
|
|
$machine->sendKeys("ctrl-alt-delete");
|
|
|
|
$machine->waitForShutdown;
|
|
|
|
};
|
2010-02-06 13:08:15 +00:00
|
|
|
'';
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2014-04-14 13:02:44 +01:00
|
|
|
})
|