Skip to content

fwmanager: downstream update lifecycle tests with slot and boot-progress capabilities - #392

Draft
chrysh wants to merge 4 commits into
OpenPRoT:mainfrom
9elements:add-lifecycle-itest
Draft

fwmanager: downstream update lifecycle tests with slot and boot-progress capabilities#392
chrysh wants to merge 4 commits into
OpenPRoT:mainfrom
9elements:add-lifecycle-itest

Conversation

@chrysh

@chrysh chrysh commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Host-level, black-box integration tests for the downstream firmware-update lifecycle: a MockDownstreamDevice on the eRoT's seams (reset line, boot-complete line, slot flash, staging flash, slot store), with every assertion made on externally visible signals — reset transitions, what was flashed while the device was held, which slot the device booted, what got committed. Plain rust_test, no kernel, no QEMU.

Covered scenarios: a successful update proves the device is held in reset the whole time firmware is written, is rebooted on the new slot, and is committed only after the booted state was observed; a device whose firmware write path fails is noticed through the flash seam, with nothing armed or committed and the old slot untouched; a corrupt staged image is rejected during staging without disturbing the running device; a trial-boot window that expires without evidence rolls back and reboots the still-committed slot. A negative-control test runs a deliberately careless driver and asserts the instrumentation catches it, so the positive assertions cannot pass vacuously.

Supporting pieces: the SlotControl capability (trial/commit/rollback slot selection) and BootProgress/await_boot (a bounded boot window over the existing BootMonitor, rendered as a deterministic poll budget — tests never sleep) are added to the fwmanager api leaf, per #377. The mock downstream device grows A/B slots, a staging region, a slot store, fault injection for a broken write path, and the ordering instrumentation the tests assert on. The existing boot_flow tests pass unchanged on the extended mock.

There is deliberately no orchestrator dependency: stage_update/activate_update in the test file are the reference rendering of the trial-boot protocol sketched in the BootControl docs. They are the executable spec for the orchestrator from #357 — when it merges, the real state machine replaces these test-local drivers and the assertions stay.

Refs #377.

@chrysh
chrysh marked this pull request as draft August 5, 2026 08:00
@chrysh
chrysh force-pushed the add-lifecycle-itest branch from c4194bb to ae906f0 Compare August 5, 2026 12:12
chrysh added 4 commits August 5, 2026 16:21
Add MockDownstreamDevice (reset line, boot-complete line, firmware
flash, one shared state) and a host test driving the boot flow through
the real adapters: verify firmware, release only on a pass, poll boot
completion within a budget. Covers corrupt firmware, hung device,
stale boot evidence, and both error seams.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Christina Quast <christina.quast@9elements.com>
SlotControl: slot actuation with trial-boot semantics — set_trial arms
one boot (one-shot), commit promotes, rollback disarms; commit and
rollback error with no trial armed. await_boot renders one bounded
boot window as a poll budget over BootMonitor, so tests never sleep.
In-file contract tests against HAL-free mocks.

Refs: openprot OpenPRoT#377
Assisted-by: Claude:claude-fable-5
Signed-off-by: Christina Quast <christina.quast@9elements.com>
Two firmware slots, a staging region, and a SlotControl store with
one-shot arming (the boot consumes the trial selector; the armed slot
stays promotable until commit/rollback). flash() becomes the boot-slot
view, so the existing boot_flow tests pass unchanged. New ordering
instrumentation (last_boot_slot, programs_while_running,
commit_preceded_by_ready, commit/rollback counts) and fault injection
(inject_program_fault, set_boots_after).

Assisted-by: Claude:claude-fable-5
Signed-off-by: Christina Quast <christina.quast@9elements.com>
Host tests asserting only on externally visible signals: successful
update (device held in reset while flashed, committed only after
observed boot), failed firmware write, corrupt staged image, trial
timeout rollback, and a negative control proving the instrumentation
catches a careless driver. stage_update/activate_update are test-local
stand-ins for the PR OpenPRoT#357 orchestrator: when it merges, the drivers go
and the assertions stay.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Christina Quast <christina.quast@9elements.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant