1
0
Files
kobopatch-webui/kobopatch-wasm/test-integration.sh
Nico Verbruggen f5fa27e00f
All checks were successful
Build and test project / build-and-test (push) Successful in 1m35s
Set up test flow on my Mac
2026-03-21 13:53:34 +01:00

55 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Integration test: downloads firmware and runs the full patching pipeline
# with SHA1 checksum validation.
#
# Usage: ./test-integration.sh
#
# The firmware zip (~150MB) is cached in testdata/ to avoid re-downloading.
FIRMWARE_VERSION="4.45.23646"
FIRMWARE_URL="https://ereaderfiles.kobo.com/firmwares/kobo13/Mar2026/kobo-update-${FIRMWARE_VERSION}.zip"
FIRMWARE_DIR="testdata"
FIRMWARE_FILE="${FIRMWARE_DIR}/kobo-update-${FIRMWARE_VERSION}.zip"
cd "$(dirname "$0")"
# Use local Go if available
LOCAL_GO_DIR="$(pwd)/go"
if [ -x "$LOCAL_GO_DIR/bin/go" ]; then
export GOROOT="$LOCAL_GO_DIR"
export PATH="$LOCAL_GO_DIR/bin:$PATH"
fi
# Download firmware if not cached.
if [ ! -f "$FIRMWARE_FILE" ]; then
echo "Downloading firmware ${FIRMWARE_VERSION} (~150MB)..."
mkdir -p "$FIRMWARE_DIR"
curl -fL --progress-bar -o "$FIRMWARE_FILE.tmp" "$FIRMWARE_URL"
# Validate it's actually a zip file.
if ! file "$FIRMWARE_FILE.tmp" | grep -q "Zip archive"; then
echo "ERROR: downloaded file is not a valid zip"
rm -f "$FIRMWARE_FILE.tmp"
exit 1
fi
mv "$FIRMWARE_FILE.tmp" "$FIRMWARE_FILE"
echo "Downloaded to $FIRMWARE_FILE"
else
echo "Using cached firmware: $FIRMWARE_FILE"
fi
# Find the WASM test executor.
GOROOT="$(go env GOROOT)"
if [ -f "$GOROOT/lib/wasm/go_js_wasm_exec" ]; then
EXEC="$GOROOT/lib/wasm/go_js_wasm_exec"
elif [ -f "$GOROOT/misc/wasm/go_js_wasm_exec" ]; then
EXEC="$GOROOT/misc/wasm/go_js_wasm_exec"
else
echo "ERROR: go_js_wasm_exec not found in GOROOT ($GOROOT)"
exit 1
fi
echo "Running integration test..."
FIRMWARE_ZIP="$FIRMWARE_FILE" GOOS=js GOARCH=wasm go test -v -run TestIntegrationPatch -timeout 300s -exec="$EXEC" .