#!/bin/bash # SPDX-License-Identifier: MIT # The board's whole gate (docs/status.md): pytest and ruff, the 32X runs (testpico cold # and warm, the Mars Check Program's automatic run, the PWM demo, NFL Quarterback Club), # and the passive gate (megadrive-python's VDPFIFOTesting, one MAME lockstep replay and the # mini sweep with a passive 32X in the slot, and the mini sweep without it, both on the # same megadrive-python). Everything runs in parallel under nice; it takes about two hours. # # OUT=reference/gate/NAME PY=.venv-pypy/bin/python MEGADRIVE_CHECKOUT=DIR scripts/gate.sh # # Found through the environment, never a machine path here: # SEGA32X_BIOS_DIR the user's 32X_G/M/S_BIOS.BIN (checked by SHA-1) # NO_INTRO_DIR the No-Intro set: "Sega - 32X" for the cartridges, and megadrive-python's # sweep reads "Sega - Mega Drive - Genesis" through it # MEGADRIVE_CHECKOUT a megadrive-python tree at the installed pin, with tests/test_roms and # tests/compat/mame-cache filled (its scripts and data; the package is # the one PY has installed) # MD_TRACES MAME traces (default $MEGADRIVE_CHECKOUT/tests/mame_traces) # PY the interpreter (default .venv-pypy/bin/python); W the board's tree # (default this repository); JOBS the sweeps' workers (default 4 each) # SKIP_PASSIVE=1 the 32X runs and pytest only # testpico is built into reference/build by scripts/build_referees.py. set -u ROOT=$(cd "$(dirname "$0")/.." && pwd) W=${W:-$ROOT} PY=${PY:-$ROOT/.venv-pypy/bin/python} OUT=${OUT:?OUT: where the gate writes} : "${SEGA32X_BIOS_DIR:?the user\'s 32X boot ROMs}" "${NO_INTRO_DIR:?the No-Intro set}" CARTS="$NO_INTRO_DIR/Sega - 32X" JOBS=${JOBS:-4} export PYPY_GC_NURSERY=1M PYTHONPATH="$W/src" mkdir -p "$OUT"; OUT=$(cd "$OUT" && pwd) git -C "$W" rev-parse --short HEAD > "$OUT/at.txt" "$PY" -c 'import importlib.metadata as m for p in ("megadrive-python", "sh2-python", "m68000-python", "z80-python", "ym2612-python", "sn76489-python"): d = m.distribution(p); u = d.read_text("direct_url.json") or ""; print(p, u)' > "$OUT/pins.txt" uptime > "$OUT/load-start.txt" run() { name=$1; shift; ( s=$(date +%s); nice "$@" > "$OUT/$name.log" 2>&1; echo "EXIT $? $(( $(date +%s) - s )) s" >> "$OUT/$name.log" ) & } ( cd "$W" && nice "$PY" -m pytest -q -p no:cacheprovider > "$OUT/pytest.log" 2>&1; echo "EXIT $?" >> "$OUT/pytest.log" nice "$PY" -m pytest -q -p no:cacheprovider -m slow > "$OUT/pytest-slow.log" 2>&1; echo "EXIT $?" >> "$OUT/pytest-slow.log" "$PY" -m ruff check src scripts tests > "$OUT/ruff.log" 2>&1; "$PY" -m ruff format --check src scripts tests >> "$OUT/ruff.log" 2>&1; echo "EXIT $?" >> "$OUT/ruff.log" ) & R32="$W/scripts/run_32x.py"; B=$SEGA32X_BIOS_DIR run testpico "$PY" "$R32" "$ROOT/reference/build/testpico/hardware/testpico-30a5783.bin" --bios-dir "$B" --frames 260 --out "$OUT/testpico" --save-32x 110,260 --press-reset-at 115 --report-every 10 # The Program dump (sha1 7654c6d3...): run untouched it goes through its tests by itself, # a verdict per test; the "(Auto Demo)" dump is another program. run mars-auto "$PY" "$R32" "$CARTS/Mars Check Program (USA) (Program).zip" --bios-dir "$B" --frames 760 --out "$OUT/mars-auto" --on-change 42,194,108,212 --png-every 250 --report-every 50 run pwm-demo "$PY" "$R32" "$CARTS/32X Sample Program - PWM Sound Demo (USA) (Demo).zip" --bios-dir "$B" --frames 480 --out "$OUT/pwm-demo" --no-fm --wav "$OUT/pwm-demo.wav" --png-every 120 --report-every 60 run nfl "$PY" "$R32" "$CARTS/NFL Quarterback Club (World).zip" --bios-dir "$B" --frames 900 --out "$OUT/nfl" --press 300:start --press 600:start --png-every 50 --report-every 100 if [ -z "${SKIP_PASSIVE:-}" ]; then MD=${MEGADRIVE_CHECKOUT:?MEGADRIVE_CHECKOUT: a megadrive-python tree at the pin} TR=${MD_TRACES:-$MD/tests/mame_traces} H=("$PY" -m sega32x_python.harness --megadrive "$MD") run lockstep-castlevania "${H[@]}" scripts/lockstep_mame.py "$TR/genesis-castlevania" run vdpfifo-genesis "${H[@]}" scripts/run_vdpfifotesting.py --machine genesis --verbose run vdpfifo-genesis-without "${H[@]}" --without scripts/run_vdpfifotesting.py --machine genesis --verbose run sweep-without "${H[@]}" --without scripts/compat_sweep.py --list "$MD/tests/mini_sweep.txt" --window 12 --jobs "$JOBS" --out "$OUT/mini-without.csv" run sweep-with "${H[@]}" scripts/compat_sweep.py --list "$MD/tests/mini_sweep.txt" --window 12 --jobs "$JOBS" --out "$OUT/mini-with.csv" fi wait if [ -z "${SKIP_PASSIVE:-}" ]; then # The passive 32X against no 32X on the same megadrive-python: every row the same. "$PY" - "$OUT/mini-without.csv" "$OUT/mini-with.csv" > "$OUT/passive-diff.txt" <<'EOF' import csv, sys rows = [{r["name"]: (r["status"], r["differ"], r["offset"]) for r in csv.DictReader(open(p))} for p in sys.argv[1:]] moved = [n for n in rows[0] if rows[0][n] != rows[1].get(n)] print(f"{len(rows[0])} rows without, {len(rows[1])} with, {len(moved)} moved") for n in moved: print(n, rows[0][n], rows[1].get(n)) EOF fi uptime > "$OUT/load-end.txt"; echo ALLDONE > "$OUT/done.txt"