Enable tracing by default if LTTng is available

Also removed the colcon.meta file that implicitly enabled tracing anyway
This commit is contained in:
Tobias Blass 2019-07-19 10:02:56 +02:00
parent 74a781a1b9
commit 1452787336
5 changed files with 49 additions and 60 deletions

View file

@ -32,7 +32,6 @@ build_enabled:
build: build:
script: script:
- rm colcon.meta
- colcon build --symlink-install --packages-up-to $PACKAGES_LIST - colcon build --symlink-install --packages-up-to $PACKAGES_LIST
- . install/local_setup.sh - . install/local_setup.sh
- colcon test --packages-select $PACKAGES_LIST - colcon test --packages-select $PACKAGES_LIST

View file

@ -4,7 +4,7 @@ Tracing tools for ROS 2.
## Building ## 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: To enable tracing:
@ -16,9 +16,9 @@ To enable tracing:
$ sudo apt-get install python3-babeltrace python3-lttng $ sudo apt-get install python3-babeltrace python3-lttng
``` ```
Note: the LTTng stable 2.10 PPA is used to get newer versions of the packages. 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: 3. Source and check that tracing is enabled:
``` ```

View file

@ -1,14 +0,0 @@
{
"names": {
"tracetools": {
"cmake-args": [
"-DWITH_LTTNG=ON",
],
},
"tracetools_test": {
"cmake-args": [
"-DWITH_LTTNG=ON",
],
},
},
}

View file

@ -12,21 +12,17 @@ endif()
find_package(ament_cmake_ros REQUIRED) 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) if(WITH_LTTNG)
# Try to find LTTng # Set TRACING_ENABLED if we can find lttng-ust
find_package(PkgConfig REQUIRED) # TODO: Should these be quiet?
pkg_check_modules(LTTNG REQUIRED lttng-ust) find_package(PkgConfig)
endif() if(PkgConfig_FOUND)
if(LTTNG_FOUND) pkg_check_modules(LTTNG lttng-ust)
set(LTTNG_TP_FILES if(LTTNG_FOUND)
include/tracetools/tp_call.h set(TRACING_ENABLED TRUE)
src/tp_call.c endif()
) endif()
set(TRACING_ENABLED TRUE)
message("LTTng found: tracing enabled")
elseif(WITH_LTTNG)
message("LTTng NOT found: tracing disabled")
endif() endif()
include_directories(include) include_directories(include)
@ -54,7 +50,10 @@ set(SOURCES
src/utils.cpp src/utils.cpp
) )
if(TRACING_ENABLED) if(TRACING_ENABLED)
list(APPEND SOURCES ${LTTNG_TP_FILES}) list(APPEND SOURCES
include/tracetools/tp_call.h
src/tp_call.c)
endif() endif()
add_library(${PROJECT_NAME} SHARED ${SOURCES}) add_library(${PROJECT_NAME} SHARED ${SOURCES})

View file

@ -12,7 +12,18 @@ endif()
find_package(ament_cmake REQUIRED) 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 # Tests
if(BUILD_TESTING) if(BUILD_TESTING)
@ -119,36 +130,30 @@ if(BUILD_TESTING)
ament_lint_auto_find_test_dependencies() ament_lint_auto_find_test_dependencies()
# Only build tracing tests if LTTng is enabled and found # Only build tracing tests if LTTng is enabled and found
if(WITH_LTTNG) if(TRACING_ENABLED)
find_package(PkgConfig REQUIRED) find_package(ament_cmake_pytest REQUIRED)
pkg_check_modules(LTTNG REQUIRED lttng-ust)
if(LTTNG_FOUND)
message("LTTng found: tracing tests enabled")
find_package(ament_cmake_pytest REQUIRED) # Run each test in its own pytest invocation
set(_tracetools_test_pytest_tests
# Run each test in its own pytest invocation test/test_intra.py
set(_tracetools_test_pytest_tests test/test_node.py
test/test_intra.py test/test_publisher.py
test/test_node.py test/test_service.py
test/test_publisher.py test/test_service_callback.py
test/test_service.py test/test_subscription.py
test/test_service_callback.py test/test_subscription_callback.py
test/test_subscription.py test/test_timer.py
test/test_subscription_callback.py
test/test_timer.py
) )
foreach(_test_path ${_tracetools_test_pytest_tests}) foreach(_test_path ${_tracetools_test_pytest_tests})
get_filename_component(_test_name ${_test_path} NAME_WE) get_filename_component(_test_name ${_test_path} NAME_WE)
ament_add_pytest_test(${_test_name} ${_test_path} ament_add_pytest_test(${_test_name} ${_test_path}
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
APPEND_ENV AMENT_PREFIX_PATH=${ament_index_build_path} APPEND_ENV AMENT_PREFIX_PATH=${ament_index_build_path}
PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
TIMEOUT 60 TIMEOUT 60
) )
endforeach() endforeach()
endif()
endif() endif()
endif() endif()