nixos/config/swap: check failure in swap file test

Changed files
+4
nixos
+4
nixos/tests/swap-file-btrfs.nix
···
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")
···
# 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")
'';
})