3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/tests/login.nix

68 lines
2.3 KiB
Nix
Raw Normal View History

import ./make-test.nix ({ pkgs, latestKernel ? false, ... }:
{
machine =
{ config, pkgs, lib, ... }:
{ boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
};
testScript =
''
$machine->waitForUnit('multi-user.target');
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty1'");
2012-10-04 17:34:44 +01:00
$machine->screenshot("postboot");
subtest "create user", sub {
$machine->succeed("useradd -m alice");
$machine->succeed("(echo foobar; echo foobar) | passwd alice");
};
2012-10-04 17:34:44 +01:00
# Check whether switching VTs works.
subtest "virtual console switching", sub {
$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');
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty2'");
2012-10-04 17:34:44 +01:00
};
# Log in as alice on a virtual console.
subtest "virtual console login", sub {
$machine->sleep(2); # urgh: wait for username prompt
$machine->sendChars("alice\n");
$machine->waitUntilSucceeds("pgrep login");
$machine->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");
};
2012-10-04 17:34:44 +01:00
# Check whether systemd gives and removes device ownership as
# needed.
subtest "device permissions", sub {
2012-10-04 17:34:44 +01:00
$machine->succeed("getfacl /dev/snd/timer | grep -q alice");
$machine->sendKeys("alt-f1");
$machine->waitUntilSucceeds("[ \$(fgconsole) = 1 ]");
$machine->fail("getfacl /dev/snd/timer | grep -q alice");
$machine->succeed("chvt 2");
2012-10-04 17:34:44 +01:00
$machine->waitUntilSucceeds("getfacl /dev/snd/timer | grep -q alice");
};
# Log out.
subtest "virtual console logout", sub {
$machine->sendChars("exit\n");
$machine->waitUntilFails("pgrep -u alice bash");
$machine->screenshot("mingetty");
};
# Check whether ctrl-alt-delete works.
subtest "ctrl-alt-delete", sub {
$machine->sendKeys("ctrl-alt-delete");
$machine->waitForShutdown;
};
'';
})