Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Karsten1987 committed Jun 12, 2018
1 parent 3a5db3a commit f280ce6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
20 changes: 12 additions & 8 deletions test_communication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,19 @@ if(BUILD_TESTING)
endif()

macro(serialize)
set(serialize_target_name "test_serialize${target}${target_suffix}")
ament_add_gtest(
set(serialize_target_name "test_serialize${target}${target_suffix}")
ament_add_gtest(
${serialize_target_name} test/test_message_serialization.cpp
TIMEOUT 30
ENV
RCL_ASSERT_RMW_ID_MATCHES=${rmw_implementation}
RMW_IMPLEMENTATION=${rmw_implementation})
RMW_IMPLEMENTATION=${rmw_implementation}
)
if(TARGET ${serialize_target_name})
target_link_libraries(${serialize_target_name}
${_AMENT_EXPORT_ABSOLUTE_LIBRARIES}
${_AMENT_EXPORT_LIBRARY_TARGETS})
${_AMENT_EXPORT_LIBRARY_TARGETS}
)
add_dependencies(${serialize_target_name} ${PROJECT_NAME})
ament_target_dependencies(${serialize_target_name}
"rmw"
Expand All @@ -338,17 +340,19 @@ if(BUILD_TESTING)
endmacro()

macro(pub_sub_raw)
set(target_name "test_publisher_subscriber_raw${target}${target_suffix}")
ament_add_gtest(
set(target_name "test_publisher_subscriber_raw${target}${target_suffix}")
ament_add_gtest(
${target_name} test/test_publisher_subscriber_raw.cpp
TIMEOUT 30
ENV
RCL_ASSERT_RMW_ID_MATCHES=${rmw_implementation}
RMW_IMPLEMENTATION=${rmw_implementation})
RMW_IMPLEMENTATION=${rmw_implementation}
)
if(TARGET ${target_name})
target_link_libraries(${target_name}
${_AMENT_EXPORT_ABSOLUTE_LIBRARIES}
${_AMENT_EXPORT_LIBRARY_TARGETS})
${_AMENT_EXPORT_LIBRARY_TARGETS}
)
add_dependencies(${target_name} ${PROJECT_NAME})
ament_target_dependencies(${target_name}
"rclcpp"
Expand Down
11 changes: 5 additions & 6 deletions test_communication/test/test_message_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ TEST_F(CLASSNAME(TestMessageSerialization, RMW_IMPLEMENTATION), de_serialize_c)
auto allocator = rcutils_get_default_allocator();

auto raw_message_c = rmw_get_zero_initialized_raw_message();
rmw_initialize_raw_message(&raw_message_c, 0, &allocator);
rmw_raw_message_init(&raw_message_c, 0, &allocator);

auto message_c_typesupport = ROSIDL_GET_MSG_TYPE_SUPPORT(test_msgs, msg, BoundedArrayNested);
test_msgs__msg__BoundedArrayNested bounded_array_nested_msg_c;
fill_c_message(&bounded_array_nested_msg_c);

auto ret = RMW_RET_OK;
ret =
rmw_serialize(&bounded_array_nested_msg_c, message_c_typesupport, &raw_message_c);
ret = rmw_serialize(&bounded_array_nested_msg_c, message_c_typesupport, &raw_message_c);
EXPECT_EQ(RMW_RET_OK, ret);
EXPECT_EQ(76u, raw_message_c.buffer_length); // measured from wireshark

Expand Down Expand Up @@ -142,7 +141,7 @@ TEST_F(CLASSNAME(TestMessageSerialization, RMW_IMPLEMENTATION), de_serialize_cpp
auto allocator = rcutils_get_default_allocator();

auto raw_message_cpp = rmw_get_zero_initialized_raw_message();
rmw_initialize_raw_message(&raw_message_cpp, 0, &allocator);
rmw_raw_message_init(&raw_message_cpp, 0, &allocator);

auto message_cpp_typesupport =
rosidl_typesupport_cpp::get_message_type_support_handle<test_msgs::msg::BoundedArrayNested>();
Expand Down Expand Up @@ -184,10 +183,10 @@ TEST_F(CLASSNAME(TestMessageSerialization, RMW_IMPLEMENTATION), cdr_integrity) {
auto allocator = rcutils_get_default_allocator();

auto raw_message_c = rmw_get_zero_initialized_raw_message();
rmw_initialize_raw_message(&raw_message_c, 0, &allocator);
rmw_raw_message_init(&raw_message_c, 0, &allocator);

auto raw_message_cpp = rmw_get_zero_initialized_raw_message();
rmw_initialize_raw_message(&raw_message_cpp, 0, &allocator);
rmw_raw_message_init(&raw_message_cpp, 0, &allocator);

auto message_c_typesupport = ROSIDL_GET_MSG_TYPE_SUPPORT(test_msgs, msg, BoundedArrayNested);
auto message_cpp_typesupport =
Expand Down
1 change: 1 addition & 0 deletions test_communication/test/test_publisher_subscriber_raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ TEST_F(CLASSNAME(TestMessageSerialization, RMW_IMPLEMENTATION), raw_callback) {
rclcpp::spin_some(node);
loop_rate.sleep();
}
EXPECT_GT(counter, 0u);
}

0 comments on commit f280ce6

Please sign in to comment.