joeylib2/scripts/bench-win16.sh
2026-10-13 14:01:46 -05:00

53 lines
1.8 KiB
Bash
Executable file

#!/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 Win16 port: UBER.EXE on Windows for Workgroups
# 3.11 under DOSBox (scripts/lib/win16Gate.sh), its folder build/win16/bin
# as drive D:, until UBER's JOEYLOG.TXT there says "press any key to exit".
#
# The stage is the generic chunky one, so the hashes must equal the DOS
# port's:
# scripts/bench-win16.sh && tools/diff-uber-hashes tests/goldens/uber/dos.txt build/win16/bin/JOEYLOG.TXT
# The ops/sec are this machine's with DOSBox at full speed: compare them
# only run against run.
#
# scripts/bench-win16.sh # default 300 s timeout
# TIMEOUT=600 scripts/bench-win16.sh # override
set -euo pipefail
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
source "$repo/scripts/lib/joeyEnv.sh"
source "$repo/scripts/lib/win16Gate.sh"
label=bench-win16
win16Need
program=$(joeyExampleProgram uber win16)
[ -f "$program" ] || { echo "$label: build UBER first (make win16)" >&2; exit 2; }
folder=$(dirname "$program")
timeoutSeconds=${TIMEOUT:-300}
work=$(mktemp -d -t joeylib-win16-bench.XXXXXX)
cleanup() {
win16Stop
rm -rf "$work"
}
trap cleanup EXIT
rm -f "$folder/JOEYLOG.TXT" "$folder/joeylog.txt"
win16Stage "$work" "$folder" "$(basename "$program")"
win16Start "$work"
for ((waited = 0; waited < timeoutSeconds; waited++)); do
log=$(win16Log "$folder")
if [ -n "$log" ] && grep -q "press any key to exit" "$log"; then
echo "$label: UBER finished in about ${waited} s; log in ${log#"$repo"/}"
exit 0
fi
joeyAlive "$WIN16_GUARD" || break
sleep 1
done
echo "$label: FAIL - UBER did not finish within ${timeoutSeconds} s" >&2
tail -5 "$work/dosbox.log" >&2
exit 1