Skip to content

Commit

Permalink
build tests in debug with sanitizers in CI
Browse files Browse the repository at this point in the history
and run them with env to fail on sanitizer warnings
commiting intentional UB to test this
  • Loading branch information
oschonrock committed Dec 16, 2024
1 parent ec15bdb commit d7e5cf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up compiler
- name: build with cmake
run: |
if [ "${{ matrix.compiler }}" == "gcc" ]; then
export CC=gcc
Expand All @@ -22,8 +22,5 @@ jobs:
export CC=clang
export CXX=clang++
fi
shell: bash
- name: build with cmake
run: |
cmake -S . -B build &&
cmake --build build # includes tests by default
cmake -S . -B build -DCMAKE_BUILD_TYPE=debug && # debug includes sanitizers
cmake --build build # includes tests by default, tests are run with env set to fail on sanitizers
6 changes: 5 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ add_custom_command(
TARGET binfuse_all_tests
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --output-on-failure # --verbose
COMMAND env
ASAN_OPTIONS='halt_on_error=1:abort_on_error=1:print_summary=1'
UBSAN_OPTIONS='halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1'
${CMAKE_CTEST_COMMAND}
-C $<CONFIGURATION> --output-on-failure # --verbose
USES_TERMINAL
)
2 changes: 2 additions & 0 deletions test/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <vector>

TEST(binfuse_filter, default_construct) { // NOLINT
char str[10];
str[1000] = 'a';
binfuse::filter8 filter;
EXPECT_FALSE(filter.is_populated());
}
Expand Down

0 comments on commit d7e5cf3

Please sign in to comment.