Skip to content

Add a publish-and-take test for rmw_take_sequence - #283

Open
xiao-yang25 wants to merge 2 commits into
ros2:rollingfrom
xiao-yang25:test/rmw-take-sequence
Open

Add a publish-and-take test for rmw_take_sequence#283
xiao-yang25 wants to merge 2 commits into
ros2:rollingfrom
xiao-yang25:test/rmw-take-sequence

Conversation

@xiao-yang25

Copy link
Copy Markdown

Summary

  • Expand the rmw_take_sequence test to publish and receive multiple messages.
  • Use BasicTypes sequence storage matching the subscription type instead of the previous Strings storage.
  • Publish three ordered messages and use a bounded wait-and-take loop to receive them.
  • Verify the number of messages taken, the message and metadata sequence sizes, and message ordering.
  • Retain the existing empty-subscription coverage.
  • Add scoped cleanup for the publisher, wait set, messages, and information sequences.

Testing

Tested commit: ba9916b

Environment:

  • Ubuntu 26.04 LTS
  • ARM64
  • ROS 2 Rolling
  • rmw_fastrtps_cpp

Commands:

colcon build --packages-up-to test_rmw_implementation

RMW_IMPLEMENTATION=rmw_fastrtps_cpp \
GTEST_FILTER=TestSubscriptionUse.take_sequence \
colcon test \
  --packages-select test_rmw_implementation \
  --ctest-args -R '^test_subscription__' --output-on-failure

colcon test-result --verbose

Result:

Summary: 2 tests, 0 errors, 0 failures, 0 skipped

Fixes #176

Signed-off-by: xiaoyang <xy1453417528@gmail.com>
@mergify

mergify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

}
total_taken += taken;
}
EXPECT_EQ(message_count, total_taken);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we add more info here? e.g., how many were taken before timing out. this would make CI flake triage much easier.

Comment on lines +750 to +754
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
{
EXPECT_EQ(
RMW_RET_OK, rmw_message_sequence_fini(&sequence)) << rmw_get_error_string().str;
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this ordering leaves dangling pointers in sequence.data? test_msgs__msg__BasicTypes__Sequence__destroy(seq) runs before rmw_message_sequence_fini(&sequence), meaning the fini runs while sequence.data[i] are dangling?

sub, message_count, &sequence, &info_sequence, &taken, null_allocation);
ASSERT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
ASSERT_EQ(taken, sequence.size);
ASSERT_EQ(taken, info_sequence.size);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we can inspect more entries as proper test? it would meaningfully strengthen the test to check, e.g., that info_sequence.data[i].publisher_gid matches the publisher.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed all three review comments in 1ba23ba:

  • The final assertion now reports both total_taken and message_count when the deadline is reached, making CI timeout failures easier to diagnose.
  • The cleanup order now ensures that rmw_message_sequence_fini(&sequence) runs before the backing message sequence is destroyed, so sequence.data does not contain dangling pointers during finalization.
  • The test now obtains the publisher GID with rmw_get_gid_for_publisher() and verifies it against every entry returned in info_sequence.

Signed-off-by: xiaoyang <xy1453417528@gmail.com>
@xiao-yang25
xiao-yang25 requested a review from fujitatomoya July 28, 2026 14:34
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.

Write a proper rmw_take_sequence test

3 participants