mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 12:29:02 +02:00
nixos/login: Port test to python
This commit is contained in:
parent
7d19c5aaa7
commit
be48c5c571
|
@ -1,4 +1,4 @@
|
||||||
import ./make-test.nix ({ pkgs, latestKernel ? false, ... }:
|
import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "login";
|
name = "login";
|
||||||
|
@ -12,62 +12,48 @@ import ./make-test.nix ({ pkgs, latestKernel ? false, ... }:
|
||||||
sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
|
sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript = ''
|
||||||
''
|
machine.wait_for_unit("multi-user.target")
|
||||||
$machine->waitForUnit('multi-user.target');
|
machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
|
||||||
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty1'");
|
machine.screenshot("postboot")
|
||||||
$machine->screenshot("postboot");
|
|
||||||
|
|
||||||
subtest "create user", sub {
|
with subtest("create user"):
|
||||||
$machine->succeed("useradd -m alice");
|
machine.succeed("useradd -m alice")
|
||||||
$machine->succeed("(echo foobar; echo foobar) | passwd alice");
|
machine.succeed("(echo foobar; echo foobar) | passwd alice")
|
||||||
};
|
|
||||||
|
|
||||||
# Check whether switching VTs works.
|
with subtest("Check whether switching VTs works"):
|
||||||
subtest "virtual console switching", sub {
|
machine.fail("pgrep -f 'agetty.*tty2'")
|
||||||
$machine->fail("pgrep -f 'agetty.*tty2'");
|
machine.send_key("alt-f2")
|
||||||
$machine->sendKeys("alt-f2");
|
machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
|
||||||
$machine->waitUntilSucceeds("[ \$(fgconsole) = 2 ]");
|
machine.wait_for_unit("getty@tty2.service")
|
||||||
$machine->waitForUnit('getty@tty2.service');
|
machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
|
||||||
$machine->waitUntilSucceeds("pgrep -f 'agetty.*tty2'");
|
|
||||||
};
|
|
||||||
|
|
||||||
# Log in as alice on a virtual console.
|
with subtest("Log in as alice on a virtual console"):
|
||||||
subtest "virtual console login", sub {
|
machine.wait_until_tty_matches(2, "login: ")
|
||||||
$machine->waitUntilTTYMatches(2, "login: ");
|
machine.send_chars("alice\n")
|
||||||
$machine->sendChars("alice\n");
|
machine.wait_until_tty_matches(2, "login: alice")
|
||||||
$machine->waitUntilTTYMatches(2, "login: alice");
|
machine.wait_until_succeeds("pgrep login")
|
||||||
$machine->waitUntilSucceeds("pgrep login");
|
machine.wait_until_tty_matches(2, "Password: ")
|
||||||
$machine->waitUntilTTYMatches(2, "Password: ");
|
machine.send_chars("foobar\n")
|
||||||
$machine->sendChars("foobar\n");
|
machine.wait_until_succeeds("pgrep -u alice bash")
|
||||||
$machine->waitUntilSucceeds("pgrep -u alice bash");
|
machine.send_chars("touch done\n")
|
||||||
$machine->sendChars("touch done\n");
|
machine.wait_for_file("/home/alice/done")
|
||||||
$machine->waitForFile("/home/alice/done");
|
|
||||||
};
|
|
||||||
|
|
||||||
# Check whether systemd gives and removes device ownership as
|
with subtest("Systemd gives and removes device ownership as needed"):
|
||||||
# needed.
|
machine.succeed("getfacl /dev/snd/timer | grep -q alice")
|
||||||
subtest "device permissions", sub {
|
machine.send_key("alt-f1")
|
||||||
$machine->succeed("getfacl -p /dev/snd/timer | grep -q alice");
|
machine.wait_until_succeeds("[ $(fgconsole) = 1 ]")
|
||||||
$machine->sendKeys("alt-f1");
|
machine.fail("getfacl /dev/snd/timer | grep -q alice")
|
||||||
$machine->waitUntilSucceeds("[ \$(fgconsole) = 1 ]");
|
machine.succeed("chvt 2")
|
||||||
$machine->fail("getfacl -p /dev/snd/timer | grep -q alice");
|
machine.wait_until_succeeds("getfacl /dev/snd/timer | grep -q alice")
|
||||||
$machine->succeed("chvt 2");
|
|
||||||
$machine->waitUntilSucceeds("getfacl -p /dev/snd/timer | grep -q alice");
|
|
||||||
};
|
|
||||||
|
|
||||||
# Log out.
|
with subtest("Virtual console logout"):
|
||||||
subtest "virtual console logout", sub {
|
machine.send_chars("exit\n")
|
||||||
$machine->sendChars("exit\n");
|
machine.wait_until_fails("pgrep -u alice bash")
|
||||||
$machine->waitUntilFails("pgrep -u alice bash");
|
machine.screenshot("mingetty")
|
||||||
$machine->screenshot("mingetty");
|
|
||||||
};
|
|
||||||
|
|
||||||
# Check whether ctrl-alt-delete works.
|
with subtest("Check whether ctrl-alt-delete works"):
|
||||||
subtest "ctrl-alt-delete", sub {
|
machine.send_key("ctrl-alt-delete")
|
||||||
$machine->sendKeys("ctrl-alt-delete");
|
machine.wait_for_shutdown()
|
||||||
$machine->waitForShutdown;
|
|
||||||
};
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue