#!/usr/bin/env bash # SPDX-License-Identifier: MIT # The gate: every rung of this transcription, in order (docs/status.md has the counts). # # scripts/ladder.sh # rungs 1-6 # scripts/ladder.sh --faults # and rung 7, the seeded faults (slow) # # Needs: ../6502-rust and ../a2600-python beside this repository (or # A2600_PYTHON_ROOT), the reference's references fetched there # (python scripts/fetch_references.py), external/venv (docs/status.md "Setup"), # NO_INTRO_DIR for the dumps. Everything runs under nice and timeout; at most # three processes at a time. set -euo pipefail cd "$(dirname "$0")/.." export A2600_PYTHON_ROOT="${A2600_PYTHON_ROOT:-$(cd .. && pwd)/a2600-python}" export MAME_HASHPATH="${MAME_HASHPATH:-$A2600_PYTHON_ROOT/reference/src/mame/hash}" export PYPY_GC_NURSERY="${PYPY_GC_NURSERY:-1M}" NICE="nice -n 19" step() { printf '\n== %s\n' "$*"; } step "1. build, format, lint, tests (the reference's behaviour tests, transcribed)" timeout 1800 $NICE cargo build --release -j 3 --bins # fmt and clippy from rustup's stable toolchain when there is one (CI's may be newer). STABLE=$(ls -d "$HOME"/.rustup/toolchains/stable-*/bin 2>/dev/null | head -1 || true) LINT_CARGO=cargo [ -n "$STABLE" ] && LINT_CARGO="env PATH=$STABLE:$PATH $STABLE/cargo" timeout 600 $LINT_CARGO fmt --check timeout 1800 $NICE $LINT_CARGO clippy --release -j 3 --all-targets --target-dir external/stable-target -- -D warnings timeout 3600 $NICE cargo test --release -j 3 -- --test-threads 3 step "2. the die traces, natively (39: tia-fpga's 22 and the reference's 17)" timeout 1800 $NICE target/release/a2600-gates die | tail -1 step "3. the reference's other judges, natively" timeout 1800 $NICE target/release/a2600-gates timers | tail -1 timeout 1800 $NICE target/release/a2600-gates timers --every-row | tail -1 for console in PAL_7800 PAL_JR_84 PAL_JR_91 PAL_L6 PAL_VADER SECAM_WOODY; do timeout 1800 $NICE target/release/a2600-gates serial "$console" | tail -1 done timeout 1800 $NICE target/release/a2600-gates hashes | tail -1 timeout 1800 $NICE target/release/a2600-gates hashes-rows | tail -1 step "4. per-slice lockstep against the reference (scripts/cases.tsv)" timeout 7200 python3 scripts/lockstep.py --reference-cache external/refcache --jobs 3 | tail -1 step "5. save states in the gate: save half way, load into a fresh console, go on" timeout 7200 python3 scripts/lockstep.py --reference-cache external/refcache --jobs 3 --save-at-half | tail -1 step "6. the window, headless (no human has looked at it)" timeout 1800 $NICE cargo build --release -j 3 --features frontend --bin a2600-play rom="$NO_INTRO_DIR/Atari - Atari 2600/Pitfall! - Pitfall Harry's Jungle Adventure (USA).zip" shot=external/window-shot.png SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy timeout 120 target/release/a2600-play "$rom" --frames 120 --scale 1 --screenshot "$shot" echo "window: $(stat -c %s "$shot") bytes of PNG after 120 frames ($shot)" if [ "${1:-}" = "--faults" ]; then step "7. seeded faults (each must be caught)" timeout 36000 python3 scripts/seeded_faults.py | tail -1 fi step "ladder passed"