From 9b47ad6682fbf3ba3c6ce006a54440e0126fdf04 Mon Sep 17 00:00:00 2001 From: Mikaela Allan Date: Tue, 16 May 2023 10:34:06 -0400 Subject: [PATCH] nixos/config/swap: check failure in swap file test --- nixos/tests/swap-file-btrfs.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/tests/swap-file-btrfs.nix b/nixos/tests/swap-file-btrfs.nix index d9fcd2be1160..35b9fb4fa50a 100644 --- a/nixos/tests/swap-file-btrfs.nix +++ b/nixos/tests/swap-file-btrfs.nix @@ -32,6 +32,8 @@ import ./make-test-python.nix ({ lib, ... }: testScript = '' machine.wait_for_unit('var-swapfile.swap') + # Ensure the swap file creation script ran to completion without failing when creating the swap file + machine.fail("systemctl is-failed --quiet mkswap-var-swapfile.service") machine.succeed("stat --file-system --format=%T /var/swapfile | grep btrfs") # First run. Auto creation. machine.succeed("swapon --show | grep /var/swapfile") @@ -41,6 +43,8 @@ import ./make-test-python.nix ({ lib, ... }: # Second run. Use it as-is. machine.wait_for_unit('var-swapfile.swap') + # Ensure the swap file creation script ran to completion without failing when the swap file already exists + machine.fail("systemctl is-failed --quiet mkswap-var-swapfile.service") machine.succeed("swapon --show | grep /var/swapfile") ''; })