Skip to content

test: Add per-test sanitizers only through obs_test_sanitize - #422

Merged
zackees merged 2 commits into
masterfrom
fix/159-test-sanitize
Oct 13, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/159-test-sanitize

Conversation

@zackees

@zackees zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Closes #159.

Eight cmocka tests hard-coded -fsanitize=address/undefined on their targets, so a tree configured with -fsanitize=thread (or MSan) failed to build (-fsanitize=thread is incompatible with -fsanitize=address), and valgrind couldn't run the ASan binaries.

  • RED: ci/test_cmocka_sanitize.py (run by ./lint) rejects any raw -fsanitize in test/cmocka/CMakeLists.txt and tests.d/*.cmake outside the helper.
  • GREEN: obs_test_sanitize(<target> <sanitizers>) plus option OBS_TEST_SANITIZE_PER_TARGET (default ON). It adds -fsanitize=<s> -fno-omit-frame-pointer (and -fno-sanitize-recover=undefined with UBSan) except on MSVC, when CMAKE_C_FLAGS/CMAKE_CXX_FLAGS/CMAKE_EXE_LINKER_FLAGS already contain -fsanitize=, or when the option is OFF. It covers test_avc, test_formatted_filename, test_utf8, test_amf_decode (keeps -fsigned-char), test_utf8_insize0, test_amf3_terminator, test_amf3_classname and test_dstr_zero_len. No C test source changed.

Checked by configuring a scratch project with the helper: a plain build gets -fsanitize=address,undefined;-fno-omit-frame-pointer;-fno-sanitize-recover=undefined, and -DCMAKE_C_FLAGS=-fsanitize=thread gets none. The local gate (incl. Tier 2 OFF/ON) passed and is stamped.

The eight tests that compile their code with ASan/UBSan now go through
one helper, which skips the flags on MSVC, when the build is already
sanitized, or when OBS_TEST_SANITIZE_PER_TARGET is OFF. A TSan, MSan or
valgrind build of the tree no longer fails on mixed sanitizers.

Closes #159

Local-Gate: v1 tree=09b7963777baa33e3d085edefec480a78cdfc479 secs=139 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791854223,"gate":"rust/all/fmt","host":"linux-x86_64","key":"410051af9b87b8efe73243aaed515fae3b73c1ada522ffd27f4809f52f216561","lane":"lint","parents":["c3388bd59eb06a0e4e599e1f8b0d01c7558193d4"],"secs":17,"stamp":"be27f4fb4a7c9934ff83d39711d2f288","tree":"09b7963777baa33e3d085edefec480a78cdfc479","v":1,"via":"run"}
Ci-Attestation: {"at":1791854223,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"410051af9b87b8efe73243aaed515fae3b73c1ada522ffd27f4809f52f216561","lane":"lint","parents":["c3388bd59eb06a0e4e599e1f8b0d01c7558193d4"],"secs":17,"stamp":"39031d6035ef9cb8fecde4537a08d8bc","tree":"09b7963777baa33e3d085edefec480a78cdfc479","v":1,"via":"run"}
Ci-Attestation: {"at":1791854223,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"92562d9e529839c999f5ac6677f7f059daf98a7d0617c03c572a9103eb5f99b7","lane":"rust-test","parents":["c3388bd59eb06a0e4e599e1f8b0d01c7558193d4"],"secs":56,"stamp":"da8d271682947ea6395f303720794118","tree":"09b7963777baa33e3d085edefec480a78cdfc479","v":1,"via":"run"}
Ci-Attestation: {"at":1791854223,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"922b2b595ab1a4ef1a10a183942f597f86d6beba257a59ac9e0c1bfa255409a7","lane":"tier2-linux","parents":["c3388bd59eb06a0e4e599e1f8b0d01c7558193d4"],"secs":66,"stamp":"ee49e86b958dd4553a303cb8453fe851","tree":"09b7963777baa33e3d085edefec480a78cdfc479","v":1,"via":"run"}
@zackees
zackees merged commit 5a28919 into master Oct 13, 2026
20 checks passed
@zackees
zackees deleted the fix/159-test-sanitize branch October 26, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

test/cmocka: hardcoded per-test -fsanitize flags break TSan/MSan builds and valgrind runs

1 participant