@@ -5,6 +5,9 @@ EXTRA_ARGS :=
5
5
# ########
6
6
.PHONY : requirements develop build build-debug build-conda install
7
7
8
+ ASAN :=
9
+ UBSAN :=
10
+
8
11
requirements : # # install python dev and runtime dependencies
9
12
ifeq ($(OS ) ,Windows_NT)
10
13
Powershell.exe -executionpolicy bypass -noprofile .\ci\scripts\windows\make_requirements.ps1
@@ -18,13 +21,13 @@ develop: requirements ## install dependencies and build library
18
21
python -m pip install -e .[develop]
19
22
20
23
build : # # 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
22
25
23
26
build-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
25
28
26
29
build-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
28
31
29
32
install : # # install library
30
33
python -m pip install .
@@ -78,12 +81,26 @@ checks: check
78
81
# ########
79
82
# TESTS #
80
83
# ########
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
82
85
83
86
TEST_ARGS :=
84
87
test-py : # # Clean and Make unit tests
85
88
python -m pytest -v csp/tests --junitxml=junit.xml $(TEST_ARGS )
86
89
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
+
87
104
test-cpp : # # Make C++ unit tests
88
105
ifneq ($(OS ) ,Windows_NT)
89
106
for f in ./csp/tests/bin/*; do $$f; done || (echo "TEST FAILED" && exit 1)
@@ -96,6 +113,8 @@ coverage-py:
96
113
97
114
test : test-cpp test-py # # run the tests
98
115
116
+ test-sanitizer : test-cpp test-py-sanitizer # # run the tests
117
+
99
118
# Alias
100
119
tests : test
101
120
0 commit comments