How would you test power-loss recovery during a critical write?
Answer
Automate power interruption at many controlled points before, during and after erase or write operations, then reboot and verify invariants rather than one expected byte sequence. The device must select either the old or new valid state, detect corruption, avoid boot loops and retain enough evidence for diagnosis. Repeat across voltage, storage wear and relevant hardware variants.
Strong answer includes
- sweeps interruption points systematically
- asserts atomic state invariants
- repeats across hardware and storage conditions
Practical example
A test rig cuts power to a device at 200 evenly spaced points during a firmware-settings write, then reboots and checks that the settings always equal either the pre-write or post-write value, never a mixture. At interruption point 143, the device boots with a partially-written checksum-valid-looking record that turns out to be neither old nor new state, exposing a bug where the checksum was written before the data instead of after.