#!/usr/bin/env bash # The fork's gate: every change must leave this board identical to gameboy-rust, which is # identical to gameboy-python at gameboy-rust-pin-2 (47a97e6). Run on every kept commit. # # scripts/ladder.sh # JOBS=10 by default # # 1. cargo test # 2. every lockstep table against the reference's traces (external/refcache, frozen copy of # gameboy-rust's at pin-2), plain and with --save-at-half (rung 7 with --audio) # 3. the Gambatte pass lists exactly (DMG-08 skip-boot, CGB-04c on cgb-c skip-boot) # 4. Mealybug DMG 24/24, CGB-D 20/21, CGB C 25/28 with cgb-acid-hell; the DMG/CGB pictures # Exit status 1 at the first step that is not identical. set -uo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) cd "$ROOT" export PYPY_GC_NURSERY=1M JOBS=${JOBS:-10} REF=external/gameboy-python/tests OUT=external/ladder mkdir -p "$OUT" fail() { echo "LADDER FAILED: $*"; exit 1; } cargo build --release -q || fail "build" tests=$(cargo test --release -q 2>&1) echo "$tests" | grep -qE "FAILED|panicked|error" && fail "cargo test" echo "cargo test: $(echo "$tests" | grep -oE '[0-9]+ passed' | awk '{n+=$1} END{print n}') pass" C="--reference-cache external/refcache --jobs $JOBS" for table in cases cases-rung3 cases-rung5 cases-rung6 cases-oamdma-cgb; do for mode in "" "--save-at-half"; do line=$(nice python3 scripts/lockstep.py $C --cases scripts/$table.tsv $mode | tail -1) echo "$table ${mode:-plain}: $line" [[ $line =~ ^([0-9]+)\ of\ ([0-9]+)\ cases\ identical$ && ${BASH_REMATCH[1]} == "${BASH_REMATCH[2]}" ]] \ || fail "$table $mode" done done for mode in "" "--save-at-half"; do line=$(nice python3 scripts/lockstep.py $C --cases scripts/cases-rung7.tsv --extra=--audio $mode | tail -1) echo "cases-rung7 --audio ${mode:-plain}: $line" [[ $line =~ ^([0-9]+)\ of\ ([0-9]+)\ cases\ identical$ && ${BASH_REMATCH[1]} == "${BASH_REMATCH[2]}" ]] \ || fail "cases-rung7 $mode" done S=target/release/gameboy-suite nice $S gambatte --skip-boot --jobs "$JOBS" --write $OUT/dmg.txt | tail -1 cmp -s <(sort $OUT/dmg.txt) <(sort $REF/gambatte_dmg08_pass.txt) || fail "Gambatte DMG-08 list" nice $S gambatte --cgb --machine cgb-c --skip-boot --jobs "$JOBS" --write $OUT/cgbc.txt | tail -1 cmp -s <(sort $OUT/cgbc.txt) <(sort $REF/gambatte_cgb04c_pass.txt) || fail "Gambatte CGB-04c list" echo "Gambatte: both pass lists exact" line=$(nice $S mealybug-dmg --jobs "$JOBS" | tail -1); echo "Mealybug DMG: $line" [[ $line == "24 of 24 pixel-exact, 0 pixels differ" ]] || fail "Mealybug DMG" line=$(nice $S cgb-pictures --jobs "$JOBS" | tail -1); echo "CGB-D pictures: $line" [[ $line == "20 of 21 pixel-exact" ]] || fail "CGB-D pictures" line=$(nice $S cgb-pictures --revision cgb_c --jobs "$JOBS" | tail -1); echo "CGB C pictures: $line" [[ $line == "25 of 28 pixel-exact" ]] || fail "CGB C pictures" pics=$(nice $S pictures) echo "$pics" | grep -qv ": 0 pixels differ" && fail "pictures: $pics" echo "pictures: all exact" echo "LADDER PASSES"