How nanoflash is tested
A flashing tool fails on hardware, where tests are slow and boards are few. nanoflash therefore tests every device session without a board first, then checks the same paths against emulators and real boards.
Transcripts
A transcript is a text file with one event per line:
| Prefix | Event |
|---|---|
> | Bytes from the host, in hexadecimal. |
< | Bytes from the device, in hexadecimal. |
! | Line changes, baud rate changes, waits, re-enumerations. |
# | A comment. |
The testing feature provides a replay transport that fails on any divergence, and a recording
transport behind the hidden --record <file> flag of the command. The transcripts of the library
are in crates/nanoflash/tests/transcripts. The transcripts of nanoflash monitor and
nanoflash run are in crates/nanoflash-cli/tests/transcripts.
Sources of transcripts
- Espressif’s QEMU (ESP32 and ESP32-C3 in download mode), in CI.
- arduino/BOSSA’s SAM-BA emulator, for SAM-BA.
- simavr (GPL-3.0, installed or downloaded at test time, never committed or distributed) running Optiboot, ATmegaBOOT and the wiring bootloader of the Mega 2560 from ArduinoCore-avr.
- Recordings from real boards, added as they are made.
- Hand-written transcripts for error paths: timeouts, bad checksums, a wrong chip.
Run the hardware tests describes each emulator and the boards.
Property tests
proptest checks that resolution never yields overlap or misalignment and keeps fixed offsets.
Every writer round-trips through a parser: esp-idf-part and ESP-IDF’s gen_esp32part.py in CI
for the Espressif table, mbrman and sfdisk --dump for the MBR.
WebAssembly
The backends and the library build for wasm32-unknown-unknown in CI. Replay tests run the
WebAssembly modules in Node against a Web Serial mock that a transcript drives. The check in a real
browser is manual: see Run the hardware
tests.
Hardware in the loop
hardware/ describes the boards attached to a runner. mise run test-hardware flashes, verifies
and checks that the board booted (a known string on its serial port). The tests are #[ignore]d
unless NANOFLASH_HARDWARE is set. A workflow_dispatch job targets a self-hosted runner with the
nanoflash-hardware label.