#!/bin/bash # Launches every port in the ports folder from its games.dat, headless on a virtual screen and # the deterministic clock, for a while each, and counts the runs that printed no error # (FORGE.md section 14.8). Coverage, not a comparison: compare.sh is the comparison. # # testScripts/ports/launch.sh [] # # SINGE the engine binary (default: the newest build in .builddir) # SINGE_RUN a directory to run in (default: a fresh one under /tmp) # SECONDS_EACH how long each port runs (default: 25) # JOBS ports run at once (default: 2; four 1080p games on Xvfb ran a # 30 GB machine out of memory) set -u ports=${1:-$HOME/claude/singePorts} repo=$(cd "$(dirname "$0")/../.." && pwd) binary=${SINGE:-$(ls -t "$repo"/.builddir/linux-gcc/*/singe/Singe-v* "$repo"/.builddir/linux/x86_64/singe/Singe-v* 2>/dev/null | head -1)} run=${SINGE_RUN:-$(mktemp -d /tmp/forgePorts.XXXXXX)} each=${SECONDS_EACH:-25} jobs=${JOBS:-2} if [[ -z "$binary" || ! -x "$binary" ]]; then echo "launch.sh: no engine binary; set SINGE" >&2 exit 2 fi binary=$(realpath "$binary") # The runs change directory. # SDL's offscreen driver has a 1024x768 desktop, smaller than the KarisFramework games ask for. export SDL_VIDEODRIVER=x11 SDL_AUDIO_DRIVER=dummy one() { local script=$1 video=$2 local stem=$(basename "$script" .port.singe) local work=$run/$stem rm -rf "$work" mkdir -p "$work" ( cd "$run" && timeout -s INT "$each" xvfb-run -a -s "-screen 0 1920x1200x24" "$binary" -w -p -k --deterministic -d "$work" -v "$ports/$video" "$ports/$script" ) > "$work/run.log" 2>&1 local rc=$? # ffmpeg's hwaccel fallback notice and the X server going away under the timeout's INT are # the harness, not the game. local bad=$(grep -a "rror\|Author:\|raceback\|FAIL\|does not exist\|Unable to" "$work/run.log" | grep -vc "hwaccel\|XIO:") if [[ "$bad" = 0 && ( $rc = 124 || $rc = 0 ) ]]; then echo "$stem clean" else echo "$stem rc=$rc problems=$bad: $(grep -a "rror\|Author:\|raceback\|does not exist\|Unable to" "$work/run.log" | grep -v "hwaccel\|XIO:" | head -2 | tr '\n' ' ')" fi } export -f one export run each binary ports for dat in "$ports"/*/games.dat; do paste -d' ' <(grep -o 'SCRIPT *= *"[^"]*"' "$dat" | sed 's/.*"\(.*\)"/\1/') <(grep -o 'VIDEO *= *"[^"]*"' "$dat" | sed 's/.*"\(.*\)"/\1/') done | xargs -P "$jobs" -L 1 bash -c 'one $0 $1' | tee "$run/results.txt" echo "launch.sh: $(grep -c ' clean$' "$run/results.txt") of $(wc -l < "$run/results.txt") ports ran clean; logs under $run"