Skip to content

Commit 597ca3a

Browse files
committed
Added test to reproduce "wrong delta base version" bug
1 parent 40ccd9e commit 597ca3a

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

.github/workflows/test-powerfail-simulator.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,18 @@ jobs:
198198
- name: Rebuild wolfboot.elf
199199
run: |
200200
make test-sim-internal-flash-with-delta-update
201-
201+
202202
- name: Run update-revert test with power failures (DELTA)
203203
run: |
204204
tools/scripts/sim-update-powerfail-resume.sh
205205
206+
- name: Rebuild with wrong delta base version
207+
run: |
208+
make clean && make test-sim-internal-flash-with-wrong-delta-update
209+
210+
- name: Run negative update test with wrong base version (DELTA)
211+
run: |
212+
tools/scripts/sim-delta-wrongversion-update.sh
206213
207214
# TEST with encryption (aes128)
208215
- name: make clean
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
V=`./wolfboot.elf update_trigger get_version 2>/dev/null`
4+
if [ "x$V" != "x1" ]; then
5+
echo "Failed first boot with update_trigger"
6+
exit 1
7+
fi
8+
9+
# First boot: attempt update, should be rejected
10+
V=`./wolfboot.elf success get_version 2>/dev/null`
11+
if [ "x$V" != "x1" ]; then
12+
echo "Error: Delta update with wrong image reported as successful."
13+
exit 1
14+
fi
15+
16+
# Second boot to verify system is alive
17+
V=`./wolfboot.elf success get_version 2>/dev/null`
18+
if [ "x$V" != "x1" ]; then
19+
echo "Error: System is possibly unrecoverable"
20+
exit 1
21+
fi
22+
echo "Update successfully rejected (V: $V)"
23+
24+
echo Test successful.
25+
exit 0
26+
27+

tools/test.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ test-sim-internal-flash-with-delta-update:
237237
$$(($(WOLFBOOT_PARTITION_UPDATE_ADDRESS)-$(ARCH_FLASH_OFFSET))) test-app/image_v$(TEST_UPDATE_VERSION)_signed_diff.bin \
238238
$$(($(WOLFBOOT_PARTITION_SWAP_ADDRESS)-$(ARCH_FLASH_OFFSET))) erased_sec.dd
239239

240+
test-sim-internal-flash-with-wrong-delta-update:
241+
make test-sim-internal-flash-with-update DELTA_UPDATE_OPTIONS="--delta test-app/image_v1_signed.bin"
242+
make test-sim-internal-flash-with-update DELTA_UPDATE_OPTIONS="--delta test-app/image_v2_signed.bin" TEST_UPDATE_VERSION=3
243+
$(Q)$(BINASSEMBLE) internal_flash.dd \
244+
0 wolfboot.bin \
245+
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) test-app/image_v1_signed.bin \
246+
$$(($(WOLFBOOT_PARTITION_UPDATE_ADDRESS)-$(ARCH_FLASH_OFFSET))) test-app/image_v3_signed_diff.bin \
247+
$$(($(WOLFBOOT_PARTITION_SWAP_ADDRESS)-$(ARCH_FLASH_OFFSET))) erased_sec.dd
248+
240249
test-sim-update-flash: wolfboot.elf test-sim-internal-flash-with-update FORCE
241250
$(Q)(test `./wolfboot.elf success update_trigger get_version` -eq 1)
242251
$(Q)(test `./wolfboot.elf success get_version` -eq $(TEST_UPDATE_VERSION))

0 commit comments

Comments
 (0)