#!/usr/bin/env bash # verify-audio-all.sh - Run every port's audio gate and summarise. # # Driven by `make verify-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) # # SEQUENTIAL, deliberately. The two recording 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-audio-all.sh [port ...] # with no arguments, all five. Otherwise any of: # iigs x68000 atarist amiga dos # Env: AUDIO_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) label=verify-audio-all ALL_PORTS="iigs x68000 atarist amiga dos" 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 $1 in iigs) echo "scripts/verify-iigs-audio.sh staxi" ;; x68000) echo "scripts/verify-x68000-audio.sh" ;; atarist) echo "scripts/verify-atarist-audio.sh" ;; amiga) echo "scripts/verify-amiga-audio.sh" ;; dos) echo "scripts/verify-dos-audio.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 "${AUDIO_ALL_LOG:-}" ]; then ( cd "$repo" && $gate ) 2>&1 | tee -a "$AUDIO_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") audio gates)" exit 0