From: Kefu Chai Date: Tue, 23 Jun 2026 08:14:19 +0000 (+0800) Subject: cmake: factor the ASan/LSan test options into cache variables X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c9b73894b4525fb2fcb7abf33da4250fde92fe8;p=ceph.git 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f2abb516b65..0fcdf9664bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/modules/AddCephTest.cmake b/cmake/modules/AddCephTest.cmake index 49562e569b0..a96ea2231af 100644 --- a/cmake/modules/AddCephTest.cmake +++ b/cmake/modules/AddCephTest.cmake @@ -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})