#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 3: every stream of ay8910-python's validation (scripts/export_streams.py): the 24 # synthetic streams of its scripts/streams.py on all five parts, and its board streams # (Gimmick! and rainwarrior's 5B tests, when a local ay8910-python checkout has them) as the # 5B and as the AY-3-8910 at half the clock. Every clock's codes (hashed per 65,536-clock # take), every read and port change, and the final state must be identical. # To find where one differs, change its script's second line to "mode full" and run both sides # on it (lockstep_ref.py, the example). BIN / OURS / REUSE / ROUNDTRIP: as for rung 2. set -euo pipefail source "$(dirname "$0")/env.sh" DIR="$ROOT/external/streams" mkdir -p "$DIR/scripts" trace_binary if [ "${REUSE:-0}" != 1 ] || [ ! -f "$DIR/ref.done" ]; then "$PYTHON" -I "$ROOT/scripts/export_streams.py" "$REF" "$DIR/scripts" "$BOARD_STREAMS" fi reference_traces "$DIR" OURS=${OURS:-"$DIR/ours"} mkdir -p "$OURS" flag=(); [ "${ROUNDTRIP:-0}" = 1 ] && flag=(--roundtrip) ls -S "$DIR"/scripts/*.txt | nice xargs -P "$JOBS" -n 2 "$BIN" "${flag[@]}" --out-dir "$OURS" compare "$DIR" "$OURS" clocks=$(cat "$DIR"/ref/*.trace | awk '$1=="take"{n+=$2} END{print n+0}') boards=$(ls "$DIR"/scripts/board-*.txt 2>/dev/null | wc -l) synthetic=$((TOTAL - boards)) saves=$(cat "$DIR"/scripts/*.txt | grep -cE '^(state|take)$' || true) what="rung 3"; [ "${ROUNDTRIP:-0}" = 1 ] && what="rung 4 (rung 3's streams, $saves save-state round trips)" echo "$what: $SAME of $TOTAL stream runs identical ($synthetic synthetic: 24 streams x 5 parts; $boards board runs; $clocks input clocks' codes)" [ "$boards" = 0 ] && echo "$what: no board streams at $BOARD_STREAMS (AY8910_BOARD_STREAMS), synthetic only" [ $STATUS = 0 ] && echo "$what: PASS" || echo "$what: FAIL" exit $STATUS