Repository navigation
fix(parlio): mock waitAllDone() pumps deferred ISR callbacks to mirror real-DMA semantics (#2992 follow-up) - #3010
Conversation
…r real-DMA semantics (#2992 follow-up) After #2992 ("feat: add ISR-backed channel poll wakeups"), `ParlioEngine` runs `beginTransmission()` in ASYNC mode: the last txDone ISR sets `mStreamComplete=true` and the *next* `poll()` tick observes that flag and clears `mTransmitting` (the gate that begins a new transmission). The old engine cleared `mTransmitting` directly in the ISR, so callers that issued back-to-back `beginTransmission()` calls without an intervening `poll()` still worked. After #2992 they no longer do. Two `parlio_driver` unit tests issue exactly that pattern and have been failing on master since 2026-06-09 (every CI run on PRs #2998, #3001, and the just-merged #3003 fails the same way): FAIL: ParlioEngine mock - transmission history clearing at tests/platforms/esp/32/drivers/parlio/parlio_driver.cpp:671 :694: count2 > 0 :695: mock.getTransmitCount() > count1 REQUIRE FAILED: parlio_driver.cpp:1029: tx_ok On real hardware the engine's own line-1845 drain pattern (`mPeripheral->waitAllDone(100)` at the top of `beginTransmission()`) gives the ISR a chance to fire and then a `poll()` tick can clear `mTransmitting`. The mock, by contrast, fires txDone callbacks synchronously inside `transmit()` and used to noop `waitAllDone()`, so no `poll()` tick ever ran — `mTransmitting` stayed stuck at true forever and the second `beginTransmission()` short-circuited with "transmission already in progress". Fix the mock, not the test (per the maintainer's "gap in the mock vs the real thing" framing): drive one `ParlioEngine::poll()` tick from the mock's `waitAllDone()` and `deinitialize()`. Those are the two real-hardware-faithful boundaries where "no active DMA" is the contract — `waitAllDone()` is the engine's own pre-transmission drain point, and `deinitialize()` is what the engine calls from its config-match re-init path at parlio_engine.cpp.hpp:1411 (the route test 1029 takes). A single `mSettlingEngine` re-entrancy flag breaks the obvious recursion (`poll()` itself calls `waitAllDone(0)`). The mock stays fully synchronous and single-threaded — no new threads, no new deferred-callback states, no churn in the existing pumpDeferredCallbacks/mFiringCallbacks machinery. Only the engine async-state contract gets one extra tick at each transmit boundary. No engine changes. No test changes. Verified: - `bash test parlio_driver` passes (both originally failing tests) - `bash test parlio_driver --debug` passes (ASAN/LSAN/UBSAN clean) - `bash lint --cpp` clean Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
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)
📝 WalkthroughWalkthroughA ChangesEngine state settling at transmit boundaries
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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)
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 |
Summary
ParlioEngine'smTransmittingclear out of the txDone ISR and intopoll(), switchingbeginTransmission()to true ASYNC mode. Twoparlio_driverunit tests issue back-to-backbeginTransmission()calls without an interveningpoll()and have been failing on master since 2026-06-09 — every PR'sunit tests linuxjob (feat(noexcept): annotate hot-path functions with FL_NOEXCEPT #2998, chore(deps): bump zccache floor to >=1.12.0 #3001, chore(deps): bump fbuild 2.2.22 -> 2.2.27 #3003) regresses the same way.transmit()AND noop'dwaitAllDone(). In ASYNC mode that leaves the engine'smTransmitting=trueforever between transmissions, so the secondbeginTransmission()short-circuits with "transmission already in progress".ParlioEngine::poll()tick from the mock'swaitAllDone()anddeinitialize()— the two real-hardware-faithful boundaries where "no active DMA" is the contract. A singlemSettlingEnginere-entrancy flag breaks the obvious recursion (poll calls waitAllDone(0)). The mock stays fully synchronous and single-threaded.Why not fix the test?
The maintainer explicitly framed this as "the gap in the mock vs the real thing." On real hardware the engine's own line-1845
waitAllDone(100)-then-check-mTransmittingdrain pattern at the top ofbeginTransmission()works because the ISR fires during the wait. The mock just didn't model that —waitAllDone()was a noop. Fixing the test would paper over the gap; fixing the mock makes it accurately model the real-DMA contract.What was tested
bash test parlio_driver— passes (both originally failing tests: "ParlioEngine mock - transmission history clearing" at line 671, and "verify captured DMA data is non-zero" at line 1011).bash test parlio_driver --debug— passes with ASAN/LSAN/UBSAN sanitizers enabled. No memory errors, no UB.bash lint --cpp— clean.No changes to the engine. No changes to any test. Single file touched:
src/platforms/esp/32/drivers/parlio/parlio_peripheral_mock.cpp.hpp(+47/-2).Test plan
bash test parlio_driverpasses (quick mode)bash test parlio_driver --debugpasses (ASAN/UBSAN clean)bash lint --cppcleanunit tests linuxjob goes green on this PR🤖 Generated with Claude Code
Summary by CodeRabbit