From 7081a65595528a614ca811e0ce936b1f356830d6 Mon Sep 17 00:00:00 2001 From: Michael Orlov Date: Tue, 21 May 2024 14:09:20 -0700 Subject: [PATCH] Address flakiness in TestRosbag2CPPAPI::minimal_writer_example - The `serialized_msg2` is not owning the serialized data after the first call writer.write(serialized_msg2,..). i.e. need to use another message or another API in test for second call to writer.write(msg). Signed-off-by: Michael Orlov --- rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp b/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp index 982d46093..04b356215 100644 --- a/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp +++ b/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp @@ -106,9 +106,7 @@ TEST_P(TestRosbag2CPPAPI, minimal_writer_example) writer.open(rosbag_directory_next.string()); // write same topic to different bag - writer.write( - serialized_msg2, "/yet/another/topic", "test_msgs/msg/BasicTypes", - rclcpp::Clock().now()); + writer.write(bag_message, "/my/other/topic", "test_msgs/msg/BasicTypes"); // close by scope } @@ -152,7 +150,7 @@ TEST_P(TestRosbag2CPPAPI, minimal_writer_example) &extracted_serialized_msg, &extracted_test_msg); EXPECT_EQ(test_msg, extracted_test_msg); - EXPECT_EQ("/yet/another/topic", topic); + EXPECT_EQ("/my/other/topic", topic); } // alternative reader