85 lines
2.9 KiB
Bash
Executable file
85 lines
2.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Headless UBER run for DVX (DOSBox Staging, DVX's own emulator setup).
|
|
#
|
|
# Stages a scratch DVX (scripts/lib/dvxGate.sh) whose desktop is UBER, boots
|
|
# it in DOSBox Staging under Xvfb, and waits for UBER's "press any key to
|
|
# exit" line in its joeylog.txt -- which a DVX program writes to its settings
|
|
# folder, CONFIG\APPS\JOEYLIB\UBER on the staged drive. The log is copied to
|
|
# build/dvx/bin/joeylog.txt (tools/diff-uber-hashes and tools/uber-perf-table
|
|
# read it from there) and DOSBox is stopped.
|
|
#
|
|
# The stage is the DOS stage, so the hashes must equal the DOS port's:
|
|
# scripts/bench-dvx.sh && tools/diff-uber-hashes tests/goldens/uber/dos.txt build/dvx/bin/joeylog.txt
|
|
# The ops/sec are the emulated machine's at DOSBox's full host speed, not a
|
|
# reference machine's: compare them only run against run.
|
|
#
|
|
# scripts/bench-dvx.sh # default 600 s timeout
|
|
# TIMEOUT=900 scripts/bench-dvx.sh # override
|
|
|
|
set -euo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
source "$repo/scripts/lib/joeyEnv.sh"
|
|
source "$repo/scripts/lib/dvxGate.sh"
|
|
joeyNeed DOSBOX dosbox
|
|
joeyNeed DVX_ROOT dvx
|
|
|
|
timeoutSeconds=${TIMEOUT:-600}
|
|
# The emulator's hard cap, a little past the wait, whatever this script does.
|
|
wallSeconds=$((timeoutSeconds + 30))
|
|
out=$DVX_BIN/$DVX_LOG_NAME
|
|
doneLine="press any key to exit"
|
|
|
|
dvxNeedBuild uber
|
|
|
|
work=$(mktemp -d -t joeylib-bench-dvx.XXXXXX)
|
|
guard=""
|
|
dosbox=""
|
|
xvfb=""
|
|
# 2>/dev/null: bash reports the SIGKILLed timeout wrapper as "Killed".
|
|
cleanup() {
|
|
joeyStop "$dosbox" "$guard" "$xvfb" 2> /dev/null
|
|
rm -rf "$work"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
dvxStage "$work/c" "$(dvxAppDir uber)"
|
|
dvxDosboxConf "$work/dosbox.conf" "$work/c"
|
|
mkdir -p "$work/xdg"
|
|
rm -f "$out"
|
|
|
|
display=":$((RANDOM % 400 + 1700))"
|
|
Xvfb "$display" -screen 0 1024x768x24 -nolisten tcp > /dev/null 2>&1 &
|
|
xvfb=$!
|
|
sleep 1
|
|
|
|
echo "bench-dvx: running UBER in DVX headless (timeout ${timeoutSeconds}s)..." >&2
|
|
XDG_CONFIG_HOME="$work/xdg" DISPLAY="$display" SDL_AUDIODRIVER=dummy \
|
|
timeout -s KILL "$wallSeconds" "$DOSBOX" "${JOEY_DOSBOX_ISOLATE[@]}" \
|
|
--conf "$work/dosbox.conf" > "$work/dosbox.log" 2>&1 &
|
|
guard=$!
|
|
dosbox=$(joeyChild "$guard" || true)
|
|
|
|
start=$SECONDS
|
|
log=$(dvxAwaitLog "$work/c" uber "$doneLine" "$timeoutSeconds" "$guard" || true)
|
|
waited=$((SECONDS - start))
|
|
if [ -z "$log" ]; then
|
|
log=$(dvxProgramLog "$work/c" uber)
|
|
fi
|
|
if [ -z "$log" ]; then
|
|
echo "bench-dvx: FAIL -- UBER wrote no joeylog.txt (DVX.LOG follows)" >&2
|
|
dvxDvxLog "$work/c" >&2
|
|
exit 1
|
|
fi
|
|
tr -d '\r' < "$log" > "$out"
|
|
joeyStop "$dosbox" "$guard" 2> /dev/null
|
|
dosbox=""
|
|
guard=""
|
|
|
|
ops=$(grep -c "ops/sec" "$out" || true)
|
|
if ! grep -q "$doneLine" "$out"; then
|
|
echo "bench-dvx: WARNING -- timed out before the completion line (partial capture)" >&2
|
|
fi
|
|
echo "bench-dvx: captured $ops op lines in ${waited}s" >&2
|
|
echo " -> $out" >&2
|
|
grep "UBER:" "$out" | sed 's/ | hash=.*//' || true
|