summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorWeathercold <weathercold.scr@gmail.com>2022-08-20 16:43:25 -0400
committerWeathercold <weathercold.scr@gmail.com>2022-08-20 16:43:25 -0400
commit7874b995fba14ba6111e10e2bb7f89224ddaa41b (patch)
tree162d39f6e6052528ae806083ac0211a2806acbde /nixos/tests
parent8fb63401afa3d252bc41f6857a56cca3a39f66e7 (diff)
downloadnixpkgs-7874b995fba14ba6111e10e2bb7f89224ddaa41b.tar
nixpkgs-7874b995fba14ba6111e10e2bb7f89224ddaa41b.tar.gz
nixpkgs-7874b995fba14ba6111e10e2bb7f89224ddaa41b.tar.bz2
nixpkgs-7874b995fba14ba6111e10e2bb7f89224ddaa41b.tar.lz
nixpkgs-7874b995fba14ba6111e10e2bb7f89224ddaa41b.tar.xz
nixpkgs-7874b995fba14ba6111e10e2bb7f89224ddaa41b.tar.zst
nixpkgs-7874b995fba14ba6111e10e2bb7f89224ddaa41b.zip
nixos/switch-test: add test for services starting with dash
Ensures that services starting with dash can be reloaded.
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/switch-test.nix39
1 files changed, 38 insertions, 1 deletions
diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix
index 0198866b6ff..f891a2cb2f4 100644
--- a/nixos/tests/switch-test.nix
+++ b/nixos/tests/switch-test.nix
@@ -214,6 +214,25 @@ in {
           systemd.services."escaped\\x2ddash".serviceConfig.X-Test = "test";
         };
 
+        unitStartingWithDash.configuration = {
+          systemd.services."-" = {
+            wantedBy = [ "multi-user.target" ];
+            serviceConfig = {
+              Type = "oneshot";
+              RemainAfterExit = true;
+              ExecStart = "${pkgs.coreutils}/bin/true";
+            };
+          };
+        };
+
+        unitStartingWithDashModified.configuration = {
+          imports = [ unitStartingWithDash.configuration ];
+          systemd.services."-" = {
+            reloadIfChanged = true;
+            serviceConfig.ExecReload = "${pkgs.coreutils}/bin/true";
+          };
+        };
+
         unitWithRequirement.configuration = {
           systemd.services.required-service = {
             wantedBy = [ "multi-user.target" ];
@@ -637,9 +656,27 @@ in {
         assert_contains(out, "\nstarting the following units: escaped\\x2ddash.service\n")
         assert_lacks(out, "the following new units were started:")
 
+        # Ensure units can start with a dash
+        out = switch_to_specialisation("${machine}", "unitStartingWithDash")
+        assert_contains(out, "stopping the following units: escaped\\x2ddash.service\n")
+        assert_lacks(out, "NOT restarting the following changed units:")
+        assert_lacks(out, "reloading the following units:")
+        assert_lacks(out, "\nrestarting the following units:")
+        assert_lacks(out, "\nstarting the following units:")
+        assert_contains(out, "the following new units were started: -.service\n")
+
+        # The regression only occurs when reloading units
+        out = switch_to_specialisation("${machine}", "unitStartingWithDashModified")
+        assert_lacks(out, "stopping the following units:")
+        assert_lacks(out, "NOT restarting the following changed units:")
+        assert_contains(out, "reloading the following units: -.service")
+        assert_lacks(out, "\nrestarting the following units:")
+        assert_lacks(out, "\nstarting the following units:")
+        assert_lacks(out, "the following new units were started:")
+
         # Ensure units that require changed units are properly reloaded
         out = switch_to_specialisation("${machine}", "unitWithRequirement")
-        assert_contains(out, "stopping the following units: escaped\\x2ddash.service\n")
+        assert_contains(out, "stopping the following units: -.service\n")
         assert_lacks(out, "NOT restarting the following changed units:")
         assert_lacks(out, "reloading the following units:")
         assert_lacks(out, "\nrestarting the following units:")