Skip to content

Commit fff8f12

Browse files
committed
Thread and Address Sanitizer CI
Signed-off-by: Tyler Weaver <[email protected]>
1 parent 332e35d commit fff8f12

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/ci.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git).
2+
# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst)
3+
4+
name: CI
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
push:
10+
branches:
11+
- ros2
12+
13+
jobs:
14+
ci:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
env:
19+
- TARGET_CMAKE_ARGS: -DENABLE_SANITIZER_ADDRESS=ON -DCMAKE_BUILD_TYPE=Debug
20+
NAME: Address Sanitizer
21+
- TARGET_CMAKE_ARGS: -DENABLE_SANITIZER_THREAD=ON -DCMAKE_BUILD_TYPE=Debug
22+
NAME: Thread Sanitizer
23+
env:
24+
ROS_DISTRO: rolling
25+
runs-on: ubuntu-latest
26+
name: ${{ matrix.env.NAME }}
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: 'ros-industrial/industrial_ci@master'
30+
env: ${{matrix.env}}

CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1010
add_compile_options(-Wall -Wextra -Wpedantic)
1111
endif()
1212

13+
option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF)
14+
if(ENABLE_SANITIZER_ADDRESS)
15+
add_compile_options(-fsanitize=address)
16+
add_link_options(-fsanitize=address)
17+
endif()
18+
19+
option(ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF)
20+
if(ENABLE_SANITIZER_THREAD)
21+
if(ENABLE_SANITIZER_ADDRESS)
22+
message(WARNING "Thread sanitizer does not work with Address sanitizer enabled")
23+
endif()
24+
add_compile_options(-fsanitize=thread)
25+
add_link_options(-fsanitize=thread)
26+
endif()
27+
1328
set(CLASS_LOADER_IGNORE_AMENT FALSE CACHE BOOL
1429
"Do not use ament when building this package.")
1530
if(NOT CLASS_LOADER_IGNORE_AMENT)

0 commit comments

Comments
 (0)