joeyagi/scripts/verify.sh
2026-10-05 18:50:09 -05:00

86 lines
2.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# verify.sh - JoeyAGI's gates, run one after another, with a summary.
#
# host the resource loader, PIC and VIEW decoders, the LOGIC VM and the
# VM pipeline, built for the host and run against every game in
# games/ (scripts/test-agi.sh)
# disk the bootable IIgs volume with games/kq3 on it boots on a CFFA2
# card, launches the interpreter and draws (make
# iigs-game-disk-agi, then JoeyLib's verify-iigs-game-disk.sh with
# the 8 MB the interpreter wants)
#
# Usage: scripts/verify.sh [gate...] every gate when none is named
# Env: JOEYLIB the JoeyLib checkout (default ../joeylib)
# The disk gate checks what is built: run make first (make check does both).
#
# Exit codes:
# 0 every gate passed
# 1 a gate failed
# 3 none failed, but one was skipped for a missing prerequisite (an
# emulator, the IIgs toolchain, no game in games/) -- not 0, so a run
# that tested nothing cannot look green
# A gate exits 2 to say it was skipped.
set -uo pipefail
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
JOEYLIB=$(cd "${JOEYLIB:-$repo/../joeylib}" && pwd) || { echo "verify: no JoeyLib checkout (set JOEYLIB)" >&2; exit 2; }
export JOEYLIB
diskGame=kq3
# name command...: every gate, in run order.
GATES=$(cat <<EOF
host scripts/test-agi.sh
disk [ -f games/$diskGame/LOGDIR ] || { echo "disk: no games/$diskGame to put on the volume" >&2; exit 2; }; make -s iigs-game-disk-agi AGI_GAME=$diskGame || exit 1; $JOEYLIB/scripts/verify-iigs-game-disk.sh build/iigs/bin/AGI.2mg 2 8M
EOF
)
names=$(echo "$GATES" | awk '{ print $1 }' | tr '\n' ' ')
for want in "$@"; do
case " $names " in
*" $want "*) ;;
*) echo "verify: unknown gate '$want' (choose from: $names)" >&2; exit 2 ;;
esac
done
selected=${*:-$names}
gateNames=()
gateVerdicts=()
gateSeconds=()
passed=0
failed=0
skipped=0
while read -r name cmd; do
case " $selected " in *" $name "*) ;; *) continue ;; esac
echo
echo "=== verify: $name ($cmd) ==="
start=$SECONDS
( cd "$repo" && bash -c "$cmd" ) < /dev/null
case $? in
0) verdict=PASS; passed=$((passed + 1)) ;;
2) verdict="SKIP (prerequisite missing)"; skipped=$((skipped + 1)) ;;
*) verdict=FAIL; failed=$((failed + 1)) ;;
esac
gateNames+=("$name")
gateVerdicts+=("$verdict")
gateSeconds+=("$((SECONDS - start))")
done <<< "$GATES"
echo
echo "================ verify summary ================"
for i in "${!gateNames[@]}"; do
printf " %-10s %-28s %4ds\n" "${gateNames[$i]}" "${gateVerdicts[$i]}" "${gateSeconds[$i]}"
done
echo " ----"
printf " %d passed, %d failed, %d skipped\n" "$passed" "$failed" "$skipped"
if [ "$failed" -gt 0 ]; then
echo "verify: FAIL" >&2
exit 1
fi
if [ "$skipped" -gt 0 ]; then
echo "verify: INCOMPLETE - some gates skipped (see above)" >&2
exit 3
fi
echo "verify: PASS (all $passed gates)"
exit 0