Add host unit test infrastructure with GoogleTest#59
Merged
Conversation
Set up an opt-in host test target (-DSENDSPIN_BUILD_TESTS=ON) that fetches GoogleTest via FetchContent and links the sendspin library, reaching its private headers for white-box testing. Add a CI job that builds and runs the suite under AddressSanitizer + UndefinedBehaviorSanitizer and gate merges on it. Exemplar tests cover the highest-value cross-platform logic: - protocol.cpp: enum round-trips, message-type dispatch, the tri-state metadata/color deltas, and the hand-rolled client/time int64 formatter checked against snprintf (including a 20k-iteration deterministic fuzz) - SendspinTimeFilter: monotonic-timestamp rejection, reset, offset round-trip, and convergence to a constant offset - AudioStreamInfo: byte/frame/sample/duration conversions, including a large-frame case pinning the frames_to_microseconds overflow fix
There was a problem hiding this comment.
Pull request overview
This PR introduces an opt-in host-side unit test target for the sendspin C++ library, using GoogleTest and integrating it into CI so core cross-platform logic can be validated (including under ASan/UBSan).
Changes:
- Adds a
sendspin_testsGoogleTest executable (enabled via-DSENDSPIN_BUILD_TESTS=ON) and atests/directory with initial white-box unit tests. - Adds unit tests covering protocol parsing/formatting, the time sync filter, and audio stream conversion utilities.
- Extends GitHub Actions CI to build and run the test suite under sanitizers and gate the aggregate CI job on it.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/test_time_filter.cpp |
Adds behavioral-invariant tests for SendspinTimeFilter (monotonic rejection, reset, convergence). |
tests/test_protocol.cpp |
Adds protocol-level JSON parsing/formatting tests, including round-trips and formatter oracle checks. |
tests/test_audio_stream_info.cpp |
Adds exact arithmetic tests for AudioStreamInfo conversions and equality behavior. |
tests/README.md |
Documents how to configure, build, and run the new host unit tests (including sanitizers). |
tests/CMakeLists.txt |
Defines the test executable, FetchContent GoogleTest setup, and CTest discovery. |
CMakeLists.txt |
Adds a top-level SENDSPIN_BUILD_TESTS option and hooks in the tests/ subdirectory for host builds. |
.github/workflows/ci.yml |
Adds a CI job that configures/builds/runs unit tests with sanitizers and gates the CI aggregator on it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Set up an opt-in host test target (
-DSENDSPIN_BUILD_TESTS=ON) that fetches GoogleTest via FetchContent and links the sendspin library, reaching its private headers for white-box testing. Add a CI job that builds and runs the suite under AddressSanitizer + UndefinedBehaviorSanitizer and gate merges on it.Exemple tests cover the highest-value cross-platform logic:
protocol.cpp:enum round-trips, message-type dispatch, the tri-state metadata/color deltas, and the hand-rolled client/time int64 formatter checked againstsnprintf(including a 20k-iteration deterministic fuzz)SendspinTimeFilter: monotonic-timestamp rejection, reset, offset round-trip, and convergence to a constant offsetAudioStreamInfo: byte/frame/sample/duration conversions, including a large-frame case pinning the frames_to_microseconds overflow fix