@@ -5,6 +5,9 @@ EXTRA_ARGS :=
55# ########
66.PHONY : requirements develop build build-debug build-conda install
77
8+ ASAN :=
9+ UBSAN :=
10+
811requirements : # # install python dev and runtime dependencies
912ifeq ($(OS ) ,Windows_NT)
1013 Powershell.exe -executionpolicy bypass -noprofile .\ci\scripts\windows\make_requirements.ps1
@@ -18,13 +21,13 @@ develop: requirements ## install dependencies and build library
1821 python -m pip install -e .[develop]
1922
2023build : # # build the library
21- python setup.py build build_ext --inplace
24+ CSP_ENABLE_ASAN= $( ASAN ) CSP_ENABLE_UBSAN= $( UBSAN ) python setup.py build build_ext --inplace
2225
2326build-debug : # # build the library ( DEBUG ) - May need a make clean when switching from regular build to build-debug and vice versa
24- SKBUILD_CONFIGURE_OPTIONS=" " DEBUG=1 python setup.py build build_ext --inplace
27+ CSP_ENABLE_ASAN= $( ASAN ) CSP_ENABLE_UBSAN= $( UBSAN ) SKBUILD_CONFIGURE_OPTIONS=" " DEBUG=1 python setup.py build build_ext --inplace
2528
2629build-conda : # # build the library in Conda
27- python setup.py build build_ext --csp-no-vcpkg --inplace
30+ CSP_ENABLE_ASAN= $( ASAN ) CSP_ENABLE_UBSAN= $( UBSAN ) python setup.py build build_ext --csp-no-vcpkg --inplace
2831
2932install : # # install library
3033 python -m pip install .
@@ -78,12 +81,26 @@ checks: check
7881# ########
7982# TESTS #
8083# ########
81- .PHONY : test-py test-cpp coverage-py test tests
84+ .PHONY : test-py test-cpp test-py-sanitizer coverage-py test test-sanitizer tests
8285
8386TEST_ARGS :=
8487test-py : # # Clean and Make unit tests
8588 python -m pytest -v csp/tests --junitxml=junit.xml $(TEST_ARGS )
8689
90+ test-py-sanitizer : # # Clean and Make unit tests with sanitizers enabled
91+ @if [ " $$ (uname -s)" = " Darwin" ]; then \
92+ ASAN_OPTIONS=detect_leaks=0,detect_stack_use_after_return=true,use_odr_indicator=1,strict_init_order=true,strict_string_checks=true \
93+ DYLD_INSERT_LIBRARIES=$$($(CXX ) -print-file-name=libclang_rt.asan_osx_dynamic.dylib) \
94+ python -m pytest -v csp/tests --junitxml=junit.xml $(TEST_ARGS ) ; \
95+ elif [ " $$ (uname -s)" = " Linux" ]; then \
96+ ASAN_OPTIONS=detect_leaks=0,detect_stack_use_after_return=true,use_odr_indicator=1,strict_init_order=true,strict_string_checks=true \
97+ LD_PRELOAD=$$($(CXX ) -print-file-name=libasan.so) \
98+ python -m pytest -v csp/tests --junitxml=junit.xml $(TEST_ARGS ) ; \
99+ else \
100+ echo " Unsupported platform: $$ (uname -s)" ; \
101+ exit 1; \
102+ fi
103+
87104test-cpp : # # Make C++ unit tests
88105ifneq ($(OS ) ,Windows_NT)
89106 for f in ./csp/tests/bin/*; do $$f; done || (echo "TEST FAILED" && exit 1)
@@ -96,6 +113,8 @@ coverage-py:
96113
97114test : test-cpp test-py # # run the tests
98115
116+ test-sanitizer : test-cpp test-py-sanitizer # # run the tests
117+
99118# Alias
100119tests : test
101120
0 commit comments