Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions test_communication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,37 @@ if(BUILD_TESTING)
"rclcpp${target_suffix}")
endfunction()

function(custom_test_c target)
# get typesupport of rmw implementation to include / link against the corresponding interfaces
get_rmw_typesupport(typesupport_impls "${rmw_implementation}" LANGUAGE "c")

ament_add_gtest(
"${target}${target_suffix}" ${ARGN}
TIMEOUT 90
ENV RCL_ASSERT_RMW_ID_MATCHES=${rmw_implementation})
target_link_libraries(${target}${target_suffix}
${_AMENT_EXPORT_ABSOLUTE_LIBRARIES}
${_AMENT_EXPORT_LIBRARY_TARGETS})
add_dependencies(${target}${target_suffix} ${PROJECT_NAME})
foreach(typesupport_impl ${typesupport_impls})
rosidl_target_interfaces(${target}${target_suffix}
${PROJECT_NAME} ${typesupport_impl})
endforeach()
rosidl_target_interfaces(${target}${target_suffix}
${PROJECT_NAME} rosidl_generator_c)
ament_target_dependencies(${target}${target_suffix}
"rcl${target_suffix}")
get_target_property(target_path ${target}${target_suffix}
RUNTIME_OUTPUT_DIRECTORY)
if(NOT target_path)
set(target_path "${CMAKE_CURRENT_BINARY_DIR}")
endif()
set_tests_properties(
${target}${target_suffix}
PROPERTIES REQUIRED_FILES "${target_path}/${target}${target_suffix}"
)
endfunction()

macro(multi_targets)
# test publish / subscribe messages
if(rmw_implementation1 STREQUAL rmw_implementation2)
Expand Down Expand Up @@ -244,6 +275,10 @@ if(BUILD_TESTING)
endmacro()

macro(targets)
get_rcl_information("${rmw_implementation}" "rcl${target_suffix}")
custom_test_c(test_messages_c
"test/test_messages_c.cpp")

get_rclcpp_information("${rmw_implementation}" "rclcpp${target_suffix}")

# publisher combined with a subscriber
Expand Down
2 changes: 2 additions & 0 deletions test_communication/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_cmake_nose</test_depend>
<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>builtin_interfaces</test_depend>
<test_depend>launch</test_depend>
<test_depend>rcl</test_depend>
<test_depend>rclcpp</test_depend>
<test_depend>rclpy</test_depend>
<test_depend>rmw_implementation</test_depend>
Expand Down
Loading