75 lines
2.5 KiB
Bash
Executable file
75 lines
2.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Behaviour gate for the Space Taxi simulation.
|
|
#
|
|
# Runs every hook level through stsim and compares the per-tick trace
|
|
# against a golden capture. A refactor that changes nothing observable
|
|
# leaves all seventeen traces byte-identical; anything else is a regression.
|
|
#
|
|
# H, W, T and X ride the C64's own attract recordings (the ones checked
|
|
# against VICE traces). The other thirteen ride synthesised fixtures from
|
|
# gateStreams.h -- a regression gate only, not evidence of C64 fidelity.
|
|
#
|
|
# gate.sh capture [dir] record goldens from the CURRENT tree
|
|
# gate.sh check [dir] compare the current tree against them
|
|
# gate.sh hashes print one md5 per level (compact reference)
|
|
#
|
|
# Capture from a tree you trust, refactor, then check.
|
|
set -u
|
|
|
|
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
repo=$(cd "$here/../.." && pwd)
|
|
levels=$repo/examples/spacetaxi/generated/iigs/levels
|
|
mode=${1:-check}
|
|
dir=${2:-$here/golden}
|
|
ticks=4000
|
|
|
|
# level letter -> level file number
|
|
pairs="H:08 T:20 W:23 X:24 G:07 I:09 K:11 O:15 Q:17 R:18 U:21 V:22 E:05 J:10 L:12 P:16 S:19"
|
|
|
|
make -C "$here" >/dev/null || { echo "gate: build failed" >&2; exit 2; }
|
|
|
|
case "$mode" in
|
|
capture)
|
|
mkdir -p "$dir"
|
|
for p in $pairs; do
|
|
l=${p%%:*}; n=${p##*:}
|
|
"$here/stsim" "$levels/level$n.dat" "$l" "$ticks" > "$dir/demo$l.jsonl" 2>/dev/null
|
|
printf ' %s: %s ticks\n' "$l" "$(wc -l < "$dir/demo$l.jsonl")"
|
|
done
|
|
echo "gate: captured to $dir"
|
|
;;
|
|
check)
|
|
fail=0
|
|
for p in $pairs; do
|
|
l=${p%%:*}; n=${p##*:}
|
|
got=$(mktemp)
|
|
"$here/stsim" "$levels/level$n.dat" "$l" "$ticks" > "$got" 2>/dev/null
|
|
if [ ! -f "$dir/demo$l.jsonl" ]; then
|
|
echo " $l: no golden (run: gate.sh capture)"
|
|
elif cmp -s "$dir/demo$l.jsonl" "$got"; then
|
|
printf ' %s: IDENTICAL (%s ticks)\n' "$l" "$(wc -l < "$got")"
|
|
else
|
|
echo " $l: *** DIFFERS ***"
|
|
diff "$dir/demo$l.jsonl" "$got" | head -3
|
|
fail=1
|
|
fi
|
|
rm -f "$got"
|
|
done
|
|
[ $fail -eq 0 ] && echo "gate: PASS" || echo "gate: FAIL"
|
|
# The cel census rides the same recordings: a cel a ride displays that
|
|
# its manifest does not bake is a mid-ride interpreted sprite.
|
|
"$here/celGate.sh" || fail=1
|
|
exit $fail
|
|
;;
|
|
hashes)
|
|
for p in $pairs; do
|
|
l=${p%%:*}; n=${p##*:}
|
|
h=$("$here/stsim" "$levels/level$n.dat" "$l" "$ticks" 2>/dev/null | md5sum | cut -d' ' -f1)
|
|
printf '%s %s\n' "$l" "$h"
|
|
done
|
|
;;
|
|
*)
|
|
sed -n '2,20p' "$0"
|
|
exit 2
|
|
;;
|
|
esac
|