|
14 | 14 |
|
15 | 15 | #include <gmock/gmock.h> |
16 | 16 |
|
| 17 | +#include <filesystem> |
17 | 18 | #include <memory> |
18 | 19 | #include <string> |
19 | 20 | #include <unordered_map> |
20 | 21 | #include <utility> |
21 | 22 | #include <vector> |
22 | 23 |
|
| 24 | +#include "mock_recorder.hpp" |
23 | 25 | #include "rclcpp/rclcpp.hpp" |
| 26 | +#include "rcpputils/scope_exit.hpp" |
24 | 27 |
|
25 | 28 | #include "rosbag2_test_common/publication_manager.hpp" |
26 | 29 | #include "rosbag2_test_common/wait_for.hpp" |
| 30 | +#include "rosbag2_test_common/temporary_directory_fixture.hpp" |
27 | 31 |
|
28 | 32 | #include "rosbag2_transport/recorder.hpp" |
29 | 33 |
|
|
33 | 37 |
|
34 | 38 | #include "rosbag2_storage/qos.hpp" |
35 | 39 | #include "record_integration_fixture.hpp" |
| 40 | +#include "rosbag2_transport/reader_writer_factory.hpp" |
| 41 | + |
| 42 | +using namespace ::testing; // NOLINT |
| 43 | +using rosbag2_test_common::TemporaryDirectoryFixture; |
| 44 | +namespace fs = std::filesystem; |
36 | 45 |
|
37 | 46 | TEST_F(RecordIntegrationTestFixture, published_messages_from_multiple_topics_are_recorded) |
38 | 47 | { |
@@ -125,6 +134,33 @@ TEST_F(RecordIntegrationTestFixture, published_messages_from_multiple_topics_are |
125 | 134 | } |
126 | 135 | } |
127 | 136 |
|
| 137 | +TEST_F(TemporaryDirectoryFixture, can_record_again_after_stop_with_real_storage) { |
| 138 | + rclcpp::init(0, nullptr); |
| 139 | + auto cleanup_process_handle = rcpputils::make_scope_exit([&]() {rclcpp::shutdown();}); |
| 140 | + std::string test_topic = "/can_record_again_after_stop_topic"; |
| 141 | + rosbag2_storage::StorageOptions storage_options{}; |
| 142 | + storage_options.uri = (fs::path(temporary_dir_path_) / "start_stop_again").generic_string(); |
| 143 | + |
| 144 | + rosbag2_transport::RecordOptions record_options{}; |
| 145 | + |
| 146 | + auto writer = rosbag2_transport::ReaderWriterFactory::make_writer(record_options); |
| 147 | + { |
| 148 | + auto recorder = std::make_shared<MockRecorder>( |
| 149 | + std::move(writer), storage_options, record_options); |
| 150 | + |
| 151 | + EXPECT_NO_THROW(recorder->record()); |
| 152 | + fs::path storage_path(storage_options.uri); |
| 153 | + EXPECT_TRUE(fs::is_directory(storage_path)); |
| 154 | + |
| 155 | + EXPECT_NO_THROW(recorder->stop()); |
| 156 | + EXPECT_NO_THROW(recorder->record()); |
| 157 | + storage_path = recorder->get_storage_options().uri; |
| 158 | + EXPECT_TRUE(fs::is_directory(storage_path)); |
| 159 | + std::string expected_path_str = storage_options.uri + "(1)"; |
| 160 | + EXPECT_EQ(storage_path.generic_string(), expected_path_str); |
| 161 | + } |
| 162 | +} |
| 163 | + |
128 | 164 | TEST_F(RecordIntegrationTestFixture, can_record_again_after_stop) |
129 | 165 | { |
130 | 166 | GTEST_SKIP() << "Skipping test `can_record_again_after_stop` in rosbag2_transport, until " |
|
0 commit comments