Added test to reproduce "wrong delta base version" bug

pull/466/head
Daniele Lacamera 2024-07-04 17:14:36 +02:00
parent 40ccd9ea22
commit 597ca3a406
3 changed files with 44 additions and 1 deletions

View File

@ -198,11 +198,18 @@ jobs:
- name: Rebuild wolfboot.elf
run: |
make test-sim-internal-flash-with-delta-update
- name: Run update-revert test with power failures (DELTA)
run: |
tools/scripts/sim-update-powerfail-resume.sh
- name: Rebuild with wrong delta base version
run: |
make clean && make test-sim-internal-flash-with-wrong-delta-update
- name: Run negative update test with wrong base version (DELTA)
run: |
tools/scripts/sim-delta-wrongversion-update.sh
# TEST with encryption (aes128)
- name: make clean

View File

@ -0,0 +1,27 @@
#!/bin/bash
V=`./wolfboot.elf update_trigger get_version 2>/dev/null`
if [ "x$V" != "x1" ]; then
echo "Failed first boot with update_trigger"
exit 1
fi
# First boot: attempt update, should be rejected
V=`./wolfboot.elf success get_version 2>/dev/null`
if [ "x$V" != "x1" ]; then
echo "Error: Delta update with wrong image reported as successful."
exit 1
fi
# Second boot to verify system is alive
V=`./wolfboot.elf success get_version 2>/dev/null`
if [ "x$V" != "x1" ]; then
echo "Error: System is possibly unrecoverable"
exit 1
fi
echo "Update successfully rejected (V: $V)"
echo Test successful.
exit 0

View File

@ -237,6 +237,15 @@ test-sim-internal-flash-with-delta-update:
$$(($(WOLFBOOT_PARTITION_UPDATE_ADDRESS)-$(ARCH_FLASH_OFFSET))) test-app/image_v$(TEST_UPDATE_VERSION)_signed_diff.bin \
$$(($(WOLFBOOT_PARTITION_SWAP_ADDRESS)-$(ARCH_FLASH_OFFSET))) erased_sec.dd
test-sim-internal-flash-with-wrong-delta-update:
make test-sim-internal-flash-with-update DELTA_UPDATE_OPTIONS="--delta test-app/image_v1_signed.bin"
make test-sim-internal-flash-with-update DELTA_UPDATE_OPTIONS="--delta test-app/image_v2_signed.bin" TEST_UPDATE_VERSION=3
$(Q)$(BINASSEMBLE) internal_flash.dd \
0 wolfboot.bin \
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) test-app/image_v1_signed.bin \
$$(($(WOLFBOOT_PARTITION_UPDATE_ADDRESS)-$(ARCH_FLASH_OFFSET))) test-app/image_v3_signed_diff.bin \
$$(($(WOLFBOOT_PARTITION_SWAP_ADDRESS)-$(ARCH_FLASH_OFFSET))) erased_sec.dd
test-sim-update-flash: wolfboot.elf test-sim-internal-flash-with-update FORCE
$(Q)(test `./wolfboot.elf success update_trigger get_version` -eq 1)
$(Q)(test `./wolfboot.elf success get_version` -eq $(TEST_UPDATE_VERSION))