test: split unit_tests.cpp with TCP messaging fixture#1092
Merged
Conversation
Replace the 962-line monolithic tests/unit_tests.cpp with per-concern test
executables under tests/unit/ and tests/stress/, all backed by a shared
messaging_loopback_fixture in tests/support/ that requests an OS-assigned
ephemeral TCP port for every test. This removes the port-collision risk
that previously forced suite-level test registration to be commented out.
* tests/support/messaging_loopback_fixture.{h,cpp}:
- Free functions pick_ephemeral_port() and wait_for_ready() plus the
is_sanitizer_run() guard the legacy fixture used.
- Trivial messaging_loopback_fixture base derived from ::testing::Test
so tests can pick the helper they need.
- Distinct from hermetic_transport_fixture, which is wired for HTTP/2,
gRPC, QUIC, and WebSocket peers (TLS-bearing).
* tests/unit/messaging_server_lifecycle_test.cpp: ServerConstruction,
ServerStartStop, ServerMultipleStartStop, ServerPortAlreadyInUse,
DoubleStartReturnsAlreadyExistsError.
* tests/unit/messaging_client_lifecycle_test.cpp: ClientConstruction,
ClientConnectToNonExistentServer, ClientServerBasicConnection,
MultipleClientsConnection, SendWithoutConnection.
* tests/unit/messaging_transfer_test.cpp: BasicMessageTransfer,
LargeMessageTransfer, MultipleMessageTransfer.
* tests/unit/messaging_server_session_test.cpp: ServerStopWhileClientsConnected,
CleanupDeadSessionsOnNewConnection, WaitForStopIsCallableWhileRunning,
WaitForStopOnNonRunningServerReturnsImmediately. Named with the
messaging_server_session_ prefix to avoid colliding with the existing
tests/unit/messaging_session_test.cpp which targets messaging_session.
* tests/unit/messaging_id_test.cpp: ServerIdReturnsConstructorValue,
ServerIdEmptyStringIsValid, SetAndGetMonitor.
* tests/stress/messaging_stress_test.cpp: NetworkStressTest.RapidConnection-
Disconnection and NetworkStressTest.ConcurrentClients, kept as bare TEST()
cases so the original test names survive.
* tests/CMakeLists.txt: introduce a network_add_messaging_test() helper that
links network::test_support and inherits the optional WITH_* defines the
legacy network_unit_tests target carried, then registers the six new
executables one per file. Each one calls add_test (via gtest_discover_tests)
because the ephemeral fixture removes the parallel-port conflict.
* tests/support/CMakeLists.txt: include messaging_loopback_fixture.cpp in
the network_test_support archive.
* scripts/build.sh: switch the test step to ctest now that there is no
single network_unit_tests binary.
Closes #1088
Contributor
Coverage Report
Coverage DetailsFull HTML report is available as a build artifact. |
This was referenced May 1, 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 #1088
Summary
Test Plan