Repository navigation
Improve test coverage to 100% functions / 88% lines; automate Windows coverage via OpenCppCoverage - #5
Merged
Conversation
amoldhamale1105
requested changes
Apr 11, 2026
Broke the two giant TEST() blocks into individual TEST/TEST_F cases with proper <func>_test_scenario names. Moved event setup/teardown into fixtures (SetUp/TearDown, SetUpTestSuite for the shared loop) instead of building everything inline in one function. Also added a real assertion that halt happens within its scheduled delay instead of just waiting up to 300ms and hoping, and made the DataEvent test actually check the handler fired. While adding a BLOCK-mode test I hit a real bug: start() would call std::thread(...) on top of a thread that was still joinable from a previous run, since Halt() signals shutdown but never joins. Fixed by joining m_mainLoop/m_scheduler at the top of start() if needed. Cleaned up the coverage-percentage comments in the test file and build.sh since that stuff belongs in the coverage report, not code. Not doing in this PR: the dead-code cleanup in eventLoop() (will be its own PR) or mocking thread-creation failures for the catch blocks (needs a factory seam in EventManager, also separate).
OpenCppCoverage rejects forward-slash paths when run from Git Bash. Convert all path arguments with cygpath -w. Also add the library directory to PATH for the coverage run, since the test exe cannot find EventLoop.dll when run outside ctest (0xC0000135), and exit with an error if coverage generation fails instead of reporting success unconditionally.
… prevent data race
…ndows coverage branch omitting thread safety tests in build script
amoldhamale1105
approved these changes
Oct 14, 2026
amoldhamale1105
left a comment
Owner
There was a problem hiding this comment.
Pushed commits to fix TSan failures with the new tests and to fix issues related to running tests and generating coverage report on Windows.
@anderewrey Thanks to your TSan CI setup, we were able to catch and fix more race conditions in the implementation. Check my recent commits in this PR.
2 tasks done
anderewrey
pushed a commit
to anderewrey/grpc_reactor_routeguide
that referenced
this pull request
Oct 22, 2026
TSan, against a fully instrumented stack, reported a data race in every ClientReactorIntegrationTest: EventManager::processEvent() pushed onto the event queue and notified without holding m_mutex, while eventLoop() reads and pops that queue under it. A standalone reproducer using only EventLoop's public API, without gRPC, lost 433 to 553 wakeups per 20 000 events and segfaulted in 5 of 5 plain -O2 runs. The reactors call TriggerEvent() from gRPC's threads, so the application is exposed too, not only the tests. Upstream fixed it in amoldhamale1105/EventLoop#7: processEvent() and scheduleEvent() push under their loop's mutex, eventLoop() releases it while handlers run, so a handler calling TriggerEvent() cannot deadlock, and the shutdown flags are atomic and set under the mutexes. amoldhamale1105/EventLoop#5 then guarded the receivers' callback map, another race, and fixed restarting after Halt() and the destructor order. Pin ce1c71e, which carries both. The port also declared EventLoop MIT, but its LICENSE and source headers are LGPL 2.1 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019GqSK7yLMgqFy6jBsgiNqG
anderewrey
pushed a commit
to anderewrey/grpc_reactor_routeguide
that referenced
this pull request
Oct 23, 2026
TSan, against a fully instrumented stack, reported a data race in every ClientReactorIntegrationTest: EventManager::processEvent() pushed onto the event queue and notified without holding m_mutex, while eventLoop() reads and pops that queue under it. A standalone reproducer using only EventLoop's public API, without gRPC, lost 433 to 553 wakeups per 20 000 events and segfaulted in 5 of 5 plain -O2 runs. The reactors call TriggerEvent() from gRPC's threads, so the application is exposed too, not only the tests. Upstream fixed it in amoldhamale1105/EventLoop#7: processEvent() and scheduleEvent() push under their loop's mutex, eventLoop() releases it while handlers run, so a handler calling TriggerEvent() cannot deadlock, and the shutdown flags are atomic and set under the mutexes. amoldhamale1105/EventLoop#5 then guarded the receivers' callback map, another race, and fixed restarting after Halt() and the destructor order. Pin ce1c71e, which carries both. The port also declared EventLoop MIT, but its LICENSE and source headers are LGPL 2.1 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019GqSK7yLMgqFy6jBsgiNqG
anderewrey
pushed a commit
to anderewrey/grpc_reactor_routeguide
that referenced
this pull request
Oct 23, 2026
TSan, against a fully instrumented stack, reported a data race in every ClientReactorIntegrationTest: EventManager::processEvent() pushed onto the event queue and notified without holding m_mutex, while eventLoop() reads and pops that queue under it. A standalone reproducer using only EventLoop's public API, without gRPC, lost 433 to 553 wakeups per 20 000 events and segfaulted in 5 of 5 plain -O2 runs. The reactors call TriggerEvent() from gRPC's threads, so the application is exposed too, not only the tests. Upstream fixed it in amoldhamale1105/EventLoop#7: processEvent() and scheduleEvent() push under their loop's mutex, eventLoop() releases it while handlers run, so a handler calling TriggerEvent() cannot deadlock, and the shutdown flags are atomic and set under the mutexes. amoldhamale1105/EventLoop#5 then guarded the receivers' callback map, another race, and fixed restarting after Halt() and the destructor order. Pin ce1c71e, which carries both. The port also declared EventLoop MIT, but its LICENSE and source headers are LGPL 2.1 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019GqSK7yLMgqFy6jBsgiNqG
anderewrey
pushed a commit
to anderewrey/grpc_reactor_routeguide
that referenced
this pull request
Oct 23, 2026
TSan, against a fully instrumented stack, reported a data race in every ClientReactorIntegrationTest: EventManager::processEvent() pushed onto the event queue and notified without holding m_mutex, while eventLoop() reads and pops that queue under it. A standalone reproducer using only EventLoop's public API, without gRPC, lost 433 to 553 wakeups per 20 000 events and segfaulted in 5 of 5 plain -O2 runs. The reactors call TriggerEvent() from gRPC's threads, so the application is exposed too, not only the tests. Upstream fixed it in amoldhamale1105/EventLoop#7: processEvent() and scheduleEvent() push under their loop's mutex, eventLoop() releases it while handlers run, so a handler calling TriggerEvent() cannot deadlock, and the shutdown flags are atomic and set under the mutexes. amoldhamale1105/EventLoop#5 then guarded the receivers' callback map, another race, and fixed restarting after Halt() and the destructor order. Pin ce1c71e, which carries both. The port also declared EventLoop MIT, but its LICENSE and source headers are LGPL 2.1 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019GqSK7yLMgqFy6jBsgiNqG
anderewrey
pushed a commit
to anderewrey/grpc_reactor_routeguide
that referenced
this pull request
Oct 23, 2026
TSan, against a fully instrumented stack, reported a data race in every ClientReactorIntegrationTest: EventManager::processEvent() pushed onto the event queue and notified without holding m_mutex, while eventLoop() reads and pops that queue under it. A standalone reproducer using only EventLoop's public API, without gRPC, lost 433 to 553 wakeups per 20 000 events and segfaulted in 5 of 5 plain -O2 runs. The reactors call TriggerEvent() from gRPC's threads, so the application is exposed too, not only the tests. Upstream fixed it in amoldhamale1105/EventLoop#7: processEvent() and scheduleEvent() push under their loop's mutex, eventLoop() releases it while handlers run, so a handler calling TriggerEvent() cannot deadlock, and the shutdown flags are atomic and set under the mutexes. amoldhamale1105/EventLoop#5 then guarded the receivers' callback map, another race, and fixed restarting after Halt() and the destructor order. Pin ce1c71e, which carries both. The port also declared EventLoop MIT, but its LICENSE and source headers are LGPL 2.1 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve coverage to 100% functions / ~89% lines and automate Windows coverage report
What this PR does
Builds on the test foundation from #4 to push coverage as high as the library's design permits, and adds automated coverage report generation on Windows via OpenCppCoverage.
Coverage results
These are defensive/safety net code paths — their presence is valuable for production robustness even if they cannot be exercised by unit tests.
build.shchangesThe
-tflag (test + coverage) now auto-detects the platform:lcov+genhtmlflow (unchanged)OpenCppCoverage, producing both an HTML report and a Cobertura XML report suitable for CIIf
OpenCppCoverageis not onPATH, the script prints a clear install instruction (winget install OpenCppCoverage) and exits gracefully instead of failing the build..gitignoreupdateAdded
CoverageReport-*/to ignore the timestamped report folders OpenCppCoverage generates in the working directory.