cmake: factor the ASan/LSan test options into cache variables

add_ceph_test() spelled out the suppression-file paths and sanitizer flags
inline.  bin/ceph needs the same options, so lift them into CEPH_ASAN_OPTIONS
and CEPH_LSAN_OPTIONS and have add_ceph_test() consume those.  The environment
the tests run with is unchanged.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
This commit is contained in:
Kefu Chai 2026-06-23 16:14:19 +08:00
parent b4f29b38df
commit 2c9b73894b
2 changed files with 9 additions and 2 deletions

View File

@ -724,6 +724,13 @@ endif(LINUX)
option(WITH_ASAN "build with ASAN" OFF)
if(WITH_ASAN)
list(APPEND sanitizers "address")
# Shared ASan/LSan runtime options: the in-tree suppression files plus the
# flags our tests need. Consumed by add_ceph_test() and baked into bin/ceph
# so both ignore the same still-reachable third-party leaks.
set(CEPH_ASAN_OPTIONS "suppressions=${CMAKE_SOURCE_DIR}/qa/asan.supp,detect_odr_violation=0"
CACHE INTERNAL "ASAN_OPTIONS for ceph tests and the ceph CLI")
set(CEPH_LSAN_OPTIONS "suppressions=${CMAKE_SOURCE_DIR}/qa/lsan.supp,print_suppressions=0"
CACHE INTERNAL "LSAN_OPTIONS for ceph tests and the ceph CLI")
endif()
option(WITH_ASAN_LEAK "explicitly enable ASAN leak detection" OFF)

View File

@ -33,8 +33,8 @@ function(add_ceph_test test_name test_path)
set_property(TEST ${test_name}
APPEND
PROPERTY ENVIRONMENT
ASAN_OPTIONS=suppressions=${CMAKE_SOURCE_DIR}/qa/asan.supp,detect_odr_violation=0
LSAN_OPTIONS=suppressions=${CMAKE_SOURCE_DIR}/qa/lsan.supp,print_suppressions=0)
ASAN_OPTIONS=${CEPH_ASAN_OPTIONS}
LSAN_OPTIONS=${CEPH_LSAN_OPTIONS})
endif()
set_property(TEST ${test_name}
PROPERTY TIMEOUT ${CEPH_TEST_TIMEOUT})