aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-09-13 10:59:31 -0500
committerCraig Jennings <c@cjennings.net>2026-09-13 10:59:31 -0500
commit0adcfaa5c7e479e9c433b92836a5548a19168e05 (patch)
treea3ed77f16ffd493ae18f8958efe7a60430274d6b /tests/unit
parent6e99a7fbae089009e7948cb3853b68364f2f527b (diff)
downloadarchangel-0adcfaa5c7e479e9c433b92836a5548a19168e05.tar.gz
archangel-0adcfaa5c7e479e9c433b92836a5548a19168e05.zip
fix(test): keep each failed install attempt's logHEADmain
The retry loop refetched the guest's newest install log after every failed attempt, so `test-logs/` only ever held the last one. When a retry followed a pacstrap stall, the saved log showed the retry's "Disk in use" and the stall behind it was gone. Each failed attempt's log now lands in `test-logs/<config>-install-attempt<N>.log`.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_test_install.bats42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/unit/test_test_install.bats b/tests/unit/test_test_install.bats
index 52ea037..3fb7c19 100644
--- a/tests/unit/test_test_install.bats
+++ b/tests/unit/test_test_install.bats
@@ -15,6 +15,48 @@ setup() {
}
#############################
+# save_attempt_log
+#############################
+# The retry loop refetches the guest's newest /tmp/archangel-*.log on
+# every failed attempt, so a retried install used to keep only the last
+# attempt's log — the failure that triggered the retry was gone by the
+# time anyone read test-logs/. save_attempt_log keeps each one.
+
+# Normal: a failed attempt's log lands under its own attempt-numbered name.
+@test "save_attempt_log writes the attempt's log under an attempt-numbered name" {
+ local dir="$BATS_TEST_TMPDIR/logs"
+ mkdir -p "$dir"
+ run save_attempt_log "$dir" zfs-encrypt 1 $'line one\nline two'
+ [ "$status" -eq 0 ]
+ [ -f "$dir/zfs-encrypt-install-attempt1.log" ]
+ [ "$(cat "$dir/zfs-encrypt-install-attempt1.log")" = $'line one\nline two' ]
+}
+
+# Boundary: an empty capture still writes a file, so "attempt ran, log
+# was empty" stays distinguishable from "attempt never happened".
+@test "save_attempt_log writes an empty file for an empty capture" {
+ local dir="$BATS_TEST_TMPDIR/logs"
+ mkdir -p "$dir"
+ run save_attempt_log "$dir" mirror 2 ""
+ [ "$status" -eq 0 ]
+ [ -f "$dir/mirror-install-attempt2.log" ]
+ [ ! -s "$dir/mirror-install-attempt2.log" ]
+}
+
+# Error: an unwritable log dir fails the save without aborting the caller.
+@test "save_attempt_log returns non-zero when the log dir is unwritable" {
+ [ "$EUID" -ne 0 ] || skip "running as root"
+ local dir="$BATS_TEST_TMPDIR/logs"
+ mkdir -p "$dir"
+ chmod 000 "$dir"
+ run save_attempt_log "$dir" mirror 1 "content"
+ chmod 755 "$dir"
+ [ "$status" -eq 1 ]
+ [ -z "$output" ]
+ [ ! -f "$dir/mirror-install-attempt1.log" ]
+}
+
+#############################
# is_transient_install_failure
#############################