#!/usr/bin/env bash # Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License. # See LICENSE.md for license information. # SPDX-License-Identifier: MIT # # Headless UBER run for the SDL3 port: no X server, no emulator. SDL's dummy # video driver gives the window and its dummy audio driver plays nothing at # the real rate, so UBER runs exactly as it does on a desktop, at the host's # speed. It waits for UBER's "press any key to exit" line in its joeylog.txt # (the program's folder, build/sdl3/bin) and stops it. # # The stage is the generic chunky one, so the hashes must equal the DOS # port's: # scripts/bench-sdl3.sh && tools/diff-uber-hashes tests/goldens/uber/dos.txt build/sdl3/bin/joeylog.txt # The ops/sec are this machine's, not a reference machine's: compare them # only run against run. # # scripts/bench-sdl3.sh # default 300 s timeout # TIMEOUT=600 scripts/bench-sdl3.sh # override set -euo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) source "$repo/scripts/lib/joeyEnv.sh" program=$(joeyExampleProgram uber sdl3) [ -x "$program" ] || { echo "bench-sdl3: build UBER first (make sdl3)" >&2; exit 2; } log=$(dirname "$program")/joeylog.txt timeoutSeconds=${TIMEOUT:-300} rm -f "$log" SDL_VIDEO_DRIVER=dummy SDL_AUDIO_DRIVER=dummy timeout -s KILL "$timeoutSeconds" "$program" > /dev/null 2>&1 & uberPid=$! trap 'joeyStop "$uberPid"' EXIT while joeyAlive "$uberPid"; do if grep -q "press any key to exit" "$log" 2>/dev/null; then echo "bench-sdl3: UBER finished; log in ${log#"$repo"/}" exit 0 fi sleep 1 done echo "bench-sdl3: FAIL - UBER ended (or timed out after ${timeoutSeconds} s) without finishing" >&2 exit 1