interplane.Get Omega
Read in your language

aien-protocols-mv

Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem

Brought by drakestapleton

branch main Branches Tags History

aien-protocols-mv / specs / execution-transcript / tools / test-check-corpus.sh

42 lines · 1733 bytes Raw Blame History
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.
5set -eu
6here=$(cd "$(dirname "$0")" && pwd)
7CC=${1:-cc}
8tmp=$(mktemp -d)
9trap 'rm -rf "$tmp"' EXIT
10fails=0
11
12fresh() { rm -rf "$tmp/et"; cp -R "$here/.." "$tmp/et"; rm -f "$tmp/et/vectors/.crumb" "$tmp/et/vectors/.crumb.local"; }
13runcheck() { sh -c 'bash "$1/tools/check-corpus.sh" "$2"' x "$tmp/et" "$CC" >"$tmp/out" 2>&1; }
14expect() { # 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
19fresh
20expect baseline 0
21
22# (a) kills: removing the -x .crumb exclusion (check would exit 1 as STALE).
23fresh; printf 'crumb\n' >"$tmp/et/vectors/.crumb"
24expect crumb-ignored 0
25# (a2) kills: dropping only the .crumb.local exclusion.
26fresh; printf 'local\n' >"$tmp/et/vectors/.crumb.local"
27expect crumb-local-ignored 0
28
29# (b) kills: widening the exclusion to a glob such as -x '.crumb*' or '*'.
30fresh; printf 'x\n' >"$tmp/et/vectors/.crumbx"
31expect near-name-still-fails nz
32fresh; printf 'x\n' >"$tmp/et/vectors/stray.txt"
33expect unknown-file-still-fails nz
34
35# (c) kills: neutering the vector comparison (e.g. ignoring everything).
36fresh
37f="$tmp/et/vectors/f001.trn"
38b=$(od -An -N1 -tu1 "$f" | tr -d ' ')
39printf "\\$(printf '%03o' $((b ^ 1)))" | dd of="$f" bs=1 seek=0 count=1 conv=notrunc 2>/dev/null
40expect mutated-golden-still-fails nz
41
42[ "$fails" -eq 0 ] && echo "TEST_CHECK_CORPUS pass" || { echo "TEST_CHECK_CORPUS fail=$fails"; exit 1; }