about summary refs log tree commit diff
path: root/nixos/tests/systemd-template-override.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/tests/systemd-template-override.nix')
-rw-r--r--nixos/tests/systemd-template-override.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/nixos/tests/systemd-template-override.nix b/nixos/tests/systemd-template-override.nix
new file mode 100644
index 0000000000000..d8ef4a6c1c9bd
--- /dev/null
+++ b/nixos/tests/systemd-template-override.nix
@@ -0,0 +1,41 @@
+import ./make-test-python.nix {
+  name = "systemd-template-override";
+
+  machine = { pkgs, lib, ... }: let
+    touchTmp = pkgs.writeTextFile {
+      name = "touch-tmp@.service";
+      text = ''
+        [Service]
+        Type=oneshot
+        ExecStart=${pkgs.coreutils}/bin/touch /tmp/%I
+      '';
+      destination = "/etc/systemd/system/touch-tmp@.service";
+    };
+  in {
+    systemd.packages = [ touchTmp ];
+
+    systemd.services."touch-tmp@forbidden" = {
+      serviceConfig.ExecStart = [ "" ''
+        ${pkgs.coreutils}/bin/true
+      ''];
+    };
+
+    systemd.services."touch-tmp@intercept" = {
+      serviceConfig.ExecStart = [ "" ''
+        ${pkgs.coreutils}/bin/touch /tmp/renamed
+      ''];
+    };
+  };
+
+  testScript = ''
+    machine.wait_for_unit("default.target")
+
+    machine.succeed("systemctl start touch-tmp@normal")
+    machine.succeed("systemctl start touch-tmp@forbbidden")
+    machine.succeed("systemctl start touch-tmp@intercept")
+
+    machine.succeed("[ -e /tmp/normal ]")
+    machine.succeed("[ ! -e /tmp/forbidden ]")
+    machine.succeed("[ -e /tmp/renamed ]")
+  '';
+}