aien-protocols-mv
Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem
Brought by drakestapleton
aien-protocols-mv / specs / execution-transcript / tools / test-check-corpus.sh
| 1 | #!/bin/sh |
| 2 | # test-check-corpus.sh: prove check-corpus.sh ignores the crumb tool's files |
| 3 | # (.crumb, .crumb.local, exact names) and nothing else. |
| 4 | # Usage: test-check-corpus.sh [CC] Copies specs/execution-transcript to a temp dir. |
| 5 | set -eu |
| 6 | here=$(cd "$(dirname "$0")" && pwd) |
| 7 | CC=${1:-cc} |
| 8 | tmp=$(mktemp -d) |
| 9 | trap 'rm -rf "$tmp"' EXIT |
| 10 | fails=0 |
| 11 | |
| 12 | fresh() { rm -rf "$tmp/et"; cp -R "$here/.." "$tmp/et"; rm -f "$tmp/et/vectors/.crumb" "$tmp/et/vectors/.crumb.local"; } |
| 13 | runcheck() { sh -c 'bash "$1/tools/check-corpus.sh" "$2"' x "$tmp/et" "$CC" >"$tmp/out" 2>&1; } |
| 14 | expect() { # name, want (0|nz), then runcheck result |
| 15 | if runcheck; then got=0; else got=nz; fi |
| 16 | if [ "$got" = "$2" ]; then echo "ok $1"; else echo "FAIL $1 (exit $got, wanted $2)"; tail -n 5 "$tmp/out"; fails=$((fails+1)); fi |
| 17 | } |
| 18 | |
| 19 | fresh |
| 20 | expect baseline 0 |
| 21 | |
| 22 | # (a) kills: removing the -x .crumb exclusion (check would exit 1 as STALE). |
| 23 | fresh; printf 'crumb\n' >"$tmp/et/vectors/.crumb" |
| 24 | expect crumb-ignored 0 |
| 25 | # (a2) kills: dropping only the .crumb.local exclusion. |
| 26 | fresh; printf 'local\n' >"$tmp/et/vectors/.crumb.local" |
| 27 | expect crumb-local-ignored 0 |
| 28 | |
| 29 | # (b) kills: widening the exclusion to a glob such as -x '.crumb*' or '*'. |
| 30 | fresh; printf 'x\n' >"$tmp/et/vectors/.crumbx" |
| 31 | expect near-name-still-fails nz |
| 32 | fresh; printf 'x\n' >"$tmp/et/vectors/stray.txt" |
| 33 | expect unknown-file-still-fails nz |
| 34 | |
| 35 | # (c) kills: neutering the vector comparison (e.g. ignoring everything). |
| 36 | fresh |
| 37 | f="$tmp/et/vectors/f001.trn" |
| 38 | b=$(od -An -N1 -tu1 "$f" | tr -d ' ') |
| 39 | printf "\\$(printf '%03o' $((b ^ 1)))" | dd of="$f" bs=1 seek=0 count=1 conv=notrunc 2>/dev/null |
| 40 | expect mutated-golden-still-fails nz |
| 41 | |
| 42 | [ "$fails" -eq 0 ] && echo "TEST_CHECK_CORPUS pass" || { echo "TEST_CHECK_CORPUS fail=$fails"; exit 1; } |