test(io-board-interface): fuzz/property tests for StreamDecoder - #69
Conversation
Harden the CPU<->MCU frame StreamDecoder against untrusted UART bytes with deterministic, dependency-free stdlib unittest coverage (fixed seeds), auto- discovered by the existing host CI python job: - feed() never raises on arbitrary bytes; emitted frames round-trip; residual buffer stays < one max frame (<=523) after every call - chunk-boundary invariance: frames + residual buffer depend only on the concatenated stream, not on how it is split across feed() calls - valid frames separated by non-magic noise are recovered in order, exactly - targeted cases: oversized declared length, bad CRC then valid frame, empty and max (512B) payloads, a 512B frame fed one byte at a time (bound check), and an explicit test documenting the known stalled-header resync limitation Full suite runs in ~0.8s.
|
@xbattlax heads-up — this adds tests under your io-board-interface subtree rather than a new folder, since they target your StreamDecoder directly and slot into the existing CI job. Happy to relocate if you'd prefer. |
|
Thanks for the heads-up. Keeping these tests under I checked the full diff at One non-blocking follow-up: No relocation needed from my side. Thank you for strengthening this path. |
|
Thank you! |
What
Fuzz/property tests for the CPU<->MCU frame
StreamDecoderincontributions/io-board-interface/xbattlax/. Tests only. No production changes.Why
StreamDecoder.feed()parses untrusted serial bytes: noisy, arbitrarilychunked, sometimes corrupt. This pins down its robustness so regressions fail CI.
Checks
feed()never raises; every emitted frame round-trips.stream, not on how it is split across calls.
512-byte payloads, a 512-byte frame fed one byte at a time, and the known
stalled-header resync behavior.
Notes
unittest, fixed seeds. Auto-discovered by the existingpythonCI job. No workflow change, no new dependency.
_bufferto check the memory bound andresidual state. Intentional white-box coverage.
Testing
Full io-board-interface suite passes in ~0.8s. Green on fork CI.