2014-04-14 14:02:44 +02:00
|
|
|
import ./make-test.nix ({ pkgs, latestKernel ? false, ... }:
|
2010-02-06 14:08:15 +01:00
|
|
|
|
|
|
|
{
|
2014-06-28 16:04:49 +02:00
|
|
|
name = "login";
|
2010-02-06 14:08:15 +01:00
|
|
|
|
2014-04-14 14:02:44 +02:00
|
|
|
machine =
|
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
{ boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
|
|
|
|
};
|
2010-02-06 14:08:15 +01:00
|
|
|
|
|
|
|
testScript =
|
|
|
|
''
|
2014-04-18 01:22:38 +02:00
|
|
|
$machine->waitForUnit('multi-user.target');
|
|
|
|
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty1'");
|
2012-10-04 18:34:44 +02:00
|
|
|
$machine->screenshot("postboot");
|
|
|
|
|
2011-01-06 18:28:35 +01:00
|
|
|
subtest "create user", sub {
|
|
|
|
$machine->succeed("useradd -m alice");
|
|
|
|
$machine->succeed("(echo foobar; echo foobar) | passwd alice");
|
|
|
|
};
|
2010-02-06 14:08:15 +01:00
|
|
|
|
2012-10-04 18:34:44 +02:00
|
|
|
# Check whether switching VTs works.
|
|
|
|
subtest "virtual console switching", sub {
|
2014-04-18 01:22:38 +02:00
|
|
|
$machine->fail("pgrep -f 'agetty.*tty2'");
|
2012-10-04 18:34:44 +02:00
|
|
|
$machine->sendKeys("alt-f2");
|
|
|
|
$machine->waitUntilSucceeds("[ \$(fgconsole) = 2 ]");
|
|
|
|
$machine->waitForUnit('getty@tty2.service');
|
2014-04-18 01:22:38 +02:00
|
|
|
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty2'");
|
2012-10-04 18:34:44 +02:00
|
|
|
};
|
|
|
|
|
2011-01-06 18:28:35 +01:00
|
|
|
# Log in as alice on a virtual console.
|
|
|
|
subtest "virtual console login", sub {
|
2011-07-28 14:10:39 +02:00
|
|
|
$machine->sleep(2); # urgh: wait for username prompt
|
2011-01-06 18:28:35 +01:00
|
|
|
$machine->sendChars("alice\n");
|
|
|
|
$machine->waitUntilSucceeds("pgrep login");
|
2011-01-10 15:41:16 +01:00
|
|
|
$machine->sleep(2); # urgh: wait for `Password:'
|
2011-01-06 18:28:35 +01:00
|
|
|
$machine->sendChars("foobar\n");
|
|
|
|
$machine->waitUntilSucceeds("pgrep -u alice bash");
|
|
|
|
$machine->sendChars("touch done\n");
|
|
|
|
$machine->waitForFile("/home/alice/done");
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2012-10-04 18:34:44 +02:00
|
|
|
# Check whether systemd gives and removes device ownership as
|
|
|
|
# needed.
|
2011-01-06 18:28:35 +01:00
|
|
|
subtest "device permissions", sub {
|
2012-10-04 18:34:44 +02:00
|
|
|
$machine->succeed("getfacl /dev/snd/timer | grep -q alice");
|
|
|
|
$machine->sendKeys("alt-f1");
|
|
|
|
$machine->waitUntilSucceeds("[ \$(fgconsole) = 1 ]");
|
2011-08-29 16:23:26 +02:00
|
|
|
$machine->fail("getfacl /dev/snd/timer | grep -q alice");
|
2011-01-06 18:28:35 +01:00
|
|
|
$machine->succeed("chvt 2");
|
2012-10-04 18:34:44 +02:00
|
|
|
$machine->waitUntilSucceeds("getfacl /dev/snd/timer | grep -q alice");
|
2011-01-06 18:28:35 +01:00
|
|
|
};
|
2010-03-09 12:38:24 +01:00
|
|
|
|
|
|
|
# Log out.
|
2011-01-06 18:28:35 +01:00
|
|
|
subtest "virtual console logout", sub {
|
|
|
|
$machine->sendChars("exit\n");
|
|
|
|
$machine->waitUntilFails("pgrep -u alice bash");
|
|
|
|
$machine->screenshot("mingetty");
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-02-06 14:08:15 +01:00
|
|
|
# Check whether ctrl-alt-delete works.
|
2011-01-06 18:28:35 +01:00
|
|
|
subtest "ctrl-alt-delete", sub {
|
|
|
|
$machine->sendKeys("ctrl-alt-delete");
|
|
|
|
$machine->waitForShutdown;
|
|
|
|
};
|
2010-02-06 14:08:15 +01:00
|
|
|
'';
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2014-04-14 14:02:44 +02:00
|
|
|
})
|