From 820723905704cf5104d0b2b69a7947960f3b8819 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Tue, 16 Jul 2019 13:53:07 +0200 Subject: [PATCH 1/8] Fix test_utils never getting built --- tracetools/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index 8c85a14..0e12230 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -92,7 +92,7 @@ if(BUILD_TESTING) ament_lint_auto_find_test_dependencies() # Only build tracetools utils tests if LTTng is enabled and found - if(TRACETOOLS_LTTNG_ENABLED) + if(TRACING_ENABLED) ament_add_gtest(test_utils test/test_utils.cpp) if(TARGET test_utils) target_link_libraries(test_utils ${PROJECT_NAME} -rdynamic) From 145278733611c787b2106f05a875e7849272b33b Mon Sep 17 00:00:00 2001 From: Tobias Blass Date: Fri, 19 Jul 2019 10:02:56 +0200 Subject: [PATCH 2/8] Enable tracing by default if LTTng is available Also removed the colcon.meta file that implicitly enabled tracing anyway --- .gitlab-ci.yml | 1 - README.md | 6 ++-- colcon.meta | 14 -------- tracetools/CMakeLists.txt | 29 ++++++++--------- tracetools_test/CMakeLists.txt | 59 ++++++++++++++++++---------------- 5 files changed, 49 insertions(+), 60 deletions(-) delete mode 100644 colcon.meta diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a2e4ca..14a42ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,6 @@ build_enabled: build: script: - - rm colcon.meta - colcon build --symlink-install --packages-up-to $PACKAGES_LIST - . install/local_setup.sh - colcon test --packages-select $PACKAGES_LIST diff --git a/README.md b/README.md index 18a8eed..d4c855f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tracing tools for ROS 2. ## Building -If tracing is not enabled when building, or if LTTng is not found, then this package will not do anything. +If the `TRACETOOLS_ENABLED` option is disabled during build or if LTTng is not found, then this package will not do anything. To enable tracing: @@ -16,9 +16,9 @@ To enable tracing: $ sudo apt-get install python3-babeltrace python3-lttng ``` Note: the LTTng stable 2.10 PPA is used to get newer versions of the packages. -2. Build with the `WITH_LTTNG` flag: +2. Build ``` - $ colcon build --cmake-args " -DWITH_LTTNG=ON" + $ colcon build ``` 3. Source and check that tracing is enabled: ``` diff --git a/colcon.meta b/colcon.meta deleted file mode 100644 index d5559d4..0000000 --- a/colcon.meta +++ /dev/null @@ -1,14 +0,0 @@ -{ - "names": { - "tracetools": { - "cmake-args": [ - "-DWITH_LTTNG=ON", - ], - }, - "tracetools_test": { - "cmake-args": [ - "-DWITH_LTTNG=ON", - ], - }, - }, -} diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index 8c85a14..eb6a6a4 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -12,21 +12,17 @@ endif() find_package(ament_cmake_ros REQUIRED) -option(WITH_LTTNG "Include support for tracing with LTTng" OFF) +option(WITH_LTTNG "Enable support for tracing with LTTng" ON) if(WITH_LTTNG) - # Try to find LTTng - find_package(PkgConfig REQUIRED) - pkg_check_modules(LTTNG REQUIRED lttng-ust) -endif() -if(LTTNG_FOUND) - set(LTTNG_TP_FILES - include/tracetools/tp_call.h - src/tp_call.c - ) - set(TRACING_ENABLED TRUE) - message("LTTng found: tracing enabled") -elseif(WITH_LTTNG) - message("LTTng NOT found: tracing disabled") + # Set TRACING_ENABLED if we can find lttng-ust + # TODO: Should these be quiet? + find_package(PkgConfig) + if(PkgConfig_FOUND) + pkg_check_modules(LTTNG lttng-ust) + if(LTTNG_FOUND) + set(TRACING_ENABLED TRUE) + endif() + endif() endif() include_directories(include) @@ -54,7 +50,10 @@ set(SOURCES src/utils.cpp ) if(TRACING_ENABLED) - list(APPEND SOURCES ${LTTNG_TP_FILES}) + list(APPEND SOURCES + include/tracetools/tp_call.h + src/tp_call.c) + endif() add_library(${PROJECT_NAME} SHARED ${SOURCES}) diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index e383cd6..abfb684 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -12,7 +12,18 @@ endif() find_package(ament_cmake REQUIRED) -option(WITH_LTTNG "Include support for tracing with LTTng" OFF) +option(WITH_LTTNG "Enable support for tracing with LTTng" ON) +if(WITH_LTTNG) + # Set TRACING_ENABLED if we can find lttng-ust + # TODO should these be quiet? + find_package(PkgConfig) + if(PkgConfig_FOUND) + pkg_check_modules(LTTNG lttng-ust) + if(LTTNG_FOUND) + set(TRACING_ENABLED TRUE) + endif() + endif() +endif() # Tests if(BUILD_TESTING) @@ -119,36 +130,30 @@ if(BUILD_TESTING) ament_lint_auto_find_test_dependencies() # 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") + if(TRACING_ENABLED) + find_package(ament_cmake_pytest REQUIRED) - find_package(ament_cmake_pytest REQUIRED) - - # 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 + # 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 + 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() + endforeach() endif() endif() From 32717cb80651a2ddc7cc54a312af559141fee614 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Thu, 25 Jul 2019 09:03:29 +0200 Subject: [PATCH 3/8] Rename option --- tracetools/CMakeLists.txt | 11 +++++------ tracetools_test/CMakeLists.txt | 6 ++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index 917b923..fa83f21 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -12,15 +12,14 @@ endif() find_package(ament_cmake_ros REQUIRED) -option(WITH_LTTNG "Enable support for tracing with LTTng" ON) -if(WITH_LTTNG) - # Set TRACING_ENABLED if we can find lttng-ust - # TODO: Should these be quiet? +option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" OFF) +if(NOT TRACETOOLS_DISABLED) find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(LTTNG lttng-ust) if(LTTNG_FOUND) set(TRACING_ENABLED TRUE) + message("LTTng found: tracing enabled") endif() endif() endif() @@ -52,8 +51,8 @@ set(SOURCES if(TRACING_ENABLED) list(APPEND SOURCES include/tracetools/tp_call.h - src/tp_call.c) - + src/tp_call.c + ) endif() add_library(${PROJECT_NAME} SHARED ${SOURCES}) diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index abfb684..182d27d 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -12,10 +12,8 @@ endif() find_package(ament_cmake REQUIRED) -option(WITH_LTTNG "Enable support for tracing with LTTng" ON) -if(WITH_LTTNG) - # Set TRACING_ENABLED if we can find lttng-ust - # TODO should these be quiet? +option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" OFF) +if(NOT TRACETOOLS_DISABLED) find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(LTTNG lttng-ust) From 1e863006ab35f3350b7ec508ac8acf157a2b0ca4 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Thu, 25 Jul 2019 09:03:39 +0200 Subject: [PATCH 4/8] Update CI config for build job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 14a42ac..7494048 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,7 @@ build_enabled: build: script: - - colcon build --symlink-install --packages-up-to $PACKAGES_LIST + - colcon build --symlink-install --cmake-args " -DTRACETOOLS_DISABLED=ON" --packages-up-to $PACKAGES_LIST - . install/local_setup.sh - colcon test --packages-select $PACKAGES_LIST - colcon test-result From 6f9cc13902cedd5efc675ec8e83d484c3518249f Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Thu, 25 Jul 2019 09:16:23 +0200 Subject: [PATCH 5/8] Fix lint_cmake errors --- tracetools_test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index 182d27d..cb35969 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -141,7 +141,7 @@ if(BUILD_TESTING) 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) @@ -150,7 +150,7 @@ if(BUILD_TESTING) APPEND_ENV AMENT_PREFIX_PATH=${ament_index_build_path} PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} TIMEOUT 60 - ) + ) endforeach() endif() endif() From 5da7ad22edfb6a48fd2b3aafb2d62a8140f054c0 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Thu, 25 Jul 2019 09:30:46 +0200 Subject: [PATCH 6/8] Put back cmake comments --- tracetools/CMakeLists.txt | 1 + tracetools_test/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index fa83f21..d1d3315 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -14,6 +14,7 @@ find_package(ament_cmake_ros REQUIRED) option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" OFF) if(NOT TRACETOOLS_DISABLED) + # Set TRACING_ENABLED if we can find lttng-ust find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(LTTNG lttng-ust) diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index cb35969..24e3ffe 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -14,6 +14,7 @@ find_package(ament_cmake REQUIRED) option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" OFF) if(NOT TRACETOOLS_DISABLED) + # Set TRACING_ENABLED if we can find lttng-ust find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(LTTNG lttng-ust) From 2af66ddfeb6162e894dabefd05d49e7fc54cf54c Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Thu, 25 Jul 2019 09:38:36 +0200 Subject: [PATCH 7/8] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4c855f..5722e2c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tracing tools for ROS 2. ## Building -If the `TRACETOOLS_ENABLED` option is disabled during build or if LTTng is not found, then this package will not do anything. +If the `TRACETOOLS_DISABLED` option is enabled during build or if LTTng is not found, then this package will not do anything. To enable tracing: From abfa1c066b50ca766efef203e4e5e8135c6febd7 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Thu, 25 Jul 2019 11:15:13 +0200 Subject: [PATCH 8/8] Check tracetools status in CI jobs --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7494048..3729e1a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,6 +26,7 @@ build_enabled: - lttng-sessiond --daemonize - colcon build --symlink-install --packages-up-to $PACKAGES_LIST - . install/local_setup.sh + - ./build/tracetools/status - colcon test --packages-select $PACKAGES_LIST - colcon test-result <<: *global_artifacts @@ -34,6 +35,7 @@ build: script: - colcon build --symlink-install --cmake-args " -DTRACETOOLS_DISABLED=ON" --packages-up-to $PACKAGES_LIST - . install/local_setup.sh + - (! ./build/tracetools/status) - colcon test --packages-select $PACKAGES_LIST - colcon test-result <<: *global_artifacts