File tree Expand file tree Collapse file tree 2 files changed +49
-5
lines changed
Expand file tree Collapse file tree 2 files changed +49
-5
lines changed Original file line number Diff line number Diff line change 1+ name : Clang Sanitizers
2+
3+ # On all pushes to branches and pull requests in general.
4+ on :
5+ push :
6+ pull_request :
7+
8+ env :
9+ # Build debug because tracepp only functions under debug builds.
10+ BUILD_TYPE : Debug
11+
12+ jobs :
13+ test :
14+ runs-on : ubuntu-latest
15+ strategy :
16+ matrix :
17+ sanitizer : [ADDRESS_SANITIZER, THREAD_SANITIZER, UNDEFINED_SANITIZER]
18+
19+ steps :
20+ - uses : actions/checkout@v2
21+
22+ - name : Configure cmake
23+ run : CC=clang CXX=clang++ cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D${{matrix.sanitizer}}=ON -DEVERY_WARNING=ON
24+
25+ - name : Build
26+ run : cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --verbose
27+
28+ - name : Test
29+ working-directory : ${{github.workspace}}/build
30+ run : ctest -C ${{env.BUILD_TYPE}} --output-on-failure
31+
32+ - name : Test sporadic failures
33+ working-directory : ${{github.workspace}}/build
34+ run : ctest -C ${{env.BUILD_TYPE}} --output-on-failure --repeat until-fail:20 -R tests
35+
36+ - name : Run examples
37+ run : cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --verbose --target run_examples
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.20)
22project (tracepp)
33
44option (ADDRESS_SANITIZER "Use memory error detector (clang only and implies debug mode!)" OFF )
5+ option (ADDRESS_SANITIZER "Use memory error detector (clang only and implies debug mode!)" OFF )
6+ option (THREAD_SANITIZER "Use thread data race detector (clang only and implies debug mode!)" OFF )
7+ option (UNDEFINED_SANITIZER "Use undefined behavior detector (clang only and implies debug mode!)" OFF )
58option (EVERY_WARNING "Use -Weverything (clang only)" OFF )
69
710# Exports the "compile_commands.json" file when the generator is Ninja or Makefile.
@@ -16,11 +19,15 @@ if (NOT CMAKE_BUILD_TYPE)
1619endif ()
1720
1821if (ADDRESS_SANITIZER)
19- if (NOT "${CMAKE_CXX_COMPILER_ID} " MATCHES "Clang" )
20- message (FATAL_ERROR "Clang is required to use address sanitizer to detect memory errors!" )
21- endif ()
22-
23- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" )
22+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" )
23+ set (CMAKE_BUILD_TYPE Debug)
24+ endif ()
25+ if (THREAD_SANITIZER)
26+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread" )
27+ set (CMAKE_BUILD_TYPE Debug)
28+ endif ()
29+ if (UNDEFINED_SANITIZER)
30+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined" )
2431 set (CMAKE_BUILD_TYPE Debug)
2532endif ()
2633
You can’t perform that action at this time.
0 commit comments