2010-02-06 14:08:15 +01:00
|
|
|
{ pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
machine = { config, pkgs, ... }: { };
|
|
|
|
|
|
|
|
testScript =
|
|
|
|
''
|
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
|
|
|
|
2011-01-06 18:28:35 +01:00
|
|
|
# Log in as alice on a virtual console.
|
|
|
|
subtest "virtual console login", sub {
|
|
|
|
$machine->waitForJob("tty1");
|
|
|
|
$machine->sendChars("alice\n");
|
|
|
|
$machine->waitUntilSucceeds("pgrep login");
|
|
|
|
$machine->execute("sleep 2"); # urgh: wait for `Password:'
|
|
|
|
$machine->sendChars("foobar\n");
|
|
|
|
$machine->waitUntilSucceeds("pgrep -u alice bash");
|
|
|
|
$machine->sendChars("touch done\n");
|
|
|
|
$machine->waitForFile("/home/alice/done");
|
|
|
|
};
|
2010-02-06 14:08:15 +01:00
|
|
|
|
|
|
|
# Check whether switching VTs works.
|
2011-01-06 18:28:35 +01:00
|
|
|
subtest "virtual console switching", sub {
|
|
|
|
$machine->sendKeys("alt-f10");
|
|
|
|
$machine->waitUntilSucceeds("[ \$(fgconsole) = 10 ]");
|
|
|
|
$machine->execute("sleep 2"); # allow fbcondecor to catch up (not important)
|
|
|
|
$machine->screenshot("syslog");
|
|
|
|
};
|
2010-02-06 14:08:15 +01:00
|
|
|
|
2010-03-09 12:38:24 +01:00
|
|
|
# Check whether ConsoleKit/udev gives and removes device
|
|
|
|
# ownership as needed.
|
2011-01-06 18:28:35 +01:00
|
|
|
subtest "device permissions", sub {
|
|
|
|
$machine->succeed("chvt 1");
|
|
|
|
$machine->execute("sleep 1"); # urgh
|
|
|
|
$machine->succeed("getfacl /dev/snd/timer | grep -q alice");
|
|
|
|
$machine->succeed("chvt 2");
|
|
|
|
$machine->execute("sleep 1"); # urgh
|
|
|
|
$machine->fail("getfacl /dev/snd/timer | grep -q alice");
|
|
|
|
};
|
2010-03-09 12:38:24 +01:00
|
|
|
|
|
|
|
# Log out.
|
2011-01-06 18:28:35 +01:00
|
|
|
subtest "virtual console logout", sub {
|
|
|
|
$machine->succeed("chvt 1");
|
|
|
|
$machine->sendChars("exit\n");
|
|
|
|
$machine->waitUntilFails("pgrep -u alice bash");
|
|
|
|
$machine->screenshot("mingetty");
|
|
|
|
};
|
2010-03-09 12:38:24 +01: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
|
|
|
'';
|
|
|
|
|
|
|
|
}
|