Skip to content

Add test_rosidl_buffer for testing rosidl::Buffer features#591

Open
nvcyc wants to merge 1 commit intorollingfrom
nvcyc/test_rosidl_buffer
Open

Add test_rosidl_buffer for testing rosidl::Buffer features#591
nvcyc wants to merge 1 commit intorollingfrom
nvcyc/test_rosidl_buffer

Conversation

@nvcyc
Copy link
Copy Markdown

@nvcyc nvcyc commented Apr 21, 2026

Description

Adds a new test_rosidl_buffer system test package that exercises the rosidl_buffer / rosidl_buffer_backend feature end-to-end. It validates the BufferBackend contract with a minimal in-tree backend plugin and covers critical transport scenarios over rmw_fastrtps_cpp that has full buffer-backend support today.

Layout under src/ros2/system_tests/test_rosidl_buffer/:

  • msg/TestBufferDescriptor.msg, msg/ByteArray.msg — descriptor and payload messages generated via rosidl_generate_interfaces.
  • include/test_rosidl_buffer/test_buffer_impl.hpp — header-only TestBufferImpl<T> (a BufferImplBase<T> subclass) with a process-wide atomic counter of to_cpu() invocations.
  • src/test_buffer_backend_plugin.cpp + test_buffer_plugin.xmlTestBufferBackend pluginlib plugin exported for discovery at runtime.
  • src/test_backend_publisher.cpp / src/test_backend_subscriber.cpp — parameterised pub/sub executables used by the launch tests.
  • test/test_buffer_backend_unit.cpp — standalone gtest for the backend contract (no RMW involved).
  • test/test_test_to_test_fastrtps.py, test/test_test_to_cpu_fastrtps.py — launch tests.

What the tests prove:

  • test to test (acceptable_buffer_backends=any on the subscriber): the subscriber observes get_backend_type() == "test", and the publisher's TestBufferImpl::to_cpu() counter stays at 0. Together these prove the RMW uses TestBufferBackend::create_descriptor_with_endpointfrom_descriptor_with_endpoint and never falls back to CPU serialization on the publisher side.
  • test to cpu (default subscriber options, i.e. acceptable_buffer_backends="cpu"): the publisher sees a CPU-only peer in on_discovering_endpoint, create_descriptor_with_endpoint returns nullptr, the RMW falls back to CPU, and the subscriber observes get_backend_type() == "cpu" with byte-exact content.

RMW gating is done at CMake time via an allowlist (_buffer_backend_capable_rmws = rmw_fastrtps_cpp) wrapped inside a get_available_rmw_implementations loop, plus RMW_IMPLEMENTATION / RCL_ASSERT_RMW_ID_MATCHES env vars in each launch description so a mismatched RMW fails loudly. The unit gtest is registered unconditionally since it does not touch any RMW. Additional backends can be supported later by just appending to the allowlist.

Is this user-facing behavior change?

No. This only adds test coverage for the existing rosidl_buffer / rosidl_buffer_backend feature.

Did you use Generative AI?

Yes. Cursor with Claude Opus 4.7 was used to assist with the draft version of the changes included in this pull request.

Signed-off-by: CY Chen <cyc@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant