Skip to content

Add host unit test infrastructure with GoogleTest#59

Merged
kahrendt merged 3 commits into
mainfrom
add-unit-test-infrastructure
May 21, 2026
Merged

Add host unit test infrastructure with GoogleTest#59
kahrendt merged 3 commits into
mainfrom
add-unit-test-infrastructure

Conversation

@kahrendt
Copy link
Copy Markdown
Contributor

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 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

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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_tests GoogleTest executable (enabled via -DSENDSPIN_BUILD_TESTS=ON) and a tests/ 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.

Comment thread CMakeLists.txt
@kahrendt kahrendt enabled auto-merge (squash) May 21, 2026 17:45
@kahrendt kahrendt merged commit e3a48ae into main May 21, 2026
5 checks passed
@kahrendt kahrendt deleted the add-unit-test-infrastructure branch May 21, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants