Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use serialized message directly #24

Merged
merged 21 commits into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
22e771d
Adapt new interface
Martin-Idel-SI Aug 10, 2018
ab73851
Try to write and read rcutils_char_array_t BLOBs in sqlite
botteroa-si Aug 10, 2018
b155060
Add simple test for arbitrary char ptr
Martin-Idel-SI Aug 14, 2018
79c1a3d
Refactor SqliteWrapper and add tests
botteroa-si Aug 14, 2018
3afe8bd
Write and read actual timestamp from serialized message and add relat…
botteroa-si Aug 14, 2018
b7831bd
Add SqliteStatementWrapper class and refactor SqliteStorage and Sqlit…
botteroa-si Aug 14, 2018
18f8c70
Refactor test fixture
botteroa-si Aug 16, 2018
94bf386
GH-50 Assert message content in write_integration_test, and remove TODOs
botteroa-si Aug 16, 2018
226740e
GH-50 Remove sqlite_storage_plugin unit tests
botteroa-si Aug 16, 2018
e2237ac
GH-50 Refactor SqliteStatements and SqliteStorage
botteroa-si Aug 17, 2018
114bdd9
GH-50 Make has_next() method no more const
botteroa-si Aug 21, 2018
0a23b29
GH-50 Fix build after rebase
botteroa-si Aug 21, 2018
e4ca9e9
GH-50 Refactor after rebase
botteroa-si Aug 22, 2018
f618390
GH-52 Extend statement wrapper with a generic bind
anhosi Aug 22, 2018
6074626
GH-59 cleanup db interface
anhosi Aug 22, 2018
96281bf
GH-59 Introduce general read interface for sqlite statements
anhosi Aug 23, 2018
d3061aa
GH-59 Cleanup: remove unused files
anhosi Aug 23, 2018
3ae2da8
GH-59 make sqlite interface fluent
anhosi Aug 24, 2018
179a1d9
GH-59 move creation of serialized message to rosbag2_storage
anhosi Aug 24, 2018
725bf95
Change rcutil_char_array_t to rmw_serialized_message_t in subscriber
Martin-Idel-SI Aug 28, 2018
45f1508
Remove debugging output in test
Martin-Idel-SI Aug 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor test fixture
  • Loading branch information
botteroa-si authored and Martin-Idel-SI committed Aug 30, 2018
commit 18f8c700fb8f9610b5ca42e9540397418150b978
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ TEST_F(StorageTestFixture, message_roundtrip_with_arbitrary_char_array_works_cor
delete[] test_message;
}


TEST_F(StorageTestFixture, has_next_return_false_if_there_are_no_more_messages) {
std::vector<std::pair<std::string, int64_t>> string_messages =
{std::make_pair("first message", 1), std::make_pair("second message", 2)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ class StorageTestFixture : public Test

std::shared_ptr<rcutils_char_array_t> make_serialized_message(std::string message)
{
int message_size = rcutils_snprintf(nullptr, 0,
"%c%c%c%c%c%c%c%c%s",
0x00, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
message.c_str());
int message_size = get_buffer_capacity(message);
message_size++; // need to account for terminating null character
assert(message_size > 0);

auto rcutils_allocator = rcutils_get_default_allocator();
auto msg = new rcutils_char_array_t;
Expand All @@ -116,11 +114,8 @@ class StorageTestFixture : public Test
});

serialized_data->buffer_length = message_size;
int written_size = rcutils_snprintf(serialized_data->buffer,
serialized_data->buffer_capacity,
"%c%c%c%c%c%c%c%c%s",
0x00, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
message.c_str());
int written_size = write_data_to_serialized_string_message(
serialized_data->buffer, serialized_data->buffer_capacity, message);

assert(written_size == message_size - 1); // terminated null character not counted
return serialized_data;
Expand Down Expand Up @@ -184,6 +179,23 @@ class StorageTestFixture : public Test
return read_messages;
}

protected:
int get_buffer_capacity(std::string message)
{
return write_data_to_serialized_string_message(nullptr, 0, message);
}

int write_data_to_serialized_string_message(
char * buffer, size_t buffer_capacity, std::string message)
{
return rcutils_snprintf(buffer,
buffer_capacity,
"%c%c%c%c%c%c%c%c%s",
0x00, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
message.c_str());
}

public:
std::string database_name_;
static std::string temporary_dir_path_;
};
Expand Down