From 3542aab98430e55b3db4784735c5380da4b3d75a Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 12 Jul 2019 10:06:52 +0200 Subject: [PATCH 1/3] Only build and run tracing tests if LTTng is enabled and found --- colcon.meta | 5 ++++ tracetools/CMakeLists.txt | 9 ++++-- tracetools_test/CMakeLists.txt | 53 ++++++++++++++++++++-------------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/colcon.meta b/colcon.meta index bd5a97b..d5559d4 100644 --- a/colcon.meta +++ b/colcon.meta @@ -5,5 +5,10 @@ "-DWITH_LTTNG=ON", ], }, + "tracetools_test": { + "cmake-args": [ + "-DWITH_LTTNG=ON", + ], + }, }, } diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index f07af0b..8c85a14 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -91,9 +91,12 @@ if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() - ament_add_gtest(test_utils test/test_utils.cpp) - if(TARGET test_utils) - target_link_libraries(test_utils ${PROJECT_NAME} -rdynamic) + # Only build tracetools utils tests if LTTng is enabled and found + if(TRACETOOLS_LTTNG_ENABLED) + ament_add_gtest(test_utils test/test_utils.cpp) + if(TARGET test_utils) + target_link_libraries(test_utils ${PROJECT_NAME} -rdynamic) + endif() endif() endif() diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index aeaf7c7..e383cd6 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -12,6 +12,8 @@ endif() find_package(ament_cmake REQUIRED) +option(WITH_LTTNG "Include support for tracing with LTTng" OFF) + # Tests if(BUILD_TESTING) find_package(rclcpp REQUIRED) @@ -116,29 +118,38 @@ if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() - find_package(ament_cmake_pytest REQUIRED) + # Only build tracing tests if LTTng is enabled and found + if(WITH_LTTNG) + find_package(PkgConfig REQUIRED) + pkg_check_modules(LTTNG REQUIRED lttng-ust) + if(LTTNG_FOUND) + message("LTTng found: tracing tests enabled") - # Run each test in its own pytest invocation - set(_tracetools_test_pytest_tests - test/test_intra.py - test/test_node.py - test/test_publisher.py - test/test_service.py - test/test_service_callback.py - test/test_subscription.py - test/test_subscription_callback.py - test/test_timer.py - ) + find_package(ament_cmake_pytest REQUIRED) - 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 - ) - endforeach() + # Run each test in its own pytest invocation + set(_tracetools_test_pytest_tests + test/test_intra.py + test/test_node.py + test/test_publisher.py + test/test_service.py + test/test_service_callback.py + test/test_subscription.py + test/test_subscription_callback.py + test/test_timer.py + ) + + 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 + ) + endforeach() + endif() + endif() endif() ament_package() From 169a7ef048f0da76776d60f84c65eb19a8b81ae2 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 12 Jul 2019 10:20:08 +0200 Subject: [PATCH 2/3] Create a CI build job without LTTng --- .gitlab-ci.yml | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 666e3a6..24ae517 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,23 +3,35 @@ variables: PACKAGES_LIST: ros2trace tracetools tracetools_launch tracetools_read tracetools_test tracetools_trace base_image_id: registry.gitlab.com/micro-ros/ros_tracing/ci_base +image: $base_image_id + +before_script: + - vcs import < instrumentation.repos + - rosdep install --from-paths . -i . -i /root/ws --rosdistro dashing -y + - . /root/ws/install/local_setup.sh + build_enabled: - image: $base_image_id script: - - vcs import < instrumentation.repos - - rosdep install --from-paths . -i . -i /root/ws --rosdistro dashing -y - lttng-sessiond --daemonize - - . /root/ws/install/local_setup.sh - colcon build --symlink-install --packages-up-to $PACKAGES_LIST - . install/local_setup.sh - colcon test --packages-select $PACKAGES_LIST - colcon test-result - artifacts: - paths: - - install + +build: + script: + - rm colcon.meta + - colcon build --symlink-install --packages-up-to $PACKAGES_LIST + - . install/local_setup.sh + - colcon test --packages-select $PACKAGES_LIST + - colcon test-result + +artifacts: + paths: + - install + - build/*/test_results/*/*.xunit.xml + - build/*/pytest.xml + reports: + junit: - build/*/test_results/*/*.xunit.xml - build/*/pytest.xml - reports: - junit: - - build/*/test_results/*/*.xunit.xml - - build/*/pytest.xml From b9d7da53a72a1dccb52c326aedc5bfc713368228 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 12 Jul 2019 10:49:32 +0200 Subject: [PATCH 3/3] Use yaml hidden key for artifacts --- .gitlab-ci.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24ae517..1a2e4ca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,17 @@ variables: image: $base_image_id +.global_artifacts: &global_artifacts + artifacts: + paths: + - install + - build/*/test_results/*/*.xunit.xml + - build/*/pytest.xml + reports: + junit: + - build/*/test_results/*/*.xunit.xml + - build/*/pytest.xml + before_script: - vcs import < instrumentation.repos - rosdep install --from-paths . -i . -i /root/ws --rosdistro dashing -y @@ -17,6 +28,7 @@ build_enabled: - . install/local_setup.sh - colcon test --packages-select $PACKAGES_LIST - colcon test-result + <<: *global_artifacts build: script: @@ -25,13 +37,4 @@ build: - . install/local_setup.sh - colcon test --packages-select $PACKAGES_LIST - colcon test-result - -artifacts: - paths: - - install - - build/*/test_results/*/*.xunit.xml - - build/*/pytest.xml - reports: - junit: - - build/*/test_results/*/*.xunit.xml - - build/*/pytest.xml + <<: *global_artifacts