#!/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-amiga-icon.sh - a program's Workbench icon: read and drawn by the # Amiga's own icon.library, and the program started from it. # # make bakes Name.info beside every Amiga program (tools/iconBake info: # a tool's icon in Workbench's four colors, with the stack it starts # with). WBLAUNCH (examples/wblaunch) runs under FS-UAE on an A500 with # PALPROBE and its icon in a folder of their own, Prog/. It reads the icon # with GetDiskObject -- it must be a tool's, of AMIGA_ICON_STACK bytes of # stack and the baked size -- and draws it; the screenshot must show every # pixel of the icon the file holds, in Workbench's colors. Then it starts # PALPROBE as Workbench starts a tool, from RAM:, and its message must come # back with PALPROBE's log, which opens in the current directory, in Prog/: # libnix's start-up moves into the folder Workbench names. # # Usage: scripts/verify-amiga-icon.sh # Env: TIMEOUT seconds to wait for each step (default 120) # AMIGA_ICON_KEEP keep the screenshot as build/amiga/amiga-icon.png # Exit: 0 PASS, 1 FAIL, 2 SKIP (FS-UAE or the Kickstart not installed) set -uo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) source "$repo/scripts/lib/joeyEnv.sh" joeyNeed FSUAE fsuae source "$repo/scripts/lib/amigaGate.sh" amigaMachine timeout_s=${TIMEOUT:-120} test_dir=$repo/build/amiga/test label=verify-amiga-icon # make/amiga.mk's AMIGA_ICON_STACK, and WBTOOL (workbench/workbench.h). want_stack=$(make -s -f "$repo/make/amiga.mk" --eval 'printStack: ; @echo $(AMIGA_ICON_STACK)' printStack) WBTOOL=3 make -s -f "$repo/make/amiga.mk" "$test_dir/Wblaunch" "$test_dir/Palprobe" "$test_dir/Palprobe.info" || { echo "$label: FAIL - building Wblaunch, Palprobe or its icon failed" >&2 exit 1 } work=$(mktemp -d -t joeylib-amiga-icon.XXXXXX) mkdir -p "$work/s" "$work/Prog" cp "$test_dir/Wblaunch" "$work/" cp "$test_dir/Palprobe" "$test_dir/Palprobe.info" "$work/Prog/" printf 'stack 32768\nWblaunch Prog Palprobe\n' > "$work/s/startup-sequence" display=:$((RANDOM % 400 + 1300)) Xvfb "$display" -screen 0 800x600x24 -nolisten tcp > /dev/null 2>&1 & xvfb_pid=$! fs_pid= cleanup() { [[ -n $fs_pid ]] && joeyStop "$fs_pid" kill "$xvfb_pid" 2>/dev/null || true wait 2>/dev/null || true rm -rf "$work" } trap cleanup EXIT sleep 0.5 DISPLAY=$display "$FSUAE" "${AMIGA_MACHINE_ARGS[@]}" --fast_memory=2048 \ --hard_drive_0="$work" --hard_drive_0_label=JOEYLIB \ --automatic_input_grab=0 \ --fullscreen=0 --fade_out_duration=0 > "$work/fsuae.log" 2>&1 & fs_pid=$! log=$work/wblaunch.txt # waitFor TEXT: true once the probe's log holds TEXT, or holds a FAIL. waitFor() { local waited for ((waited = 0; waited < timeout_s; waited++)); do if grep -q "$1\|WBLAUNCH: FAIL" "$log" 2>/dev/null; then return 0 fi sleep 1 done return 1 } if ! waitFor "WBLAUNCH: drawn"; then echo "$label: FAIL - the probe never drew the icon within ${timeout_s}s" >&2 exit 1 fi # A second into the probe's five-second hold. sleep 1 DISPLAY=$display import -window root "$work/screen.png" [[ -n ${AMIGA_ICON_KEEP:-} ]] && cp "$work/screen.png" "$repo/build/amiga/amiga-icon.png" if ! waitFor "WBLAUNCH: returned"; then echo "$label: FAIL - Palprobe's Workbench message never came back within ${timeout_s}s" >&2 exit 1 fi cat "$log" "$(joeyTool amigaCheck)" icon "$work" "$want_stack" "$WBTOOL" "$label"