Skip to content

Commit

Permalink
Add AddressSanitizer to CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Nov 22, 2024
1 parent d33f058 commit 4ab2ea2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- name: Build & run tests
run: |
sudo apt install -y ninja-build
cmake -DASAN=ON -B build/ -G Ninja
CMAKE_GENERATOR=Ninja make test
check_format:
Expand Down Expand Up @@ -290,6 +291,7 @@ jobs:
- name: Build & test pico
run: |
sudo apt install -y ninja-build
cmake -DASAN=ON -B build/ -G Ninja
CMAKE_GENERATOR=Ninja make
python3 ./build/tests/no_router.py
timeout-minutes: 5
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ else()
add_compile_options(-Wpedantic)
endif()
# add_compile_options(-Wconversion)
# add_link_options(-fsanitize=address)
elseif(MSVC)
add_compile_options(/W4 /WX /Od /wd4127)
elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
Expand Down Expand Up @@ -379,12 +378,14 @@ option(BUILD_EXAMPLES "Use this to also build the examples." ON)
option(BUILD_TOOLS "Use this to also build the tools." OFF)
option(BUILD_TESTING "Use this to also build tests." ON)
option(BUILD_INTEGRATION "Use this to also build integration tests." OFF)
option(ASAN "Enable AddressSanitizer." OFF)

message(STATUS "Produce Debian and RPM packages: ${PACKAGING}")
message(STATUS "Build examples: ${BUILD_EXAMPLES}")
message(STATUS "Build tools: ${BUILD_TOOLS}")
message(STATUS "Build tests: ${BUILD_TESTING}")
message(STATUS "Build integration: ${BUILD_INTEGRATION}")
message(STATUS "AddressSanitizer: ${ASAN}")

set(PICO_LIBS "")
if(PICO_STATIC)
Expand Down Expand Up @@ -453,6 +454,11 @@ if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

if(ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()

if(UNIX OR MSVC)
if(BUILD_TOOLS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tools)
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ CMAKE_OPT=-DZENOH_DEBUG=$(ZENOH_DEBUG) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DCMAK
-DZ_FEATURE_MULTI_THREAD=$(Z_FEATURE_MULTI_THREAD) -DZ_FEATURE_INTEREST=$(Z_FEATURE_INTEREST) -DZ_FEATURE_UNSTABLE_API=$(Z_FEATURE_UNSTABLE_API)\
-DZ_FEATURE_PUBLICATION=$(Z_FEATURE_PUBLICATION) -DZ_FEATURE_SUBSCRIPTION=$(Z_FEATURE_SUBSCRIPTION) -DZ_FEATURE_QUERY=$(Z_FEATURE_QUERY) -DZ_FEATURE_QUERYABLE=$(Z_FEATURE_QUERYABLE)\
-DZ_FEATURE_RAWETH_TRANSPORT=$(Z_FEATURE_RAWETH_TRANSPORT) -DFRAG_MAX_SIZE=$(FRAG_MAX_SIZE) -DBATCH_UNICAST_SIZE=$(BATCH_UNICAST_SIZE) -DBATCH_MULTICAST_SIZE=$(BATCH_MULTICAST_SIZE)\
-DBUILD_INTEGRATION=$(BUILD_INTEGRATION) -DBUILD_TOOLS=$(BUILD_TOOLS) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -H.
-DASAN=$(ASAN) -DBUILD_INTEGRATION=$(BUILD_INTEGRATION) -DBUILD_TOOLS=$(BUILD_TOOLS) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -H.

ifeq ($(FORCE_C99), ON)
CMAKE_OPT += -DCMAKE_C_STANDARD=99
Expand Down

0 comments on commit 4ab2ea2

Please sign in to comment.