diff --git a/bin/box b/bin/box index 6fbf3bb..a57d6ec 100755 --- a/bin/box +++ b/bin/box @@ -236,9 +236,10 @@ being told. --name Required. The box's name. --template Template to mint from; 'box templates' lists them. A template sets image, user, resources and boot - demands (a server-class one insists on VM mode and - autostart) — never the network: every template gets - the same isolation. + demands (independently: BOX_REQUIRE_VM insists on + VM mode, BOX_AUTOSTART survives host reboots) — + never the network: every template gets the same + isolation. --from [/] Clone src's live state, or its snapshot . --cpu CPUs for this mint (limits.cpu, verbatim to Incus). --memory RAM for this mint, e.g. 3GiB (limits.memory). diff --git a/test/cli.sh b/test/cli.sh index fb8ae33..78f793c 100644 --- a/test/cli.sh +++ b/test/cli.sh @@ -165,6 +165,15 @@ check "load_template: an unknown key dies (no template grows a network)" 1 "unkn tpl "$EVILROOT" evil printf 'BOX_USER="dev"\n' > "$EVILROOT/templates/evil/box.env" check "load_template: a missing BOX_IMAGE dies" 1 "required" tpl "$EVILROOT" evil +# The green path the two new keys exist for: no in-tree template sets them yet +# (the seed lands after rig#31), so without this fixture the case arms could be +# deleted and the suite would stay green while the keys silently died as +# "unknown key" at first use. Accepted AND surfaced, through the real parser. +mkdir -p "$EVILROOT/templates/server" +printf 'BOX_IMAGE="images:debian/13/cloud"\nBOX_USER="ops"\nBOX_REQUIRE_VM="1"\nBOX_AUTOSTART="1"\n' \ + > "$EVILROOT/templates/server/box.env" +check "load_template: REQUIRE_VM and AUTOSTART round-trip (accepted + surfaced)" \ + 0 "REQUIRE_VM=1 AUTOSTART=1" tpl "$EVILROOT" server rm -rf "$EVILROOT" # YAML well-formedness needs python3 + pyyaml; the CI runner has both. Skip @@ -211,6 +220,14 @@ check "new: the REQUIRE_VM refusal orders after pick_mode" 0 "" bash -c ' pick="$(printf "%s\n" "$fn" | grep -n "pick_mode" | head -1 | cut -d: -f1)" guard="$(printf "%s\n" "$fn" | grep -n "T_REQUIRE_VM" | head -1 | cut -d: -f1)" [ -n "$pick" ] && [ -n "$guard" ] && [ "$pick" -lt "$guard" ]' +# Order is necessary, not sufficient: a regression to the RAW flag +# ([ "$mode" != vm ]) would still sit after pick_mode — and would refuse every +# auto mint on a valid VM host. Pin the guard to the EFFECTIVE operand: the +# T_REQUIRE_VM line itself must compare $m, the pick_mode result. +# shellcheck disable=SC2016 # the $-strings are literals in the target file +check "new: the REQUIRE_VM guard compares the effective mode (\$m)" 0 "" bash -c ' + awk "/^cmd_new\(\) \{/,/^\}/" "'"$ROOT"'/bin/box" \ + | grep "T_REQUIRE_VM" | grep -qF "\"\$m\" != vm"' check "new: boot.autostart is stamped under the T_AUTOSTART guard" 0 "" bash -c ' awk "/^cmd_new\(\) \{/,/^\}/" "'"$ROOT"'/bin/box" \ | grep -F "boot.autostart=true" | grep -q "T_AUTOSTART"'