about summary refs log tree commit diff
path: root/nixos/tests/systemd-shutdown.nix
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2022-04-15 11:23:02 +0100
committerJanne Heß <janne@hess.ooo>2022-04-16 21:17:36 +0100
commit30a00c29c4b0be54cee6f8bcfb2fdde583454407 (patch)
treec4cc9b875e32aa70ef61def3ccb7b437ca17ad22 /nixos/tests/systemd-shutdown.nix
parent031b95e587f75da4796c95e8ee232383310389c5 (diff)
nixos/systemd: Properly shut down the system
Diffstat (limited to 'nixos/tests/systemd-shutdown.nix')
-rw-r--r--nixos/tests/systemd-shutdown.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/nixos/tests/systemd-shutdown.nix b/nixos/tests/systemd-shutdown.nix
new file mode 100644
index 0000000000000..9283489c25591
--- /dev/null
+++ b/nixos/tests/systemd-shutdown.nix
@@ -0,0 +1,21 @@
+import ./make-test-python.nix ({ pkgs, systemdStage1 ? false, ...} : {
+  name = "systemd-shutdown";
+  meta = with pkgs.lib.maintainers; {
+    maintainers = [ das_j ];
+  };
+
+  nodes.machine = {
+    imports = [ ../modules/profiles/minimal.nix ];
+    boot.initrd.systemd.enable = systemdStage1;
+  };
+
+  testScript = ''
+    machine.wait_for_unit("multi-user.target")
+    # .shutdown() would wait for the machine to power off
+    machine.succeed("systemctl poweroff")
+    # Message printed by systemd-shutdown
+    machine.wait_for_console_text("All filesystems, swaps, loop devices, MD devices and DM devices detached.")
+    # Don't try to sync filesystems
+    machine.booted = False
+  '';
+})