Verify partition isolation in custom-trailer state test

After writing both partitions, re-read BOOT and confirm it still
holds TESTING, so a backend that routes both IDs to the same
trailer is caught (previously each read followed its own write).

Verification: make -C tools/unit-tests unit-custom-trailer-nopart
exits 0; suite runs 1 check, 0 failures.
pull/892/head
Daniele Lacamera 2026-09-17 09:29:03 +02:00
parent d0ec587c7a
commit edf41b1c35
1 changed files with 5 additions and 0 deletions

View File

@ -94,6 +94,11 @@ START_TEST(test_set_get_partition_state)
ck_assert_int_eq(wolfBoot_get_partition_state(PART_UPDATE, &st), 0);
ck_assert_uint_eq(st, IMG_STATE_UPDATING);
/* Writing UPDATE must not clobber BOOT: re-read BOOT and confirm it
* still holds TESTING, not the UPDATE value. */
ck_assert_int_eq(wolfBoot_get_partition_state(PART_BOOT, &st), 0);
ck_assert_uint_eq(st, IMG_STATE_TESTING);
/* PART_NONE is rejected. */
ck_assert_int_eq(wolfBoot_set_partition_state(PART_NONE, 0), -1);
ck_assert_int_eq(wolfBoot_get_partition_state(PART_NONE, &st), -1);