Skip to content

Commit

Permalink
ci: Test shared library with sanitizers
Browse files Browse the repository at this point in the history
Since we run our tests through Python, this requires

- to link with -shared-libasan
- to LD_PRELOAD the ASan runtime
- to disable LeakSanitizer beacuse of false positives from Python
  • Loading branch information
nwellnhof committed Mar 18, 2024
1 parent 192cf1b commit 5c26299
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,30 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- cmake_opts: '-DBUILD_SHARED_LIBS=NO'
- cmake_opts: '-DBUILD_SHARED_LIBS=YES'
cflags: '-shared-libasan'
test_env: 'LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so)'
asan_options: 'detect_leaks=0'
env:
CMAKE_OPTIONS: ${{ matrix.cmake_opts }}
CC: 'clang'
CXX: 'clang++'
CFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all'
CXXFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all'
CFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all ${{ matrix.cflags }}'
CXXFLAGS: '-fsanitize=address,undefined -fno-sanitize-recover=all ${{ matrix.cflags }}'
ASAN_OPTIONS: ${{ matrix.asan_options }}

steps:
- uses: actions/checkout@v4
- name: Build and test
run: |
cmake -DBUILD_SHARED_LIBS=NO -DCMAKE_BUILD_TYPE=Debug -S . -B build
cmake $CMAKE_OPTIONS -DCMAKE_BUILD_TYPE=Debug -S . -B build
cmake --build build
# https://github.com/actions/runner-images/issues/9491
sudo sysctl vm.mmap_rnd_bits=28
ctest --test-dir build --output-on-failure
env ${{ matrix.test_env }} ctest --test-dir build --output-on-failure
macos:

Expand Down

0 comments on commit 5c26299

Please sign in to comment.