2019-05-31 16:07:11 +02:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
project(tracetools_test)
|
|
|
|
|
|
|
|
# Default to C++14
|
|
|
|
if(NOT CMAKE_CXX_STANDARD)
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2019-07-05 12:52:03 +02:00
|
|
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
2019-05-31 16:07:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(ament_cmake REQUIRED)
|
|
|
|
|
2019-07-25 09:03:29 +02:00
|
|
|
option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" OFF)
|
|
|
|
if(NOT TRACETOOLS_DISABLED)
|
2019-07-25 09:30:46 +02:00
|
|
|
# Set TRACING_ENABLED if we can find lttng-ust
|
2019-07-19 10:02:56 +02:00
|
|
|
find_package(PkgConfig)
|
|
|
|
if(PkgConfig_FOUND)
|
|
|
|
pkg_check_modules(LTTNG lttng-ust)
|
|
|
|
if(LTTNG_FOUND)
|
|
|
|
set(TRACING_ENABLED TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2019-07-12 10:06:52 +02:00
|
|
|
|
2019-05-31 16:07:11 +02:00
|
|
|
# Tests
|
|
|
|
if(BUILD_TESTING)
|
2019-06-04 13:51:56 +02:00
|
|
|
find_package(rclcpp REQUIRED)
|
|
|
|
find_package(std_msgs REQUIRED)
|
|
|
|
find_package(std_srvs REQUIRED)
|
2019-06-17 14:08:59 +00:00
|
|
|
find_package(tracetools REQUIRED)
|
2019-06-04 13:51:56 +02:00
|
|
|
|
2019-08-02 13:35:44 +02:00
|
|
|
# Avoid using -rdynamic on Windows
|
|
|
|
if(NOT WIN32)
|
|
|
|
set(RDYNAMIC_FLAG "-rdynamic")
|
|
|
|
else()
|
|
|
|
set(RDYNAMIC_FLAG "")
|
|
|
|
endif()
|
|
|
|
|
2019-05-31 16:07:11 +02:00
|
|
|
add_executable(test_publisher
|
2019-06-03 10:02:03 +02:00
|
|
|
src/test_publisher.cpp
|
2019-05-31 16:07:11 +02:00
|
|
|
)
|
|
|
|
ament_target_dependencies(test_publisher
|
|
|
|
rclcpp
|
|
|
|
std_msgs
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-05-31 16:07:11 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_publisher "${RDYNAMIC_FLAG}")
|
2019-06-19 16:44:37 +02:00
|
|
|
add_executable(test_intra
|
|
|
|
src/test_intra.cpp
|
|
|
|
)
|
|
|
|
ament_target_dependencies(test_intra
|
|
|
|
rclcpp
|
|
|
|
std_msgs
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-06-19 16:44:37 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_intra "${RDYNAMIC_FLAG}")
|
2019-06-03 11:16:05 +02:00
|
|
|
add_executable(test_ping
|
|
|
|
src/test_ping.cpp
|
|
|
|
)
|
|
|
|
ament_target_dependencies(test_ping
|
|
|
|
rclcpp
|
|
|
|
std_msgs
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-06-03 11:16:05 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_ping "${RDYNAMIC_FLAG}")
|
2019-06-03 11:16:05 +02:00
|
|
|
add_executable(test_pong
|
|
|
|
src/test_pong.cpp
|
|
|
|
)
|
|
|
|
ament_target_dependencies(test_pong
|
|
|
|
rclcpp
|
|
|
|
std_msgs
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-06-03 11:16:05 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_pong "${RDYNAMIC_FLAG}")
|
2019-06-03 11:36:16 +02:00
|
|
|
add_executable(test_timer
|
|
|
|
src/test_timer.cpp
|
|
|
|
)
|
|
|
|
ament_target_dependencies(test_timer
|
|
|
|
rclcpp
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-06-03 11:36:16 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_timer "${RDYNAMIC_FLAG}")
|
2019-06-03 11:57:19 +02:00
|
|
|
add_executable(test_service
|
|
|
|
src/test_service.cpp
|
|
|
|
)
|
|
|
|
ament_target_dependencies(test_service
|
|
|
|
rclcpp
|
|
|
|
std_srvs
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-06-03 11:57:19 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_service "${RDYNAMIC_FLAG}")
|
2019-06-03 13:05:05 +02:00
|
|
|
add_executable(test_service_ping
|
|
|
|
src/test_service_ping.cpp
|
|
|
|
)
|
|
|
|
ament_target_dependencies(test_service_ping
|
|
|
|
rclcpp
|
|
|
|
std_srvs
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-06-03 13:05:05 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_service_ping "${RDYNAMIC_FLAG}")
|
2019-06-03 13:05:05 +02:00
|
|
|
add_executable(test_service_pong
|
|
|
|
src/test_service_pong.cpp
|
|
|
|
)
|
|
|
|
ament_target_dependencies(test_service_pong
|
|
|
|
rclcpp
|
|
|
|
std_srvs
|
2019-07-03 15:22:04 +02:00
|
|
|
tracetools
|
2019-06-03 13:05:05 +02:00
|
|
|
)
|
2019-08-02 13:35:44 +02:00
|
|
|
target_link_libraries(test_service_pong "${RDYNAMIC_FLAG}")
|
2019-05-31 16:43:04 +02:00
|
|
|
|
2019-05-31 16:07:11 +02:00
|
|
|
install(TARGETS
|
2019-06-19 16:44:37 +02:00
|
|
|
test_intra
|
2019-06-03 11:16:05 +02:00
|
|
|
test_ping
|
|
|
|
test_pong
|
2019-06-19 16:44:37 +02:00
|
|
|
test_publisher
|
2019-06-03 11:57:19 +02:00
|
|
|
test_service
|
2019-06-03 13:05:05 +02:00
|
|
|
test_service_ping
|
|
|
|
test_service_pong
|
2019-06-19 16:44:37 +02:00
|
|
|
test_timer
|
2019-05-31 16:07:11 +02:00
|
|
|
DESTINATION lib/${PROJECT_NAME}
|
|
|
|
)
|
|
|
|
|
2019-06-04 13:53:05 +02:00
|
|
|
find_package(ament_lint_auto REQUIRED)
|
|
|
|
ament_lint_auto_find_test_dependencies()
|
|
|
|
|
2019-07-12 10:06:52 +02:00
|
|
|
# Only build tracing tests if LTTng is enabled and found
|
2019-07-19 10:02:56 +02:00
|
|
|
if(TRACING_ENABLED)
|
|
|
|
find_package(ament_cmake_pytest REQUIRED)
|
2019-07-12 10:06:52 +02:00
|
|
|
|
2019-07-19 10:02:56 +02:00
|
|
|
# Run each test in its own pytest invocation
|
|
|
|
set(_tracetools_test_pytest_tests
|
2019-11-12 18:06:42 -08:00
|
|
|
test/test_intra.py
|
2019-07-19 10:02:56 +02:00
|
|
|
test/test_node.py
|
|
|
|
test/test_publisher.py
|
|
|
|
test/test_service.py
|
|
|
|
test/test_service_callback.py
|
|
|
|
test/test_subscription.py
|
|
|
|
test/test_timer.py
|
2019-07-25 09:16:23 +02:00
|
|
|
)
|
2019-05-31 16:07:11 +02:00
|
|
|
|
2019-07-19 10:02:56 +02:00
|
|
|
foreach(_test_path ${_tracetools_test_pytest_tests})
|
|
|
|
get_filename_component(_test_name ${_test_path} NAME_WE)
|
|
|
|
ament_add_pytest_test(${_test_name} ${_test_path}
|
|
|
|
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
|
|
|
|
APPEND_ENV AMENT_PREFIX_PATH=${ament_index_build_path}
|
|
|
|
PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
TIMEOUT 60
|
2019-07-25 09:16:23 +02:00
|
|
|
)
|
2019-07-19 10:02:56 +02:00
|
|
|
endforeach()
|
2019-07-12 10:06:52 +02:00
|
|
|
endif()
|
2019-05-31 16:07:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
ament_package()
|