-
Notifications
You must be signed in to change notification settings - Fork 18
102 lines (84 loc) · 3.1 KB
/
memory.yml
File metadata and controls
102 lines (84 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Memory Testing
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
jobs:
asan-pysimlin:
name: AddressSanitizer Testing (pysimlin)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly-2026-02-21
components: rust-src
# Cache is enabled by default with actions-rust-lang/setup-rust-toolchain
- name: Install dependencies
run: |
uv pip install --system cffi numpy pandas pytest pytest-cov
- name: Build libsimlin with AddressSanitizer
run: |
cd src/libsimlin
RUSTFLAGS="-Z sanitizer=address" \
cargo +nightly-2026-02-21 build --release --target x86_64-unknown-linux-gnu
# Copy the library to where pysimlin expects it
mkdir -p target/release
cp ../../target/x86_64-unknown-linux-gnu/release/libsimlin.a target/release/
- name: Install pysimlin
env:
ASAN: '1'
run: |
cd src/pysimlin
uv pip install --system -e .
- name: Run memory tests with AddressSanitizer
run: |
cd src/pysimlin
# Find the AddressSanitizer runtime library
ASAN_LIB=$(gcc -print-file-name=libasan.so)
# Run tests with verbose ASAN output and timeout
RUST_BACKTRACE=1 \
ASAN_OPTIONS="detect_leaks=1:check_initialization_order=1:strict_init_order=1:verbosity=1:print_stats=1:halt_on_error=0:print_module_map=1:log_path=/tmp/asan.log" \
LD_PRELOAD=$ASAN_LIB \
PYTHONMALLOC=malloc \
timeout 60 python -m pytest tests/test_memory.py -v --tb=short -x || EXIT_CODE=$?
# Show ASAN log if it exists
if [ -f /tmp/asan.log.* ]; then
echo "=== ASAN Log ==="
cat /tmp/asan.log.*
fi
# If specific test is failing, run it in isolation with more debug
if [ "${EXIT_CODE:-0}" != "0" ]; then
echo "=== Running failing test in isolation ==="
RUST_BACKTRACE=full \
ASAN_OPTIONS="detect_leaks=1:verbosity=1:halt_on_error=0" \
LD_PRELOAD=$ASAN_LIB \
PYTHONMALLOC=malloc \
timeout 10 python -m pytest tests/test_memory.py::TestErrorPathMemoryLeaks::test_import_error_no_leak -vvs || true
fi
exit ${EXIT_CODE:-0}
asan-full:
name: AddressSanitizer Testing (Full Rust Suite)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly-2026-02-21
components: rust-src
- name: Run ASAN tests
run: ./test-asan.sh