#!/usr/bin/env bash # verify-all.sh - Run one kind of gate on every port and summarise. # # Driven by `make verify-audio` and `make verify-serial`. # # audio: five gates, two kinds: # iigs DOC wavetable + sound IRQ vector (register tap) # x68000 YM2151 noise + PPI port C + ADPCM rate (register tap) # atarist YM2149 write trace, with the pc (register tap) # amiga recorded sound, four loudness phases (Paula has no tap) # dos recorded sound, four loudness phases (SB has no tap) # # serial: the host check of the shared layer, then each port's loopback # (banner out, probe echoed back): # host scripts/check-serial.sh (no emulator) # iigs SCC modem port -> MAME null_modem # x68000 SCC channel A -> MAME null_modem # atarist Modem port -> Hatari pty # amiga serial.device -> FS-UAE TCP # dos COM1 -> DOSBox nullmodem # # SEQUENTIAL, deliberately. The two recording audio gates drive the emulator on # wall-clock sleeps and grade fixed time windows of the capture, so a # second emulator competing for CPU can slide a phase boundary and fail a # gate that is actually fine. Running five emulators at once also makes # the timing-sensitive register gates noisier. The whole set is ~2.5 # minutes; parallelism is not worth the flakiness. # # Exit codes, distinguishing "it works" from "it did not run": # 0 every selected gate PASSED # 1 at least one gate FAILED (a real defect) # 3 no failures, but at least one gate SKIPPED for a missing # prerequisite -- an unbuilt port or absent emulator. Non-zero on # purpose: a run that quietly tested nothing must not look green. # # Each gate already reports its own evidence line; this only adds the # roll-up. Gate stdout/stderr is echoed as it happens, so a failure shows # its diagnosis here and not just a verdict. # # Usage: scripts/verify-all.sh audio|serial [port ...] # with no ports, all of that kind's. Otherwise any of: # iigs x68000 atarist amiga dos (and host, for serial) # Env: VERIFY_ALL_LOG also append the full transcript to this file # Requires: whatever each selected gate requires; missing ones SKIP. set -uo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) kind=${1:-} shift || true label="verify-all $kind" case $kind in audio) ALL_PORTS="iigs x68000 atarist amiga dos" ;; serial) ALL_PORTS="host iigs x68000 atarist amiga dos" ;; *) echo "usage: scripts/verify-all.sh audio|serial [port ...]" >&2; exit 2 ;; esac ports=${*:-$ALL_PORTS} for p in $ports; do case " $ALL_PORTS " in *" $p "*) ;; *) echo "$label: unknown port '$p' (choose from: $ALL_PORTS)" >&2; exit 2 ;; esac done gateFor() { # $1 = port -> script + args case $kind:$1 in audio:iigs) echo "scripts/verify-iigs-audio.sh staxi" ;; audio:*) echo "scripts/verify-$1-audio.sh" ;; serial:host) echo "scripts/check-serial.sh" ;; serial:*) echo "scripts/verify-$1-serial.sh" ;; esac } passed="" failed="" skipped="" declare -A elapsed for port in $ports; do gate=$(gateFor "$port") echo echo "=== $label: $port ($gate) ===" start=$SECONDS if [ -n "${VERIFY_ALL_LOG:-}" ]; then ( cd "$repo" && $gate ) 2>&1 | tee -a "$VERIFY_ALL_LOG" rc=${PIPESTATUS[0]} else ( cd "$repo" && $gate ) rc=$? fi elapsed[$port]=$((SECONDS - start)) case $rc in 0) passed="$passed $port" ;; 2) skipped="$skipped $port" ;; *) failed="$failed $port" ;; esac done count() { set -- $1; echo $#; } echo echo "================ $label summary ================" for port in $ports; do case " $passed " in *" $port "*) verdict=PASS ;; *) case " $skipped " in *" $port "*) verdict="SKIP (prerequisite missing)" ;; *) verdict=FAIL ;; esac ;; esac printf " %-8s %-28s %3ds\n" "$port" "$verdict" "${elapsed[$port]}" done echo " ----" printf " %d passed, %d failed, %d skipped\n" \ "$(count "$passed")" "$(count "$failed")" "$(count "$skipped")" if [ -n "$failed" ]; then echo "$label: FAIL -$failed" >&2 exit 1 fi if [ -n "$skipped" ]; then echo "$label: INCOMPLETE - skipped$skipped (build those ports, then re-run)" >&2 exit 3 fi echo "$label: PASS (all $(count "$passed") $kind gates)" exit 0