-
Notifications
You must be signed in to change notification settings - Fork 294
Open
Labels
bugSomething isn't workingSomething isn't workingmore-information-neededFurther information is requiredFurther information is required
Description
Description
When opening storage using StorageFactory::open_read_write(), if the storage_options.uri passed in is an empty string, the current implementation does not throw an exception. Instead, it interprets the empty path as "." and continues to open the storage plugin normally.
Expected Behavior
Throws an exception when the string is empty
Actual Behavior
No exception thrown
To Reproduce
Test Case
#include <gtest/gtest.h>
#include <memory>
#include <string>
#include "rosbag2_storage/storage_interfaces/read_only_interface.hpp"
#include "rosbag2_storage/storage_interfaces/read_write_interface.hpp"
#include "rosbag2_storage/storage_factory.hpp"
#include "test_constants.hpp"
using rosbag2_storage::storage_interfaces::ReadWriteInterface;
using rosbag2_storage::storage_interfaces::ReadOnlyInterface;
// The fixture for testing class Foo.
class StorageFactoryTest : public ::testing::Test
{
public:
rosbag2_storage::StorageFactory factory;
std::string bag_file_path = "path/to/be/loaded.bag";
std::string test_unavailable_plugin_id = "my_unavailable_plugin";
};
TEST_F(StorageFactoryTest, test) {
EXPECT_THROW(
factory.open_read_write({"", test_constants::READ_WRITE_PLUGIN_IDENTIFIER}),
std::runtime_error);
}Output
RUN ] StorageFactoryTest.test
opening testplugin read write: storage uri: .
config file uri: .
closing.
/home/shangzh/rosbag2_ws/rosbag2/rosbag2_storage/test/rosbag2_storage/test_storage_factory.cpp:22: Failure
Expected: factory.open_read_write({"", test_constants::READ_WRITE_PLUGIN_IDENTIFIER}) throws an exception of type std::runtime_error.
Actual: it throws nothing.
[ FAILED ] StorageFactoryTest.test (19 ms)
[----------] 1 test from StorageFactoryTest (19 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (19 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] StorageFactoryTest.test
1 FAILED TEST
System (please complete the following information)
OS: ubuntu 24.04
ROS 2 Distro: ros 2 jazzy
Install Method: source
Version: ros 2 jazzy
build options: --mixin asan-gcc
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmore-information-neededFurther information is requiredFurther information is required