Repository navigation
test(spi): add safety counter guard to ping-pong drain-all loops (#2824) - #2869
Conversation
Closes #2824. PR #2843 already fixed the polling-drain logic bug (the encodeIdx-based branch that produced the infinite loop). This closes out the issue's "Additional defense" recommendation: add the same `safety` counter + `stepStreaming()` return-value guard that's already in the queue-depth test (line 226) to the two drain-all loops that don't yet have it. Without the guard, a future regression of the same shape would manifest as a 20 s runner-watchdog timeout (the original #2824 symptom). With it, the loop bails after 1000 iterations with a clear `FL_CHECK_GT(safety, 0)` assertion in milliseconds. Affected test cases: - "Ping-pong - all bytes accounted for after drain" (line 248) - "Ping-pong - polling path drains all bytes" (line 268, the original #2824 hang site) The 1000-iteration cap leaves generous headroom — a 4 KB-capacity strip of 12345 bytes drains in ~25 ping-pong steps; 8000 bytes polling drains in ~16. Any regression that crosses 1000 is the same class of bug that #2824 caught. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo test cases in the SPI ping-pong pipeline logic test file were updated to add fail-fast safety counters around their streaming-drain completion loops. The counters break if the drain loop stalls and assert that the guard never expired, preventing infinite loops and runner watchdog timeouts. ChangesTest safety counters for streaming drain loops
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)tests/platforms/esp/32/drivers/spi/spi_pingpong_pipeline_logic.cpptests/platforms/esp/32/drivers/spi/spi_pingpong_pipeline_logic.cpp:25:10: fatal error: 'fl/stl/cstddef.h' file not found ... [truncated 1178 characters] ... l-isystem" "/usr/local/include" "-internal-isystem" 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 |
Closes #2824.
Summary
PR #2843 already shipped the primary fix from this issue (the polling-drain logic bug). This closes out the issue's Additional defense recommendation: add the
safetycounter +stepStreaming()return-value guard that's already used in the queue-depth test (line 226) to the two drain-all loops that don't yet have it.Without the guard, a future regression of the same shape would manifest as a 20 s runner-watchdog timeout (the original #2824 symptom). With it, the loop bails after 1000 iterations with a clear
FL_CHECK_GT(safety, 0)assertion in milliseconds.Test cases updated
Ping-pong - all bytes accounted for after drain(line 248)Ping-pong - polling path drains all bytes(line 268, the original test hang: spi_pingpong_pipeline_logic polling-path drains wrong buffer, loops forever (regression in #2810) #2824 hang site)The 1000-iteration cap leaves generous headroom — a 4 KB-capacity strip of 12345 bytes drains in ~25 ping-pong steps; 8000 bytes polling drains in ~16.
Test plan
bash lint --cppcleanbash test spi_pingpong_pipeline_logic— 1/1 passed in 1.73 s (no regression)🤖 Generated with Claude Code
Summary by CodeRabbit