aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/maint-scenarios/20-cache-keep3.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-08 05:45:51 -0500
committerCraig Jennings <c@cjennings.net>2026-07-08 05:45:51 -0500
commitd6993d35368f4733cac7dfd23be354de7ef0a0fb (patch)
tree5b4fb22b66d69bf5851dac0e32614ef958af5378 /scripts/testing/maint-scenarios/20-cache-keep3.sh
parent26f7ea43ed3ef2dcb088dc4af5eb5881743f6a88 (diff)
downloadarchsetup-d6993d35368f4733cac7dfd23be354de7ef0a0fb.tar.gz
archsetup-d6993d35368f4733cac7dfd23be354de7ef0a0fb.zip
test(maint): add VM and nspawn remedy scenario harness
Nine break/fix/assert scenarios run the real maint fix inside the test VM. The runner batches non-conflicting scenarios into one VM boot, restores the snapshot only between groups, and leaves the base image pristine afterwards. A systemd-nspawn fast lane runs the pacman-level group against a cached pacstrap rootfs in seconds. The plan layer validates the scenario contract without a VM and carries a 19-test unit suite. make test-maint wires the VM lane in. The zfs lane is filtered but unexercised: the FS_PROFILE=zfs base image fails to build (ZFS DKMS module not found on linux-lts 6.18). The failure is tracked in the todo.
Diffstat (limited to 'scripts/testing/maint-scenarios/20-cache-keep3.sh')
-rw-r--r--scripts/testing/maint-scenarios/20-cache-keep3.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/testing/maint-scenarios/20-cache-keep3.sh b/scripts/testing/maint-scenarios/20-cache-keep3.sh
new file mode 100644
index 0000000..a9a6ee5
--- /dev/null
+++ b/scripts/testing/maint-scenarios/20-cache-keep3.sh
@@ -0,0 +1,24 @@
+# shellcheck shell=bash disable=SC2034 # sourced by run-maint-scenarios.sh
+# Scenario: paccache -rk3 trims an installed package's cache to 3 versions.
+#
+# paccache decides from filenames, so five fake versions of a package that
+# IS installed (bash) stand in for a fat cache. The bootstrap may leave a
+# real bash package in the cache too, so the assert uses the ordering
+# invariant rather than a count: the two newest fakes survive any keep-3
+# window that contains them, and the two oldest fall outside it whether or
+# not a real (newer) version is cached alongside.
+SCENARIO_DESC="pacman cache trimmed to three versions per package"
+SCENARIO_GROUP="packages"
+SCENARIO_PROFILES="any"
+
+scenario_break() {
+ mexec "for v in 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5; do touch /var/cache/pacman/pkg/bash-\$v-1-x86_64.pkg.tar.zst; done; ls /var/cache/pacman/pkg/ | grep -c '^bash-'"
+}
+
+scenario_fix() {
+ mfix cache_clean
+}
+
+scenario_assert() {
+ mexec "test -e /var/cache/pacman/pkg/bash-1.0.5-1-x86_64.pkg.tar.zst && test -e /var/cache/pacman/pkg/bash-1.0.4-1-x86_64.pkg.tar.zst && test ! -e /var/cache/pacman/pkg/bash-1.0.2-1-x86_64.pkg.tar.zst && test ! -e /var/cache/pacman/pkg/bash-1.0.1-1-x86_64.pkg.tar.zst"
+}