aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_config.bats
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-08-14 09:59:55 -0500
committerCraig Jennings <c@cjennings.net>2026-08-14 09:59:55 -0500
commit1a900e50433b0fcd3a192eed1c7989233a6928cf (patch)
treefe558b95439053b7bfd3be7297dc8ef00db2f3a9 /tests/unit/test_config.bats
parent4186fcf3f75831b28333dbfb0814318ec88dd0d0 (diff)
downloadarchangel-1a900e50433b0fcd3a192eed1c7989233a6928cf.tar.gz
archangel-1a900e50433b0fcd3a192eed1c7989233a6928cf.zip
feat(install): optional SWAP_SIZE carves a swap partition for hibernate
Hibernate needs a resume target outside the pool (swap-on-zvol deadlocks, a long-standing OpenZFS issue), and that's only decidable at partition time. SWAP_SIZE=100G in a config file carves partition 3 (type 8200) physically between EFI and root. Root still takes the remainder and the EFI=1/ROOT=2 numbering contract holds. validate_config rejects malformed sizes and multi-disk layouts. get_swap_partition handles nvme vs sata naming. This only partitions: formatting, encryption, and the resume chain stay manual for now. The change ran the real velox reinstall on 2026-08-13 (EFI=512M, SWAP=100G, ROOT=remainder).
Diffstat (limited to 'tests/unit/test_config.bats')
-rw-r--r--tests/unit/test_config.bats43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/unit/test_config.bats b/tests/unit/test_config.bats
index 4169c5e..554c0c7 100644
--- a/tests/unit/test_config.bats
+++ b/tests/unit/test_config.bats
@@ -302,3 +302,46 @@ EOF
[[ "$output" == *"LUKS_PASSPHRASE"* ]]
! [[ "$output" == *"ZFS_PASSPHRASE"* ]]
}
+
+#############################
+# SWAP_SIZE validation
+#############################
+
+@test "validate_config accepts empty SWAP_SIZE (default layout)" {
+ HOSTNAME=h; TIMEZONE=UTC; ROOT_PASSWORD=x
+ SELECTED_DISKS=(/dev/sda); RAID_LEVEL=""; SWAP_SIZE=""
+ run validate_config
+ [[ "$output" != *"SWAP_SIZE"* ]]
+}
+
+@test "validate_config accepts a well-formed SWAP_SIZE on a single disk" {
+ HOSTNAME=h; TIMEZONE=UTC; ROOT_PASSWORD=x
+ SELECTED_DISKS=(/dev/sda); RAID_LEVEL=""; SWAP_SIZE=100G
+ run validate_config
+ [[ "$output" != *"Invalid SWAP_SIZE"* ]]
+ [[ "$output" != *"single-disk"* ]]
+}
+
+@test "validate_config rejects SWAP_SIZE without a unit suffix" {
+ HOSTNAME=h; TIMEZONE=UTC; ROOT_PASSWORD=x
+ SELECTED_DISKS=(/dev/sda); RAID_LEVEL=""; SWAP_SIZE=100
+ run validate_config
+ [ "$status" -eq 1 ]
+ [[ "$output" == *"Invalid SWAP_SIZE"* ]]
+}
+
+@test "validate_config rejects SWAP_SIZE with a bogus unit" {
+ HOSTNAME=h; TIMEZONE=UTC; ROOT_PASSWORD=x
+ SELECTED_DISKS=(/dev/sda); RAID_LEVEL=""; SWAP_SIZE=100Q
+ run validate_config
+ [ "$status" -eq 1 ]
+ [[ "$output" == *"Invalid SWAP_SIZE"* ]]
+}
+
+@test "validate_config rejects SWAP_SIZE on a multi-disk layout" {
+ HOSTNAME=h; TIMEZONE=UTC; ROOT_PASSWORD=x
+ SELECTED_DISKS=(/dev/sda /dev/sdb); RAID_LEVEL=mirror; SWAP_SIZE=100G
+ run validate_config
+ [ "$status" -eq 1 ]
+ [[ "$output" == *"single-disk"* ]]
+}