summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJulien Malka <julien@malka.sh>2023-11-17 22:34:30 +0100
committerGitHub <noreply@github.com>2023-11-17 22:34:30 +0100
commit4d968c70fb320edbe0a94d6a6a834d9ed2de351f (patch)
tree750418ed03361b23d5883b40a29a7c593ccf93c2 /nixos
parentde20681ff7cb84daea4d85630a6a59f2eacf265e (diff)
parente63f3c012b20d4bad4c456ff950f31aa4fbf0740 (diff)
Merge pull request #265365 from JulienMalka/systemd-boot-garbage-test
nixos/tests/systemd-boot: add garbage-collect-entry test
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/systemd-boot.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/nixos/tests/systemd-boot.nix b/nixos/tests/systemd-boot.nix
index a592504addc03..256a18532b0a2 100644
--- a/nixos/tests/systemd-boot.nix
+++ b/nixos/tests/systemd-boot.nix
@@ -252,6 +252,35 @@ in
     '';
   };
 
+  garbage-collect-entry = makeTest {
+    name = "systemd-boot-switch-test";
+    meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ];
+
+    nodes = {
+      inherit common;
+      machine = { pkgs, nodes, ... }: {
+        imports = [ common ];
+
+        # These are configs for different nodes, but we'll use them here in `machine`
+        system.extraDependencies = [
+          nodes.common.system.build.toplevel
+        ];
+      };
+    };
+
+    testScript = { nodes, ... }:
+      let
+        baseSystem = nodes.common.system.build.toplevel;
+      in
+      ''
+        machine.succeed("nix-env -p /nix/var/nix/profiles/system --set ${baseSystem}")
+        machine.succeed("nix-env -p /nix/var/nix/profiles/system --delete-generations 1")
+        machine.succeed("${baseSystem}/bin/switch-to-configuration boot")
+        machine.fail("test -e /boot/loader/entries/nixos-generation-1.conf")
+        machine.succeed("test -e /boot/loader/entries/nixos-generation-2.conf")
+      '';
+  };
+
   # Some UEFI firmwares fail on large reads. Now that systemd-boot loads initrd
   # itself, systems with such firmware won't boot without this fix
   uefiLargeFileWorkaround = makeTest {