#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 2: seeded lockstep. Random register, tick, pot, key, SID and BCLK streams, seeded # power-ons, snapshots restored mid-run, record=True and both variants, plus four directed # scripts (scripts/lockstep_gen.py), run on pokey-python (scripts/lockstep_ref.py, on the # reference's own venv) and on this crate (examples/pokey-trace.rs); every trace line (each # tick's pins, levels and mix() bits, each read, each wiring call, the full state) must be # identical byte for byte. # Usage: scripts/rung2.sh [count, default 64] [seed, default 1] [cycles per script, default 20000] # BIN: another build of examples/pokey-trace to judge (scripts/seeded_faults.py uses it); # REUSE=1 keeps the reference traces already written; OURS: where to write ours. set -euo pipefail source "$(dirname "$0")/env.sh" require_reference COUNT=${1:-64}; SEED=${2:-1}; CYCLES=${3:-20000} DIR="$ROOT/external/lockstep/seed$SEED-n$COUNT-c$CYCLES" mkdir -p "$DIR/scripts" "$DIR/ref" if [ -z "${BIN:-}" ]; then (cd "$ROOT" && nice -n 19 cargo build --release -q --example pokey-trace) BIN="$ROOT/target/release/examples/pokey-trace" fi if [ "${REUSE:-0}" != 1 ] || [ ! -f "$DIR/ref.done" ]; then python3 "$ROOT/scripts/lockstep_gen.py" "$DIR/scripts" --count "$COUNT" --seed "$SEED" --cycles "$CYCLES" >/dev/null ls "$DIR"/scripts/*.txt | timeout 3600 nice -n 19 xargs -P "$JOBS" -n 8 \ env PYTHONPATH="$POKEY_PYTHON/src" "$REFERENCE_PYTHON" "$ROOT/scripts/lockstep_ref.py" --out-dir "$DIR/ref" touch "$DIR/ref.done" fi OURS=${OURS:-"$DIR/ours"} mkdir -p "$OURS" ls "$DIR"/scripts/*.txt | timeout 1800 nice -n 19 xargs -P "$JOBS" -n 16 "$BIN" --out-dir "$OURS" "$ROOT/scripts/compare_traces.sh" "$DIR/ref" "$OURS" "rung 2"