Skip to content

Commit 9504a53

Browse files
committed
ASAN tests
1 parent f2a4bec commit 9504a53

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/asan.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Address Sanitizer Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
clang_ASAN_UBSAN:
23+
runs-on: macos-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
fetch-tags: true
29+
30+
- name: Install system dependencies
31+
run: |
32+
brew install mpfr fftw cmake
33+
34+
- name: Set up LLVM
35+
run: |
36+
brew install llvm@19
37+
LLVM_PREFIX=$(brew --prefix llvm@19)
38+
echo "CC=$LLVM_PREFIX/bin/clang" >> $GITHUB_ENV
39+
echo "CXX=$LLVM_PREFIX/bin/clang++" >> $GITHUB_ENV
40+
echo "LDFLAGS=-L$LLVM_PREFIX/lib" >> $GITHUB_ENV
41+
echo "CPPFLAGS=-I$LLVM_PREFIX/include" >> $GITHUB_ENV
42+
43+
- name: Set up pyenv
44+
run: |
45+
git clone https://github.com/pyenv/pyenv.git "$HOME/.pyenv"
46+
PYENV_ROOT="$HOME/.pyenv"
47+
PYENV_BIN="$PYENV_ROOT/bin"
48+
PYENV_SHIMS="$PYENV_ROOT/shims"
49+
echo "$PYENV_BIN" >> $GITHUB_PATH
50+
echo "$PYENV_SHIMS" >> $GITHUB_PATH
51+
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
52+
53+
- name: Check pyenv is working
54+
run: pyenv --version
55+
56+
- name: Build CPython with address sanitizer
57+
run: |
58+
CONFIGURE_OPTS="--with-address-sanitizer" pyenv install 3.14t
59+
pyenv global 3.14t
60+
61+
- name: Install Python build dependencies
62+
run: |
63+
pip install meson meson-python ninja cython pytest hypothesis wheel build patchelf pytest-timeout
64+
65+
- name: Clone and build NumPy with ASan
66+
run: |
67+
git clone --depth 1 https://github.com/numpy/numpy.git numpy-asan
68+
cd numpy-asan
69+
git submodule update --init --recursive
70+
# Build NumPy with address sanitizer using pip
71+
pip install . -v --no-build-isolation \
72+
-Csetup-args=-Db_sanitize=address,undefined \
73+
-Csetup-args=-Db_lundef=false
74+
75+
- name: Build and install quaddtype with ASan
76+
working-directory: quaddtype
77+
run: |
78+
pip install .[test] -v --no-build-isolation \
79+
-Csetup-args=-Db_sanitize=address,undefined \
80+
-Csetup-args=-Db_lundef=false
81+
82+
- name: Run quaddtype tests with ASan
83+
working-directory: quaddtype
84+
run: |
85+
# pass -s to pytest to see ASAN errors and warnings, otherwise pytest captures them
86+
ASAN_OPTIONS=detect_leaks=0:symbolize=1:strict_init_order=true:allocator_may_return_null=1 \
87+
UBSAN_OPTIONS=halt_on_error=1 \
88+
pytest -vvv -s --color=yes --timeout=600 --durations=10

0 commit comments

Comments
 (0)