#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 1: sh2-python's corpus (validation/rung1: 16,600 generated cases, agreed by MAME # 0.285 and jgenesis or ruled from the manuals). Every case natively against # expected.txt.gz, per ruling class; then every case's result line and the CRC of its # bus cycles against the reference's (scripts/corpus_trace.py, cached). # BIN: another build's directory holding sh2-corpus (scripts/seeded_faults.py). set -euo pipefail source "$(dirname "$0")/env.sh" require_reference CACHE="$ROOT/external/reference-cache/${SH2_PYTHON_PIN:0:12}" mkdir -p "$CACHE" if [ -z "${BIN:-}" ]; then build; BIN="$ROOT/target/release"; fi V="$SH2_PYTHON/validation/rung1" [ -f "$CACHE/corpus.txt" ] || nice -n 19 "$REFERENCE_PYTHON" "$ROOT/scripts/corpus_trace.py" "$SH2_PYTHON" "$CACHE/corpus.txt" OUT=${OUT:-"$ROOT/external/ours/main"} mkdir -p "$OUT" status=0 "$BIN/sh2-corpus" "$V/cases.txt.gz" "$V/expected.txt.gz" --lockstep "$OUT/corpus.txt" || status=1 if cmp -s "$CACHE/corpus.txt" "$OUT/corpus.txt"; then echo "rung 1 lockstep: $(wc -l < "$CACHE/corpus.txt") cases, every result and bus CRC identical" else echo "rung 1 lockstep: DIFFERENT ($(diff "$CACHE/corpus.txt" "$OUT/corpus.txt" | grep -c '^<') cases)"; status=1 fi exit $status