c65779cafae6

gen test creates distinct generations via config changes to exercise history/back/go/clean

time
2026-05-29 16:52 UTC · 4 months ago
machine
koh2
parent
7ae2557619ee
1 file test/vm/tests/gen.sh+21 −22
test/vm/tests/gen.sh+21 −22
@@ -1,42 +1,41 @@11 #!/usr/bin/env sh2-# G-01/G-02/G-03 generations validation, run inside the VM. Prints nina's output3-# alongside ground-truth system-profile state so the host can judge pass/fail.4-# Ground truth uses the SYSTEM profile explicitly (-p), which is what5-# nixos-rebuild manages.2+# G-01/G-02/G-03 generations validation, run inside the VM. Creates distinct3+# system generations by changing the config between applies (a tiny /etc file via4+# an imported module), then exercises history/current/back/go/clean. Prints5+# nina's output beside ground-truth system-profile state for host-side judging.66 set -u77 N=/root/nina88 99 sysgens() { nix-env -p /nix/var/nix/profiles/system --list-generations 2>/dev/null | wc -l | tr -d ' '; }1010 syscur()  { readlink /nix/var/nix/profiles/system | sed -n 's/.*system-\([0-9][0-9]*\)-link/\1/p'; }11+mkgen()   { printf '{ ... }: { environment.etc."nina-gen".text = "%s"; }\n' "$1" > /etc/nixos/genmarker.nix; }1112 1213 echo "KILN_GEN_TEST_BEGIN"14+15+# Import a marker module so each content change yields a new system generation.16+sed -i 's| ./hardware-configuration.nix | ./hardware-configuration.nix ./genmarker.nix |' /etc/nixos/configuration.nix17+echo "imports now: $(grep -o 'imports = .*];' /etc/nixos/configuration.nix)"1318 echo "GROUND before: sysgens=$(sysgens) syscur=$(syscur)"1419 15-echo "### T-001 nina apply (expect exit 0, system generation increments)"16-$N apply; echo "T001_RC=$?"17-echo "GROUND after apply#1: sysgens=$(sysgens) syscur=$(syscur)"20+echo "### G-01 apply x3 with config changes (expect generations to increment)"21+mkgen A; $N apply; echo "APPLY_A_RC=$?"; echo "GROUND: sysgens=$(sysgens) syscur=$(syscur)"22+mkgen B; $N apply; echo "APPLY_B_RC=$?"; echo "GROUND: sysgens=$(sysgens) syscur=$(syscur)"23+mkgen C; $N apply; echo "APPLY_C_RC=$?"; echo "GROUND: sysgens=$(sysgens) syscur=$(syscur)"1824 19-echo "### T-002 nina apply again (expect generation increments again)"20-$N apply; echo "T002_RC=$?"21-echo "GROUND after apply#2: sysgens=$(sysgens) syscur=$(syscur)"22-2325 echo "### T-015 nina history (expect all system generations, current marked)"2426 $N history; echo "HIST_RC=$?"2527 26-echo "### T-017 nina gen current (expect current system generation number)"28+echo "### T-017 nina gen current (expect = $(syscur))"2729 $N gen current; echo "GENCUR_RC=$?"2830 29-echo "### T-010 nina back (expect system generation decrements)"30-$N back; echo "BACK_RC=$?"31-echo "GROUND after back: syscur=$(syscur)"31+echo "### T-010 nina back (expect syscur decrements by 1)"32+$N back; echo "BACK_RC=$?"; echo "GROUND after back: syscur=$(syscur)"3233 33-echo "### T-012 nina go <syscur+1> (return forward)"34-TARGET=$(( $(syscur) + 1 ))35-$N go "$TARGET"; echo "GO_RC=$?"36-echo "GROUND after go $TARGET: syscur=$(syscur)"34+echo "### T-012 nina go <newest> (return forward)"35+NEWEST=$(nix-env -p /nix/var/nix/profiles/system --list-generations | awk '{print $1}' | sort -n | tail -1)36+$N go "$NEWEST"; echo "GO_RC=$?"; echo "GROUND after go $NEWEST: syscur=$(syscur)"3737 38-echo "### T-030 nina clean (expect exit 0, garbage collected)"39-$N clean; echo "CLEAN_RC=$?"40-echo "GROUND after clean: sysgens=$(sysgens)"38+echo "### T-030 nina clean (keep 5; expect exit 0, no duration error)"39+$N clean; echo "CLEAN_RC=$?"; echo "GROUND after clean: sysgens=$(sysgens)"4140 4241 echo "KILN_GEN_TEST_END"

view file