#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 2: register-stream lockstep. Seeded random and scripted call sequences for the four # parts (scripts/lockstep_gen.py) run on both cores; the traces (every sample, every state # field after every operation, every write_test outcome) must be identical byte for byte. # Usage: scripts/rung2.sh [count per part, default 64] [seed, default 1] [steps, default 400] # BIN: another build of examples/sn76489-trace to judge (scripts/seeded_faults.py uses it); # REUSE=1 keeps the reference traces already in external/lockstep; OURS: where to write ours. set -euo pipefail source "$(dirname "$0")/env.sh" COUNT=${1:-64}; SEED=${2:-1}; STEPS=${3:-400} DIR="$ROOT/external/lockstep/seed$SEED-n$COUNT-s$STEPS" mkdir -p "$DIR/scripts" "$DIR/ref" if [ -z "${BIN:-}" ]; then (cd "$ROOT" && nice cargo build --release -q --example sn76489-trace) BIN="$ROOT/target/release/examples/sn76489-trace" fi if [ "${REUSE:-0}" != 1 ] || [ ! -f "$DIR/ref.done" ]; then python3 "$ROOT/scripts/lockstep_gen.py" "$DIR/scripts" --count "$COUNT" --seed "$SEED" --steps "$STEPS" >/dev/null ls "$DIR"/scripts/*.txt | nice xargs -P "$JOBS" -n 8 env PYTHONPATH="$REF/src" "$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 | nice xargs -P "$JOBS" -n 16 "$BIN" --out-dir "$OURS" "$ROOT/scripts/compare_traces.sh" "$DIR/ref" "$OURS" "rung 2"