From f166a9ffca4052150a26471cbe3f949826626db0 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 26 Mar 2026 12:21:05 +0100 Subject: [PATCH] Centralize firmware configuration for tests --- .github/workflows/build.yml | 2 +- kobopatch-wasm/test-integration.sh | 5 +---- kobopatch-wasm/test-patches.sh | 11 +++++++---- test.sh | 4 ++-- tests/firmware-config.js | 18 +++++++++++++++--- tests/helpers/paths.js | 5 +---- web/src/patches/blacklist.json | 12 ++++++++++++ 7 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5cb3b2..add8d78 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,7 +69,7 @@ jobs: if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true' run: | mkdir -p tests/cached_assets - node -e "console.log(JSON.stringify(require('./tests/firmware-config')))" | jq -c '.[]' | while IFS= read -r entry; do + node -e "var c=require('./tests/firmware-config'); console.log(JSON.stringify([c.primary, ...c.others]))" | jq -c '.[]' | while IFS= read -r entry; do version=$(echo "$entry" | jq -r '.version') url=$(echo "$entry" | jq -r '.url') file="tests/cached_assets/kobo-update-${version}.zip" diff --git a/kobopatch-wasm/test-integration.sh b/kobopatch-wasm/test-integration.sh index a6edf35..73c8033 100755 --- a/kobopatch-wasm/test-integration.sh +++ b/kobopatch-wasm/test-integration.sh @@ -14,10 +14,7 @@ if [ -x "$LOCAL_GO_DIR/bin/go" ]; then fi FIRMWARE_CONFIG="$(cd .. && pwd)/tests/firmware-config.js" -PRIMARY=$(node -e " - const c = require('$FIRMWARE_CONFIG')[0]; - console.log(JSON.stringify(c)); -") +PRIMARY=$(node -e "console.log(JSON.stringify(require('$FIRMWARE_CONFIG').primary))") PRIMARY_VERSION=$(echo "$PRIMARY" | jq -r '.version') PATCHES_ZIP="$(cd .. && pwd)/web/src/patches/$(echo "$PRIMARY" | jq -r '.patches')" CHECKSUMS=$(echo "$PRIMARY" | jq -r '.checksums | to_entries | map("\(.key)=\(.value)") | join(",")') diff --git a/kobopatch-wasm/test-patches.sh b/kobopatch-wasm/test-patches.sh index 91568c5..860a852 100755 --- a/kobopatch-wasm/test-patches.sh +++ b/kobopatch-wasm/test-patches.sh @@ -29,8 +29,8 @@ echo "Built kobopatch successfully." # Start with an empty blacklist. echo "{}" > "$BLACKLIST_FILE" -# Iterate over all firmware versions in the config. -CONFIGS=$(node -e "console.log(JSON.stringify(require('$FIRMWARE_CONFIG')))") +# Iterate over all firmware versions in the config (primary + others). +CONFIGS=$(node -e "var c=require('$FIRMWARE_CONFIG'); console.log(JSON.stringify([c.primary, ...c.others]))") COUNT=$(echo "$CONFIGS" | jq 'length') for i in $(seq 0 $((COUNT - 1))); do @@ -39,13 +39,16 @@ for i in $(seq 0 $((COUNT - 1))); do SHORT_VERSION=$(echo "$ENTRY" | jq -r '.shortVersion') PATCHES=$(echo "$ENTRY" | jq -r '.patches') + URL=$(echo "$ENTRY" | jq -r '.url') FIRMWARE_FILE="$CACHED_ASSETS/kobo-update-${VERSION}.zip" PATCHES_ZIP="$PATCHES_DIR/$PATCHES" if [ ! -f "$FIRMWARE_FILE" ]; then echo "" - echo "=== Skipping $VERSION (firmware not downloaded) ===" - continue + echo "=== Downloading firmware $VERSION ===" + mkdir -p "$CACHED_ASSETS" + curl -fL --progress-bar -o "$FIRMWARE_FILE.tmp" "$URL" + mv "$FIRMWARE_FILE.tmp" "$FIRMWARE_FILE" fi if [ ! -f "$PATCHES_ZIP" ]; then diff --git a/test.sh b/test.sh index c777c4a..6e4a206 100755 --- a/test.sh +++ b/test.sh @@ -41,7 +41,7 @@ while IFS= read -r line; do if [ ! -f "$file" ]; then MISSING+=("$version|$url|$file") fi -done < <(node -e "console.log(JSON.stringify(require('$FIRMWARE_CONFIG')))" | jq -c '.[]') +done < <(node -e "var c=require('$FIRMWARE_CONFIG'); console.log(JSON.stringify([c.primary, ...c.others]))" | jq -c '.[]') if [ ${#MISSING[@]} -gt 0 ]; then echo "The following firmware test assets are not cached locally (~150 MB each):" @@ -94,7 +94,7 @@ echo "=== Building WASM ===" echo "" echo "=== Running WASM integration test ===" -PRIMARY_FW="$CACHED_ASSETS/kobo-update-$(node -e "console.log(require('$FIRMWARE_CONFIG')[0].version)").zip" +PRIMARY_FW="$CACHED_ASSETS/kobo-update-$(node -e "console.log(require('$FIRMWARE_CONFIG').primary.version)").zip" if [ -f "$PRIMARY_FW" ]; then "$SCRIPT_DIR/kobopatch-wasm/test-integration.sh" else diff --git a/tests/firmware-config.js b/tests/firmware-config.js index 31c8653..3a3053c 100644 --- a/tests/firmware-config.js +++ b/tests/firmware-config.js @@ -1,12 +1,16 @@ // Firmware versions used for testing. Shell scripts read this via jq-compatible // JSON output from: node -e "console.log(JSON.stringify(require('./tests/firmware-config')))" -module.exports = [ - { +// +// The primary version is used for WASM integration tests (checksum validation) +// and E2E tests. All versions (primary + others) are used for patch testing. +module.exports = { + primary: { version: '4.45.23646', shortVersion: '4.45', url: 'https://ereaderfiles.kobo.com/firmwares/kobo13/Mar2026/kobo-update-4.45.23646.zip', patches: 'patches_4.45.zip', checksums: { + // Modified checksums if the "hide row3" patch is applied. 'usr/local/Kobo/libnickel.so.1.0.0': 'ef64782895a47ac85f0829f06fffa4816d23512d', 'usr/local/Kobo/nickel': '80a607bac515457a6864be8be831df631a01005c', 'usr/local/Kobo/libadobe.so': '02dc99c71c4fef75401cd49ddc2e63f928a126e1', @@ -16,4 +20,12 @@ module.exports = [ // Used to verify the "restore original firmware" flow extracts correctly. originalTgzChecksum: 'b5c3307e8e7ec036f4601135f0b741c37b899db4', }, -]; + others: [ + { + version: '4.38.23648', + shortVersion: '4.38', + url: 'https://ereaderfiles.kobo.com/firmwares/kobo9/Mar2026/kobo-update-4.38.23648.zip', + patches: 'patches_4.38.zip', + }, + ], +}; diff --git a/tests/helpers/paths.js b/tests/helpers/paths.js index 24fd614..5f63a4a 100644 --- a/tests/helpers/paths.js +++ b/tests/helpers/paths.js @@ -1,19 +1,16 @@ const path = require('path'); -const firmwareConfig = require('../firmware-config'); +const { primary } = require('../firmware-config'); const CACHED_ASSETS = path.resolve(__dirname, '..', 'cached_assets'); const WEBROOT = path.resolve(__dirname, '..', '..', 'web', 'dist'); const WEBROOT_FIRMWARE = path.join(WEBROOT, '_test_firmware.zip'); -// Primary firmware entry (first in config) is used for E2E/integration tests. -const primary = firmwareConfig[0]; const FIRMWARE_PATH = path.join(CACHED_ASSETS, `kobo-update-${primary.version}.zip`); const EXPECTED_SHA1 = primary.checksums; const ORIGINAL_TGZ_SHA1 = primary.originalTgzChecksum; module.exports = { - firmwareConfig, FIRMWARE_PATH, WEBROOT, WEBROOT_FIRMWARE, diff --git a/web/src/patches/blacklist.json b/web/src/patches/blacklist.json index 241cd56..5834544 100644 --- a/web/src/patches/blacklist.json +++ b/web/src/patches/blacklist.json @@ -17,5 +17,17 @@ "Default ePub sans-serif font (Gill Sans)", "Default ePub serif font (Amasis)" ] + }, + "4.38": { + "src/libadobe.so.yaml": [ + "Remove PDF map widget shown during panning" + ], + "src/libnickel.so.1.0.0.yaml": [ + "Both page turn buttons go next", + "Customize ComfortLight settings" + ], + "src/nickel.yaml": [ + "Remove forgot pin button from lock screen" + ] } }