test(core): expand coverage for unified_session_manager.cpp#1046
Merged
Conversation
Add tests/unit/unified_session_manager_extra_coverage_test.cpp covering the previously uncovered branches of src/core/unified_session_manager.cpp: - default-constructed manager configuration defaults - is_backpressure_active() short-circuit when enable_backpressure is false - get_utilization() divide-by-zero guard when max_sessions == 0 - add_session(session_handle, id) overload (pre-wrapped handle path) - add_session_with_id rejection / explicit id / collision / auto-generated - duplicate-id add_session not inflating total_accepted - update_activity and remove_session returning false on missing ids - cleanup_idle_sessions no-op when nothing is idle - stop_all_sessions / clear_all_sessions equivalence and reusability - for_each over empty manager (mutable + const) - generate_id uniqueness across threads - set_max_sessions narrowing below current count blocking accepts - full stats population including idle_timeout / backpressure_active - const get_session round-trip - total_cleaned_up accumulation across multiple cleanup invocations Register network_unified_session_manager_extra_coverage_test target in tests/CMakeLists.txt and document the addition in both CHANGELOG.md files. Closes #1034
Contributor
Coverage Report
Coverage DetailsFull HTML report is available as a build artifact. |
This was referenced Apr 26, 2026
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.
Closes #1034
What
Adds
tests/unit/unified_session_manager_extra_coverage_test.cpp—a new gtest binary that targets branches and edge cases of
src/core/unified_session_manager.cppnot exercised by the existingunified_session_manager_test.cpp.Why
Issue #1034 (part of #953) requires raising line coverage of
src/core/unified_session_manager.cppto >= 70% and branch coverageto >= 60%. The pre-Step-1 baseline reported 26.1% line coverage (2026-04-13).
The uncovered region concentrates in error and boundary paths — exactly
the surfaces that regress during the ongoing
Result<T>migration —so this PR fills in those paths with hermetic unit tests.
Where
src/core/unified_session_manager.cpptests/unit/unified_session_manager_extra_coverage_test.cpptests/CMakeLists.txt(registersnetwork_unified_session_manager_extra_coverage_testviaadd_network_test)CHANGELOG.mdanddocs/CHANGELOG.md(Tests / Added)How
New tests close the following previously-uncovered paths:
is_backpressure_active()short-circuit whenenable_backpressureis falseget_utilization()divide-by-zero guard whenmax_sessions == 0add_session(session_handle, id)overload (pre-wrapped handle path,both explicit id and auto-generated id branches)
add_session_with_idrejection at the limit / explicit id passthrough /collision returning empty / auto-generated id prefix
add_sessiondoes not inflatetotal_acceptedupdate_activityandremove_sessionreturning false on missing idscleanup_idle_sessionsno-op when nothing is idle (and on empty manager)stop_all_sessionsandclear_all_sessionsequivalence and reusabilityfor_eachover empty manager (mutable + const overloads)generate_iduniqueness across threads (4 threads x 200 ids each)set_max_sessionsnarrowing below current count blocks new acceptsand toggles backpressure
statspopulation includingidle_timeoutandbackpressure_activeget_sessionround-trip with type recoverytotal_cleaned_upaccumulation across multiple cleanup invocationsThe source under test is not modified. No source refactoring or seam
insertion was needed — all branches are reachable through the public API.
Tests are hermetic: no network, no filesystem, only short
sleep_forcalls(<= 50ms) for activity-driven cleanup paths, mirroring the existing
unified_session_manager_test.cppstyle.Test Plan
src/core/unified_session_manager.cppsrc/core/unified_session_manager.cppreaches >= 70% line / >= 60% branch
Notes
so the build was not verified locally; CI is the source of truth here.
network_tcp_socket_extra_coverage_testregistered for test: expand coverage for src/tcp_socket.cpp #1032.extra_tcp_session,extra_idle_session) live in ananonymous namespace inside the test TU and have local
session_traitsspecializations to avoid collisions with theexisting
test_tcp_session/test_idle_sessiontypes in thesibling test binary.