#!/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 # # verify-win32-save.sh - Save gate for the Win32 port: a save outlives the # program, beside it. # # SAVE.EXE (examples/save) counts its launches in SAVES\RUNS.DAT. It is run # twice under Wine from a scratch folder, started from another directory so # the port's own move into the program's folder is what puts SAVES there; # after the second run the count must be 2. # # Usage: scripts/verify-win32-save.sh # Requires: Wine; build/win32/bin/SAVE.EXE (make win32). set -euo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) source "$repo/scripts/lib/joeyEnv.sh" source "$repo/scripts/lib/wineGate.sh" label=verify-win32-save wineNeed program=$(joeyExampleProgram save win32) [ -f "$program" ] || { echo "$label: build SAVE.EXE first (make win32)" >&2; exit 2; } runSeconds=6 work=$(mktemp -d -t "joeylib-win32-save.XXXXXX") cleanup() { wineStop rm -rf "$work" } trap cleanup EXIT mkdir -p "$work/program" "$work/elsewhere" cp "$program" "$work/program/SAVE.EXE" wineStart "$work" for run in 1 2; do # SAVE waits for ESC: each run is stopped once it has saved. (cd "$work/elsewhere" && wineRun "$work/program/SAVE.EXE" && sleep "$runSeconds" && joeyStop "$WINE_PID") "$(dirname "$WINE")/wineserver" -w 2> /dev/null || true done saved=$(find "$work/program" -maxdepth 2 -ipath "*/saves/runs.dat" -print -quit) [ -n "$saved" ] || { echo "$label: FAIL - no SAVES/runs.dat beside the program" >&2; exit 1; } count=$(joeyLe16 "$saved") if [ "$count" = 2 ]; then echo "$label: PASS (the second run counted 2, in SAVES beside the program)" else echo "$label: FAIL - the second run counted $count, not 2" >&2 exit 1 fi