Skip to content

Commit 620ca89

Browse files
committed
Run TSan in two passes to limit annotation scope
Pass 1 runs all tests without annotations, skipping the false-positive tests that trigger races in CoreAudio's internal synchronization. Pass 2 re-runs only those tests with --features tsan-annotations so TSan can observe the happens-before relationship. This keeps annotation scope minimal while maximizing TSan coverage on all other tests.
1 parent 1b172af commit 620ca89

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

run_sanitizers.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,36 @@ do
5656
# See: https://github.com/rust-lang/rust/issues/146465
5757
if [[ "${san}" == "thread" ]]; then
5858
export RUSTFLAGS="${RUSTFLAGS} -Cunsafe-allow-abi-mismatch=sanitizer"
59+
# TSan false-positive tests: these trigger races in CoreAudio's
60+
# internal synchronization that TSan cannot observe. They are
61+
# skipped in pass 1 and re-run with annotations in pass 2.
62+
tsan_false_positive_tests=(
63+
"test_ops_duplex_voice_stream_set_input_processing_params"
64+
)
65+
tsan_skip_flags=""
66+
for t in "${tsan_false_positive_tests[@]}"; do
67+
tsan_skip_flags="${tsan_skip_flags} --skip ${t}"
68+
done
69+
export TSAN_SKIP_FLAGS="${tsan_skip_flags}"
5970
fi
6071
export CARGO_HOST_RUSTFLAGS=""
6172
# Set SANITIZER_BUILD so run_tests.sh can detect sanitizer mode.
6273
export SANITIZER_BUILD=1
6374
cargo_test_flags="-Z build-std --target ${TARGET}"
75+
# Pass 1: Run all tests (TSan false-positive tests are skipped via
76+
# TSAN_SKIP_FLAGS, picked up by run_tests.sh).
6477
sh run_tests.sh "${cargo_test_flags}"
78+
# Pass 2 (TSan only): Re-run false-positive tests with annotations
79+
# enabled so TSan can see CoreAudio's internal synchronization.
80+
if [[ "${san}" == "thread" ]]; then
81+
echo "\n\nRe-running TSan false-positive tests with annotations\n------------------------------"
82+
cargo_test_flags_annotated="${cargo_test_flags} --features tsan-annotations"
83+
for t in "${tsan_false_positive_tests[@]}"; do
84+
echo "Running ${t} with tsan-annotations..."
85+
cargo test --verbose --lib --tests ${cargo_test_flags_annotated} -- ${t}
86+
done
87+
unset TSAN_SKIP_FLAGS
88+
fi
6589
unset RUSTFLAGS
6690
unset CARGO_HOST_RUSTFLAGS
6791
unset SANITIZER_BUILD

run_tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ if [[ -n "${SANITIZER_ENABLED}" ]]; then
4848
# queues under sanitizers, allowing these tests to run.
4949
SKIP_TEST_FLAGS="--skip test_panic_"
5050
echo "Skipping #[should_panic] tests (incompatible with sanitizers)\n"
51+
# TSan false-positive tests are skipped in the main run and re-run
52+
# separately with annotations in run_sanitizers.sh.
53+
if [[ -n "${TSAN_SKIP_FLAGS}" ]]; then
54+
SKIP_TEST_FLAGS="${SKIP_TEST_FLAGS} ${TSAN_SKIP_FLAGS}"
55+
echo "Skipping TSan false-positive tests (will re-run with annotations)\n"
56+
fi
5157
fi
5258

5359
# Run tests in the sub crate

0 commit comments

Comments
 (0)