Skip to content

Commit

Permalink
Fix for regression in open_succeeds_twice and `minimal_writer_examp…
Browse files Browse the repository at this point in the history
…le` tests (#1667) (#1675)

* Use test-specific temp subfolder to avoid leftovers from previous run

Signed-off-by: Michael Orlov <[email protected]>

* 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 <[email protected]>

---------

Signed-off-by: Michael Orlov <[email protected]>
(cherry picked from commit 8523995)

Co-authored-by: Michael Orlov <[email protected]>
  • Loading branch information
mergify[bot] and MichaelOrlov authored May 24, 2024
1 parent 353fe59 commit 3840224
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ TEST_F(SequentialCompressionWriterTest, open_succeeds_on_supported_compression_f
kDefaultCompressionQueueThreadsPriority};
initializeWriter(compression_options);

auto tmp_dir = fs::temp_directory_path() / "path_not_empty";
auto tmp_dir = tmp_dir_ / "path_not_empty";
auto storage_options = rosbag2_storage::StorageOptions();
storage_options.uri = tmp_dir.string();

Expand All @@ -230,8 +230,8 @@ TEST_F(SequentialCompressionWriterTest, open_succeeds_twice)
kDefaultCompressionQueueThreadsPriority};
initializeWriter(compression_options);

auto tmp_dir = fs::temp_directory_path() / "path_not_empty";
auto tmp_dir_next = fs::temp_directory_path() / "path_not_empty_next";
auto tmp_dir = tmp_dir_ / "path_not_empty";
auto tmp_dir_next = tmp_dir_ / "path_not_empty_next";

auto storage_options = rosbag2_storage::StorageOptions();
auto storage_options_next = rosbag2_storage::StorageOptions();
Expand Down
6 changes: 2 additions & 4 deletions rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,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
}
Expand Down Expand Up @@ -154,7 +152,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
Expand Down

0 comments on commit 3840224

Please sign in to comment.