#!/usr/bin/env bash # Boot -> title -> main menu -> NEW GAME -> DIFFICULTY -> SELECT DATA, and report # the crash count there. # # NEW GAME is the menu's FIRST item, so this presses (A) with no d-pad movement — # which is also what the run that first hit the SELECT DATA crash did, though it # thought it was choosing TUTORIAL (the d-pad steps had not registered). TUTORIAL # leads somewhere else entirely, to a lesson list, so it cannot test this crash. # # EXTRA_FLAGS is passed to the emulator, e.g. --eh_dispatch=true. set -u export HOME=/sylph-home/re SDL_AUDIODRIVER=dummy DISPLAY=:98 SD="$(cd "$(dirname "$0")" && pwd)" OUT="${1:-/sylph-home/re/newgame}" mkdir -p "$OUT" shot(){ screenshot "$1" >/dev/null 2>&1; } screen(){ shot /tmp/ng.png; python3 "$SD/screen_id.py" /tmp/ng.png | awk '{print $1}'; } crashes(){ grep -c "CRASH DUMP" "$OUT/canary.stdout" 2>/dev/null || echo 0; } alive(){ ps -o pid=,stat= -C xenia_canary 2>/dev/null | awk '$2 !~ /^Z/ {print $1}'; } for attempt in $(seq 1 "${ATTEMPTS:-3}"); do echo "=== attempt $attempt flags: ${EXTRA_FLAGS:-}" pkill -9 -x xenia_canary 2>/dev/null; sleep 3 ( cd "$OUT" && nohup run-canary --mem_watch=false ${EXTRA_FLAGS:-} \ --logged_profile_slot_0_xuid=B13EBABEBABEBABE >"$OUT/canary.stdout" 2>&1 & ) sleep 8 until xdotool search --name "Xenia-canary" >/dev/null 2>&1; do [ -n "$(alive)" ] || { echo "EMULATOR GONE"; exit 4; }; sleep 1 done s=""; deadline=$(( SECONDS + 420 )) while [ $SECONDS -lt $deadline ]; do s="$(screen)"; [ "$s" = "title" ] && break; sleep 2 done [ "$s" = "title" ] || { echo "NO TITLE this attempt"; continue; } echo "title -> A" python3 "$SD/pad.py" tap A 0.3 for _ in 1 2 3 4 5 6 7 8; do sleep 3; s="$(screen)"; [ "$s" = "menu" ] && break; done [ "$s" = "menu" ] || { echo "(A) not accepted; rebooting"; continue; } echo "menu -> A (NEW GAME, no d-pad)" python3 "$SD/pad.py" tap A 0.3; sleep 10; shot "$OUT/step1.png" echo " after NEW GAME: $(screen) crashes=$(crashes)" echo "difficulty -> A (NORMAL)" python3 "$SD/pad.py" tap A 0.3 for i in $(seq 1 12); do sleep 8; shot "$OUT/step2-$(printf '%02d' "$i").png" echo " t+$((i*8))s $(screen) crashes=$(crashes)" done echo "RESULT flags='${EXTRA_FLAGS:-}' crash_dumps=$(crashes) throws=$(grep -c 'Guest attempted to throw' "$OUT/canary.stdout" 2>/dev/null || echo 0)" exit 0 done echo "GAVE UP after ${ATTEMPTS:-3} boots"