Repository navigation
fix(autoresearch): fail the test when RX capture is truncated - #2297
Conversation
The WS2812 per-LED comparator silently `break`s when `bytes_captured` runs short, then reports `Errors: 0/<num_leds>` as PASS. Any LEDs past the first `bytes_captured / 3` are quietly skipped without comparison — turning truncated captures into false-positive PASSes. On ESP32-S3 the RMT RX DMA buffer caps a single receive at 4096 symbols (≈ 170 WS2812B LEDs), so every autoresearch run on a strip longer than ~170 LEDs was passing without actually verifying the tail. Track how many LEDs were actually compared. After the loop, if the count is short of `num_leds`, count the unchecked LEDs as mismatches and emit a clear `[TRUNCATED CAPTURE]` diagnostic so the run hard-FAILs. No-op when capture is full (current pass paths unchanged). Observed behavior on ESP32-S3 before: `--spi --strip-sizes 550` reports PASS with `bytes_captured=512` / `Errors: 0/550 (100.0%)`. After: hard FAIL with `[TRUNCATED CAPTURE] Only verified 170/550 LEDs (512 bytes captured, needed 1650). Marking 380 unchecked LEDs as mismatches.` 100-LED test regression-free (still PASSes legitimately). See issue #2254. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThe test verification logic now properly detects and penalizes truncated RX buffer captures by tracking verified LED counts, comparing against expected totals, and counting missing validations as byte mismatches with a warning message. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
examples/AutoResearch/AutoResearchTest.cpp (1)
690-712: Same silent-truncation bug still lives inrunTest().This PR fixes
runMultiTest(), but the siblingrunTest()has the identical pattern: the loopbreaks on insufficientbytes_captured(line 698) without incrementingmismatches, so a truncated capture whose verified LEDs all happen to match will still be reported asPASS ✓at line 720. If any callers exerciserunTest()on strips that can exceed the RMT 4096-symbol DMA budget (e.g.,--strip-sizes 550on ESP32-S3), they will continue to see false positives even after this PR lands.Consider mirroring the fix here for consistency.
♻️ Proposed parallel fix for runTest()
+ size_t verified_leds = 0; for (size_t i = 0; i < num_leds; i++) { size_t byte_offset = rx_buffer_offset + i * 3; // Skip front padding if (byte_offset + 2 >= bytes_captured) { // Check against total captured bytes FL_ERROR("[" << ctx.driver_name << "/" << ctx.timing_name << "/" << ctx.pattern_name << " | Lane " << ctx.lane_index << "/" << ctx.lane_count << " (Pin " << ctx.pin_number << ", " << ctx.num_leds << " LEDs) | RX:" << ctx.rx_type_name << "] " << "Incomplete data for LED[" << static_cast<int>(i) << "] (only " << bytes_captured << " bytes captured)"); break; } + verified_leds = i + 1; uint8_t expected_r = leds[i].r; // ... if (expected_r != actual_r || expected_g != actual_g || expected_b != actual_b) { mismatches++; } } + + if (verified_leds < num_leds) { + size_t unchecked = num_leds - verified_leds; + mismatches += static_cast<int>(unchecked); + FL_WARN("[TRUNCATED CAPTURE] Only verified " << verified_leds + << "/" << num_leds << " LEDs - marking " << unchecked + << " unchecked LEDs as mismatches."); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/AutoResearch/AutoResearchTest.cpp` around lines 690 - 712, runTest() currently breaks out of the LED verification loop when (byte_offset + 2 >= bytes_captured) without marking that remaining LEDs were unverified, which can yield false PASS results; update the loop in runTest() (the block referencing rx_buffer_offset, num_leds, bytes_captured, mismatches and the FL_ERROR log) to treat a truncation as mismatches for the remaining LEDs — increment mismatches by (num_leds - i) or otherwise set a failing flag before breaking and keep the existing FL_ERROR message so truncated captures are counted as failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@examples/AutoResearch/AutoResearchTest.cpp`:
- Around line 690-712: runTest() currently breaks out of the LED verification
loop when (byte_offset + 2 >= bytes_captured) without marking that remaining
LEDs were unverified, which can yield false PASS results; update the loop in
runTest() (the block referencing rx_buffer_offset, num_leds, bytes_captured,
mismatches and the FL_ERROR log) to treat a truncation as mismatches for the
remaining LEDs — increment mismatches by (num_leds - i) or otherwise set a
failing flag before breaking and keep the existing FL_ERROR message so truncated
captures are counted as failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d596ff79-00ba-4f6e-9b80-ac02a84198c2
📒 Files selected for processing (1)
examples/AutoResearch/AutoResearchTest.cpp
Summary
The autoresearch WS2812 comparator silently
breaks the per-LED compare loop whenbytes_capturedruns short, then reportsErrors: 0/<num_leds>as PASS. Any LEDs past the firstbytes_captured / 3are skipped without comparison — turning truncated captures into false-positive PASSes.On ESP32-S3 the RMT RX DMA buffer caps a single receive at 4096 symbols (≈ 170 WS2812B LEDs), so every autoresearch run on a strip longer than ~170 LEDs was passing without actually verifying the tail.
Change
Track
verified_leds. After the loop, if it's short ofnum_leds, count the unchecked LEDs as mismatches and emit a clear[TRUNCATED CAPTURE]diagnostic so the run hard-FAILs. No-op when capture is full.Before on
bash autoresearch --spi --strip-sizes 550(ESP32-S3):After:
Test plan
bash autoresearch --spi --strip-sizes 550on ESP32-S3 now hard-FAILs with the[TRUNCATED CAPTURE]diagnostic.bash autoresearch --spi --strip-sizes 100on ESP32-S3 still PASSes legitimately (bytes_captured=300, all 100 LEDs verified).--strip-sizes smalldefault).Background
Exposed while reproducing issue #2254 (ESP32-S3 SPI driver "black frame between displays"). Independent of any driver fix; this is purely a test-harness correctness improvement that makes the harness stop lying on long strips.
The underlying RX-capacity limit (~170 LEDs per pass) is a separate, larger investigation documented in #2254 — it requires RmtMemoryManager refactoring to support DMA-mode RX allocations. Until that lands, this PR at least ensures such runs FAIL loudly instead of passing silently.
Related
--frames Nmulti-frame capture)🤖 Generated with Claude Code
Summary by CodeRabbit