Skip to content

Add regression tests for flash write bugs#39

Merged
widgetii merged 2 commits intomasterfrom
test/flash-regression
Apr 6, 2026
Merged

Add regression tests for flash write bugs#39
widgetii merged 2 commits intomasterfrom
test/flash-regression

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented Apr 6, 2026

Summary

Regression tests for bugs found during hardware testing that caused data corruption on real cameras:

Bug Impact Test Coverage
COBS trailing zero strip ~1/256 packets corrupted → all writes failed 1000 CRC patterns (C), 256 build/parse roundtrips (Python)
CRC32 high-byte UB (uint8_t << 24) Undefined behavior when byte >= 128 All 256 MSB values (C)
_recv_packet_sync partial frame stash Next packet corrupted after stash 32 consecutive ACKs, interleaved READY+DATA (Python)
recv_response READY timeout READY packets consumed timeout budget Deadline reset verification (Python)
Sector bitmap bit ordering Host/agent bitmap disagreement → wrong sectors skipped 256 individual sectors, byte boundaries, firmware simulation (Python)
page_is_ff false positives Could skip programming non-FF pages Single non-FF byte at every position (C)

C tests: 5406 assertions (up from 1603)
Python tests: 18 new tests in test_flash_stream_regression.py

Test plan

  • make -C agent test — 5406/5406 pass
  • pytest tests/test_flash_stream_regression.py — 18/18 pass
  • CI green

🤖 Generated with Claude Code

widgetii and others added 2 commits April 6, 2026 21:24
C tests (agent/test_agent.c, 5406 assertions up from 1603):
- COBS trailing zero: 1000 payloads with varying CRC patterns
- CRC32 high-byte shift: all 256 MSB values through pack/unpack
- Proto send/recv roundtrip: 256 different payloads covering all CRC MSBs
- page_is_ff: all-FF, all-00, single non-FF at every position
- Sector bitmap: bit ordering, byte boundaries, all-set, all-clear

Python tests (tests/test_flash_stream_regression.py, 18 tests):
- COBS trailing zero: roundtrip, CRC32 with zero MSB, build/parse all patterns
- Partial frame stashing: consecutive packets, extra bytes after delimiter,
  32 ACKs in sequence, interleaved READY+DATA
- recv_response READY timeout: verify deadline resets after READY skip
- Sector bitmap: individual sectors, byte boundaries, firmware simulation
- CMD_FLASH_STREAM payload: 44-byte format, bitmap parsing
- COBS cross-compat: all 256 single bytes, zero CRC MSB edge case

These tests prevent regressions for bugs that caused data corruption on
real cameras during flash write operations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit cc8cb9e into master Apr 6, 2026
13 checks passed
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