#!/usr/bin/env bash set -euo pipefail usage() { cat <<'USAGE' Usage: tests/smoke_appimage.sh PATH_TO_APPIMAGE [SECONDS] Runs an Avida-ED AppImage long enough to verify wrapper startup, embedded HTTP serving, WebView page load, and absence of proxied JavaScript errors. The app normally keeps running until its window closes, so timeout exit code 124 is accepted after the expected load signals appear. USAGE } if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then usage exit 0 fi appimage="${1:?missing AppImage path}" seconds="${2:-20}" if [[ ! -x "$appimage" ]]; then echo "error: AppImage is missing or not executable: $appimage" >&2 exit 2 fi tmpdir="$(mktemp -d)" logfile="$tmpdir/appimage.log" cleanup() { rm -rf "$tmpdir" } trap cleanup EXIT cmd=( env LIBGL_ALWAYS_SOFTWARE="${LIBGL_ALWAYS_SOFTWARE:-1}" WEBKIT_DISABLE_COMPOSITING_MODE="${WEBKIT_DISABLE_COMPOSITING_MODE:-1}" "$appimage" ) if [[ -z "${DISPLAY:-}" ]] && command -v xvfb-run >/dev/null 2>&1; then cmd=(xvfb-run -a "${cmd[@]}") fi set +e timeout "$seconds" "${cmd[@]}" >"$logfile" 2>&1 status=$? set -e cat "$logfile" if [[ "$status" -ne 0 && "$status" -ne 124 ]]; then echo "error: AppImage exited before smoke window completed; status=$status" >&2 exit "$status" fi if ! grep -q "Avida-ED loading http://127.0.0.1:" "$logfile"; then echo "error: wrapper did not log local HTTP load URL" >&2 exit 1 fi if ! grep -q "Avida-ED HTTP 200" "$logfile"; then echo "error: embedded HTTP server did not serve any successful response" >&2 exit 1 fi if ! grep -q "Avida-ED page-load finished" "$logfile"; then echo "error: WebView did not finish loading the app page" >&2 exit 1 fi if grep -E "Avida-ED WebView (js-error|js-rejection|console-error):" "$logfile"; then echo "error: WebView reported JavaScript errors" >&2 exit 1 fi echo "AppImage smoke passed: $appimage"