systemd test: add test for systemd-shutdown scripts
This commit is contained in:
parent
a304fc5d75
commit
5636fe572b
@ -1,4 +1,4 @@
|
|||||||
import ./make-test.nix {
|
import ./make-test.nix ({ pkgs, ... }: {
|
||||||
name = "systemd";
|
name = "systemd";
|
||||||
|
|
||||||
machine = { lib, ... }: {
|
machine = { lib, ... }: {
|
||||||
@ -21,6 +21,14 @@ import ./make-test.nix {
|
|||||||
services.journald.extraConfig = "Storage=volatile";
|
services.journald.extraConfig = "Storage=volatile";
|
||||||
services.xserver.displayManager.auto.user = "alice";
|
services.xserver.displayManager.auto.user = "alice";
|
||||||
|
|
||||||
|
systemd.shutdown.test = pkgs.writeScript "test.shutdown" ''
|
||||||
|
#!${pkgs.stdenv.shell}
|
||||||
|
PATH=${lib.makeBinPath (with pkgs; [ utillinux coreutils ])}
|
||||||
|
mount -t 9p shared -o trans=virtio,version=9p2000.L /tmp/shared
|
||||||
|
touch /tmp/shared/shutdown-test
|
||||||
|
umount /tmp/shared
|
||||||
|
'';
|
||||||
|
|
||||||
systemd.services.testservice1 = {
|
systemd.services.testservice1 = {
|
||||||
description = "Test Service 1";
|
description = "Test Service 1";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
@ -69,5 +77,20 @@ import ./make-test.nix {
|
|||||||
# has a last mount time, because the file system wasn't checked.
|
# has a last mount time, because the file system wasn't checked.
|
||||||
$machine->fail('dumpe2fs /dev/vdb | grep -q "^Last mount time: *n/a"');
|
$machine->fail('dumpe2fs /dev/vdb | grep -q "^Last mount time: *n/a"');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Regression test for https://github.com/NixOS/nixpkgs/issues/35268
|
||||||
|
subtest "file system with x-initrd.mount is not unmounted", sub {
|
||||||
|
$machine->shutdown;
|
||||||
|
$machine->waitForUnit('multi-user.target');
|
||||||
|
# If the file system was unmounted during the shutdown the file system
|
||||||
|
# has a last mount time, because the file system wasn't checked.
|
||||||
|
$machine->fail('dumpe2fs /dev/vdb | grep -q "^Last mount time: *n/a"');
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest "systemd-shutdown works", sub {
|
||||||
|
$machine->shutdown;
|
||||||
|
$machine->waitForUnit('multi-user.target');
|
||||||
|
$machine->succeed('test -e /tmp/shared/shutdown-test');
|
||||||
|
};
|
||||||
'';
|
'';
|
||||||
}
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user