From 957d0716bdc9ec7dcd70f271c50e5115a6fc1554 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 21 Nov 2025 05:47:08 -0600 Subject: [PATCH 01/12] Use catch to define tests that use catch --- lib/CMakeLists.txt | 3 +++ plugins/esi/test/CMakeLists.txt | 28 ++++++++++++++-------------- src/iocore/cache/CMakeLists.txt | 30 +++++++++++++++--------------- src/iocore/hostdb/CMakeLists.txt | 12 ++++++------ 4 files changed, 38 insertions(+), 35 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 6e28a50eb15..05e1c379176 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -32,6 +32,8 @@ if(BUILD_TESTING) # # Update the above comment about the version to update. add_subdirectory(Catch2) + include(CTest) + include(Catch) # Disable -Werror=parentheses for Catch2 to avoid issues with older compilers (GCC <=11) # that complain about the use of parentheses in macro expansions. We see errors like this: @@ -51,6 +53,7 @@ if(BUILD_TESTING) macro(add_catch2_test) cmake_parse_arguments(CATCH2_TEST "" "NAME" "COMMAND" ${ARGN}) add_test(NAME ${CATCH2_TEST_NAME} COMMAND ${CATCH2_TEST_COMMAND} --order decl) + catch_discover_tests(${CATCH2_TEST_NAME}) endmacro() endif() diff --git a/plugins/esi/test/CMakeLists.txt b/plugins/esi/test/CMakeLists.txt index c9bc8c2d5f7..e6e78e4299d 100644 --- a/plugins/esi/test/CMakeLists.txt +++ b/plugins/esi/test/CMakeLists.txt @@ -21,23 +21,23 @@ target_link_libraries(esitest PUBLIC esi-common esicore) macro(ADD_ESI_TEST NAME) add_executable(${NAME} print_funcs.cc ${ARGN}) target_link_libraries(${NAME} PRIVATE esitest) - add_catch2_test(NAME ${NAME}_esi COMMAND $) + add_catch2_test(NAME ${NAME} COMMAND $) # Use ASan leak suppression for intentional DbgCtl leaks (issue #12776) set_tests_properties( - ${NAME}_esi PROPERTIES ENVIRONMENT + ${NAME} PROPERTIES ENVIRONMENT "LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/esi_test_leak_suppression.txt" ) endmacro() -add_esi_test(test_docnode docnode_test.cc) -target_link_libraries(test_docnode PRIVATE Catch2::Catch2WithMain esi-common esicore) -add_esi_test(test_parser parser_test.cc) -target_link_libraries(test_parser PRIVATE Catch2::Catch2WithMain esi-common esicore) -add_esi_test(test_processor processor_test.cc) -target_link_libraries(test_processor PRIVATE Catch2::Catch2WithMain esi-common esicore) -add_esi_test(test_utils utils_test.cc) -target_link_libraries(test_utils PRIVATE Catch2::Catch2WithMain esi-common) -add_esi_test(test_vars vars_test.cc) -target_link_libraries(test_vars PRIVATE Catch2::Catch2WithMain esi-common esicore) -add_esi_test(test_gzip gzip_test.cc) -target_link_libraries(test_gzip PRIVATE Catch2::Catch2WithMain esi-common) +add_esi_test(test_docnode_esi docnode_test.cc) +target_link_libraries(test_docnode_esi PRIVATE Catch2::Catch2WithMain esi-common esicore) +add_esi_test(test_parser_esi parser_test.cc) +target_link_libraries(test_parser_esi PRIVATE Catch2::Catch2WithMain esi-common esicore) +add_esi_test(test_processor_esi processor_test.cc) +target_link_libraries(test_processor_esi PRIVATE Catch2::Catch2WithMain esi-common esicore) +add_esi_test(test_utils_esi utils_test.cc) +target_link_libraries(test_utils_esi PRIVATE Catch2::Catch2WithMain esi-common) +add_esi_test(test_vars_esi vars_test.cc) +target_link_libraries(test_vars_esi PRIVATE Catch2::Catch2WithMain esi-common esicore) +add_esi_test(test_gzip_esi gzip_test.cc) +target_link_libraries(test_gzip_esi PRIVATE Catch2::Catch2WithMain esi-common) diff --git a/src/iocore/cache/CMakeLists.txt b/src/iocore/cache/CMakeLists.txt index 2775cef4e35..b96cf197718 100644 --- a/src/iocore/cache/CMakeLists.txt +++ b/src/iocore/cache/CMakeLists.txt @@ -60,7 +60,7 @@ if(BUILD_TESTING) macro(add_cache_test name) add_executable(${name} unit_tests/main.cc unit_tests/stub.cc unit_tests/CacheTestHandler.cc ${ARGN}) target_link_libraries(${name} PRIVATE ts::inkcache Catch2::Catch2WithMain) - add_catch2_test(NAME test_cache_${name} COMMAND $) + add_catch2_test(NAME ${name} COMMAND $) endmacro() add_cache_test(Cache unit_tests/test_Cache.cc) @@ -76,20 +76,20 @@ if(BUILD_TESTING) endforeach() add_cache_test(Populated_Cache_Disk_Failure unit_tests/test_Populated_Cache_Disk_Failure.cc) endif() - add_cache_test(CacheDir unit_tests/test_CacheDir.cc) - add_cache_test(CacheVol unit_tests/test_CacheVol.cc) - add_cache_test(RWW unit_tests/test_RWW.cc) - add_cache_test(Alternate_L_to_S unit_tests/test_Alternate_L_to_S.cc) - add_cache_test(Alternate_S_to_L unit_tests/test_Alternate_S_to_L.cc) - add_cache_test(Alternate_L_to_S_remove_L unit_tests/test_Alternate_L_to_S_remove_L.cc) - add_cache_test(Alternate_L_to_S_remove_S unit_tests/test_Alternate_L_to_S_remove_S.cc) - add_cache_test(Alternate_S_to_L_remove_L unit_tests/test_Alternate_S_to_L_remove_L.cc) - add_cache_test(Alternate_S_to_L_remove_S unit_tests/test_Alternate_S_to_L_remove_S.cc) - add_cache_test(Update_L_to_S unit_tests/test_Update_L_to_S.cc) - add_cache_test(Update_S_to_L unit_tests/test_Update_S_to_L.cc) - add_cache_test(Update_Header unit_tests/test_Update_header.cc) - add_cache_test(CacheStripe unit_tests/test_Stripe.cc) - add_cache_test(CacheAggregateWriteBuffer unit_tests/test_AggregateWriteBuffer.cc) + add_cache_test(test_cache_CacheDir unit_tests/test_CacheDir.cc) + add_cache_test(test_cache_CacheVol unit_tests/test_CacheVol.cc) + add_cache_test(test_cache_RWW unit_tests/test_RWW.cc) + add_cache_test(test_cache_Alternate_L_to_S unit_tests/test_Alternate_L_to_S.cc) + add_cache_test(test_cache_Alternate_S_to_L unit_tests/test_Alternate_S_to_L.cc) + add_cache_test(test_cache_Alternate_L_to_S_remove_L unit_tests/test_Alternate_L_to_S_remove_L.cc) + add_cache_test(test_cache_Alternate_L_to_S_remove_S unit_tests/test_Alternate_L_to_S_remove_S.cc) + add_cache_test(test_cache_Alternate_S_to_L_remove_L unit_tests/test_Alternate_S_to_L_remove_L.cc) + add_cache_test(test_cache_Alternate_S_to_L_remove_S unit_tests/test_Alternate_S_to_L_remove_S.cc) + add_cache_test(test_cache_Update_L_to_S unit_tests/test_Update_L_to_S.cc) + add_cache_test(test_cache_Update_S_to_L unit_tests/test_Update_S_to_L.cc) + add_cache_test(test_cache_Update_Header unit_tests/test_Update_header.cc) + add_cache_test(test_cache_CacheStripe unit_tests/test_Stripe.cc) + add_cache_test(test_cache_CacheAggregateWriteBuffer unit_tests/test_AggregateWriteBuffer.cc) endif() diff --git a/src/iocore/hostdb/CMakeLists.txt b/src/iocore/hostdb/CMakeLists.txt index 7cc9ada3248..a3c52e34559 100644 --- a/src/iocore/hostdb/CMakeLists.txt +++ b/src/iocore/hostdb/CMakeLists.txt @@ -35,12 +35,12 @@ if(BUILD_TESTING) ts::inkhostdb ) - add_executable(test_HostFile test_HostFile.cc HostFile.cc HostDBInfo.cc) - target_link_libraries(test_HostFile PRIVATE ts::tscore ts::tsutil ts::inkevent Catch2::Catch2WithMain) - add_catch2_test(NAME test_hostdb_HostFile COMMAND $) + add_executable(test_hostdb_HostFile test_HostFile.cc HostFile.cc HostDBInfo.cc) + target_link_libraries(test_hostdb_HostFile PRIVATE ts::tscore ts::tsutil ts::inkevent Catch2::Catch2WithMain) + add_catch2_test(NAME test_hostdb_HostFile COMMAND $) - add_executable(test_RefCountCache test_RefCountCache.cc) - target_link_libraries(test_RefCountCache PRIVATE ts::tscore ts::tsutil ts::inkevent Catch2::Catch2WithMain) - add_catch2_test(NAME test_hostdb_RefCountCache COMMAND $) + add_executable(test_hostdb_RefCountCache test_RefCountCache.cc) + target_link_libraries(test_hostdb_RefCountCache PRIVATE ts::tscore ts::tsutil ts::inkevent Catch2::Catch2WithMain) + add_test(NAME test_hostdb_RefCountCache COMMAND $) endif() From 919736be9f72cf5fb806aa7e8c975a3c5b8f5257 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 24 Nov 2025 20:42:02 -0600 Subject: [PATCH 02/12] Fix some tests --- src/mgmt/rpc/server/unit_tests/test_rpcserver.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc b/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc index 0385ac43087..191deb7c252 100644 --- a/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc +++ b/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc @@ -71,8 +71,18 @@ add_method_handler(const std::string &name, Func &&call) namespace { -const std::string sockPath{"tests/var/jsonrpc20_test.sock"}; -const std::string lockPath{"tests/var/jsonrpc20_test.lock"}; + +std::string +pid_specific_file(const char *suffix) +{ + char buffer[PATH_MAX]; + + snprintf(buffer, PATH_MAX, "tests/var/jsonrpc20_test.%d.%s", getpid(), suffix); + return std::string(buffer); +} + +const std::string sockPath = pid_specific_file("sock"); +const std::string lockPath = pid_specific_file("lock"); constexpr int default_backlog{5}; constexpr int default_maxRetriesOnTransientErrors{64}; constexpr size_t default_incoming_req_max_size{32000 * 3}; From f4489e189982d324d6adaabb5f99169e2281dd79 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 24 Nov 2025 20:44:04 -0600 Subject: [PATCH 03/12] Dont also add_test --- lib/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 05e1c379176..6a398da8d2a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -52,7 +52,6 @@ if(BUILD_TESTING) # we ensure declaration order execution via --order decl. macro(add_catch2_test) cmake_parse_arguments(CATCH2_TEST "" "NAME" "COMMAND" ${ARGN}) - add_test(NAME ${CATCH2_TEST_NAME} COMMAND ${CATCH2_TEST_COMMAND} --order decl) catch_discover_tests(${CATCH2_TEST_NAME}) endmacro() endif() From 86fe80bc48dad074de397cddee1012c9a25f8f70 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 1 Dec 2025 21:20:33 -0700 Subject: [PATCH 04/12] cleanup and allow passing properites --- lib/CMakeLists.txt | 4 ++-- lib/swoc/unit_tests/CMakeLists.txt | 2 +- plugins/cachekey/CMakeLists.txt | 2 +- .../access_control/unit_tests/CMakeLists.txt | 2 +- plugins/experimental/cookie_remap/CMakeLists.txt | 2 +- .../experimental/ja4_fingerprint/CMakeLists.txt | 2 +- .../stale_response/unit_tests/CMakeLists.txt | 2 +- .../experimental/txn_box/unit_tests/CMakeLists.txt | 2 +- .../uri_signing/unit_tests/CMakeLists.txt | 7 +++---- plugins/ja3_fingerprint/CMakeLists.txt | 2 +- .../origin_server_auth/unit_tests/CMakeLists.txt | 2 +- plugins/prefetch/test/CMakeLists.txt | 2 +- plugins/slice/unit-tests/CMakeLists.txt | 8 ++++---- plugins/traffic_dump/unit_tests/CMakeLists.txt | 2 +- plugins/xdebug/CMakeLists.txt | 2 +- src/iocore/cache/CMakeLists.txt | 2 +- src/iocore/eventsystem/CMakeLists.txt | 6 +++--- src/iocore/hostdb/CMakeLists.txt | 4 ++-- src/iocore/io_uring/CMakeLists.txt | 2 +- src/iocore/net/CMakeLists.txt | 7 ++++--- src/mgmt/rpc/CMakeLists.txt | 4 ++-- src/proxy/hdrs/CMakeLists.txt | 4 ++-- src/proxy/http/CMakeLists.txt | 2 +- src/proxy/http/remap/unit-tests/CMakeLists.txt | 14 +++++++------- src/proxy/http/unit_tests/CMakeLists.txt | 2 +- src/proxy/http2/CMakeLists.txt | 4 ++-- src/proxy/http3/CMakeLists.txt | 4 ++-- src/proxy/logging/CMakeLists.txt | 4 ++-- src/proxy/unit_tests/CMakeLists.txt | 2 +- src/records/CMakeLists.txt | 2 +- src/tscore/CMakeLists.txt | 2 +- src/tsutil/CMakeLists.txt | 2 +- 32 files changed, 55 insertions(+), 55 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 6a398da8d2a..2bea3e65c14 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -51,8 +51,8 @@ if(BUILD_TESTING) # macro allows us to add common command line arguments to all tests. For now, # we ensure declaration order execution via --order decl. macro(add_catch2_test) - cmake_parse_arguments(CATCH2_TEST "" "NAME" "COMMAND" ${ARGN}) - catch_discover_tests(${CATCH2_TEST_NAME}) + cmake_parse_arguments(CATCH2_TEST "" "NAME" "" ${ARGN}) + catch_discover_tests(${CATCH2_TEST_NAME} ${ARGN}) endmacro() endif() diff --git a/lib/swoc/unit_tests/CMakeLists.txt b/lib/swoc/unit_tests/CMakeLists.txt index 8535367a3ae..dc644d5fa93 100644 --- a/lib/swoc/unit_tests/CMakeLists.txt +++ b/lib/swoc/unit_tests/CMakeLists.txt @@ -47,4 +47,4 @@ if(CMAKE_COMPILER_IS_GNUCXX) endif() endif() -add_catch2_test(NAME test_libswoc COMMAND test_libswoc) +add_catch2_test(NAME test_libswoc) diff --git a/plugins/cachekey/CMakeLists.txt b/plugins/cachekey/CMakeLists.txt index 65c506c3525..1dfc82e4667 100644 --- a/plugins/cachekey/CMakeLists.txt +++ b/plugins/cachekey/CMakeLists.txt @@ -25,5 +25,5 @@ if(BUILD_TESTING) target_include_directories(pattern_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(pattern_test PRIVATE CACHEKEY_UNIT_TEST) target_link_libraries(pattern_test PRIVATE Catch2::Catch2WithMain libswoc::libswoc ts::tsutil) - add_catch2_test(NAME pattern_test COMMAND pattern_test) + add_catch2_test(NAME pattern_test) endif() diff --git a/plugins/experimental/access_control/unit_tests/CMakeLists.txt b/plugins/experimental/access_control/unit_tests/CMakeLists.txt index b2c6d7c8bd2..6c6f1559255 100644 --- a/plugins/experimental/access_control/unit_tests/CMakeLists.txt +++ b/plugins/experimental/access_control/unit_tests/CMakeLists.txt @@ -23,4 +23,4 @@ add_executable( target_link_libraries(test_access_control PRIVATE ts::tscore OpenSSL::SSL OpenSSL::Crypto Catch2::Catch2WithMain) target_compile_definitions(test_access_control PRIVATE ACCESS_CONTROL_UNIT_TEST) -add_catch2_test(NAME test_access_control COMMAND test_access_control) +add_catch2_test(NAME test_access_control) diff --git a/plugins/experimental/cookie_remap/CMakeLists.txt b/plugins/experimental/cookie_remap/CMakeLists.txt index ece374ce11b..78793fcf413 100644 --- a/plugins/experimental/cookie_remap/CMakeLists.txt +++ b/plugins/experimental/cookie_remap/CMakeLists.txt @@ -28,5 +28,5 @@ if(BUILD_TESTING) target_link_libraries(test_cookiejar PRIVATE Catch2::Catch2WithMain) - add_catch2_test(NAME test_cookiejar COMMAND test_cookiejar) + add_catch2_test(NAME test_cookiejar) endif() diff --git a/plugins/experimental/ja4_fingerprint/CMakeLists.txt b/plugins/experimental/ja4_fingerprint/CMakeLists.txt index d9ec658ce5b..586b73011be 100644 --- a/plugins/experimental/ja4_fingerprint/CMakeLists.txt +++ b/plugins/experimental/ja4_fingerprint/CMakeLists.txt @@ -23,5 +23,5 @@ if(BUILD_TESTING) add_executable(test_ja4 test_ja4.cc ja4.cc tls_client_hello_summary.cc) target_link_libraries(test_ja4 PRIVATE Catch2::Catch2WithMain) - add_catch2_test(NAME test_ja4 COMMAND test_ja4) + add_catch2_test(NAME test_ja4) endif() diff --git a/plugins/experimental/stale_response/unit_tests/CMakeLists.txt b/plugins/experimental/stale_response/unit_tests/CMakeLists.txt index 9fb7d3d3848..8798e3271a3 100644 --- a/plugins/experimental/stale_response/unit_tests/CMakeLists.txt +++ b/plugins/experimental/stale_response/unit_tests/CMakeLists.txt @@ -20,4 +20,4 @@ add_executable(test_stale_response test_DirectiveParser.cc test_BodyData.cc ${PR target_include_directories(test_stale_response PRIVATE "${PROJECT_SOURCE_DIR}") target_link_libraries(test_stale_response PRIVATE ts::tsutil libswoc::libswoc Catch2::Catch2WithMain) -add_catch2_test(NAME test_stale_response COMMAND test_stale_response) +add_catch2_test(NAME test_stale_response) diff --git a/plugins/experimental/txn_box/unit_tests/CMakeLists.txt b/plugins/experimental/txn_box/unit_tests/CMakeLists.txt index 51beaae1b9b..b0321974bfc 100644 --- a/plugins/experimental/txn_box/unit_tests/CMakeLists.txt +++ b/plugins/experimental/txn_box/unit_tests/CMakeLists.txt @@ -29,4 +29,4 @@ target_link_libraries( # After fighting with CMake over the include paths, it's just not worth it to be correct. # target_link_libraries should make this work but it doesn't. I can't figure out why. target_include_directories(test_txn_box PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../plugin/include) -add_catch2_test(NAME test_txn_box COMMAND test_txn_box) +add_catch2_test(NAME test_txn_box) diff --git a/plugins/experimental/uri_signing/unit_tests/CMakeLists.txt b/plugins/experimental/uri_signing/unit_tests/CMakeLists.txt index 38525b13c1d..75e7dfe41aa 100644 --- a/plugins/experimental/uri_signing/unit_tests/CMakeLists.txt +++ b/plugins/experimental/uri_signing/unit_tests/CMakeLists.txt @@ -46,8 +46,7 @@ target_link_libraries( ts::inknet ts::overridable_txn_vars ) -add_catch2_test(NAME uri_signing_test COMMAND uri_signing_test) -set_tests_properties( - uri_signing_test - PROPERTIES ENVIRONMENT "LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/uri_signing_test_leak_suppression.txt" +add_catch2_test( + NAME uri_signing_test PROPERTIES ENVIRONMENT + "LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/uri_signing_test_leak_suppression.txt" ) diff --git a/plugins/ja3_fingerprint/CMakeLists.txt b/plugins/ja3_fingerprint/CMakeLists.txt index c19f05ff6b9..d366f5f95d6 100644 --- a/plugins/ja3_fingerprint/CMakeLists.txt +++ b/plugins/ja3_fingerprint/CMakeLists.txt @@ -24,5 +24,5 @@ verify_remap_plugin(ja3_fingerprint) if(BUILD_TESTING) add_executable(test_ja3_fingerprint ja3_utils.cc test_utils.cc) target_link_libraries(test_ja3_fingerprint PRIVATE Catch2::Catch2WithMain) - add_catch2_test(NAME test_ja3_fingerprint COMMAND test_ja3_fingerprint) + add_catch2_test(NAME test_ja3_fingerprint) endif() diff --git a/plugins/origin_server_auth/unit_tests/CMakeLists.txt b/plugins/origin_server_auth/unit_tests/CMakeLists.txt index 99a813b64ea..722e4523f0c 100644 --- a/plugins/origin_server_auth/unit_tests/CMakeLists.txt +++ b/plugins/origin_server_auth/unit_tests/CMakeLists.txt @@ -21,4 +21,4 @@ target_link_libraries(test_origin_server_auth PRIVATE OpenSSL::Crypto Catch2::Ca target_compile_definitions(test_origin_server_auth PRIVATE AWS_AUTH_V4_UNIT_TEST) -add_catch2_test(NAME test_origin_server_auth COMMAND test_origin_server_auth) +add_catch2_test(NAME test_origin_server_auth) diff --git a/plugins/prefetch/test/CMakeLists.txt b/plugins/prefetch/test/CMakeLists.txt index a7c7b4405f5..cb9e77fc61d 100644 --- a/plugins/prefetch/test/CMakeLists.txt +++ b/plugins/prefetch/test/CMakeLists.txt @@ -21,4 +21,4 @@ target_link_libraries(test_evaluate PRIVATE Catch2::Catch2WithMain) target_compile_definitions(test_evaluate PRIVATE PREFETCH_UNIT_TEST) -add_catch2_test(NAME test_evaluate COMMAND test_evaluate) +add_catch2_test(NAME test_evaluate) diff --git a/plugins/slice/unit-tests/CMakeLists.txt b/plugins/slice/unit-tests/CMakeLists.txt index e50cb0e7e20..93d812505eb 100644 --- a/plugins/slice/unit-tests/CMakeLists.txt +++ b/plugins/slice/unit-tests/CMakeLists.txt @@ -18,19 +18,19 @@ add_executable(test_content_range test_content_range.cc ${PROJECT_SOURCE_DIR}/ContentRange.cc) target_compile_definitions(test_content_range PRIVATE UNITTEST) target_link_libraries(test_content_range PRIVATE Catch2::Catch2WithMain ts::tsutil) -add_catch2_test(NAME test_content_range COMMAND test_content_range) +add_catch2_test(NAME test_content_range) add_executable(test_range test_range.cc ${PROJECT_SOURCE_DIR}/Range.cc) target_compile_definitions(test_range PRIVATE UNITTEST) target_link_libraries(test_range PRIVATE Catch2::Catch2WithMain ts::tsutil) -add_catch2_test(NAME test_range COMMAND test_range) +add_catch2_test(NAME test_range) add_executable(test_config test_config.cc ${PROJECT_SOURCE_DIR}/Config.cc ${PROJECT_SOURCE_DIR}/ObjectSizeCache.cc) target_compile_definitions(test_config PRIVATE UNITTEST) target_link_libraries(test_config PRIVATE Catch2::Catch2WithMain ts::tsutil) -add_catch2_test(NAME test_config COMMAND test_config) +add_catch2_test(NAME test_config) add_executable(test_cache test_cache.cc ${PROJECT_SOURCE_DIR}/ObjectSizeCache.cc) target_compile_definitions(test_cache PRIVATE UNITTEST) target_link_libraries(test_cache PRIVATE Catch2::Catch2WithMain ts::tsutil) -add_catch2_test(NAME test_cache COMMAND test_cache) +add_catch2_test(NAME test_cache) diff --git a/plugins/traffic_dump/unit_tests/CMakeLists.txt b/plugins/traffic_dump/unit_tests/CMakeLists.txt index 6b59e9a9d6f..297360c38d2 100644 --- a/plugins/traffic_dump/unit_tests/CMakeLists.txt +++ b/plugins/traffic_dump/unit_tests/CMakeLists.txt @@ -20,4 +20,4 @@ add_executable(test_traffic_dump test_json_utils.cc test_sensitive_fields.cc ${P target_include_directories(test_traffic_dump PRIVATE "${PROJECT_SOURCE_DIR}") target_link_libraries(test_traffic_dump PRIVATE Catch2::Catch2WithMain) -add_catch2_test(NAME test_traffic_dump COMMAND test_traffic_dump) +add_catch2_test(NAME test_traffic_dump) diff --git a/plugins/xdebug/CMakeLists.txt b/plugins/xdebug/CMakeLists.txt index 716583536fc..435ee3356b8 100644 --- a/plugins/xdebug/CMakeLists.txt +++ b/plugins/xdebug/CMakeLists.txt @@ -23,5 +23,5 @@ if(BUILD_TESTING) add_executable(test_xdebug unit_tests/test_xdebug_utils.cc xdebug_utils.cc xdebug_escape.cc) target_include_directories(test_xdebug PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(test_xdebug PRIVATE Catch2::Catch2WithMain libswoc::libswoc) - add_catch2_test(NAME test_xdebug COMMAND test_xdebug) + add_catch2_test(NAME test_xdebug) endif() diff --git a/src/iocore/cache/CMakeLists.txt b/src/iocore/cache/CMakeLists.txt index b96cf197718..84a275cc954 100644 --- a/src/iocore/cache/CMakeLists.txt +++ b/src/iocore/cache/CMakeLists.txt @@ -60,7 +60,7 @@ if(BUILD_TESTING) macro(add_cache_test name) add_executable(${name} unit_tests/main.cc unit_tests/stub.cc unit_tests/CacheTestHandler.cc ${ARGN}) target_link_libraries(${name} PRIVATE ts::inkcache Catch2::Catch2WithMain) - add_catch2_test(NAME ${name} COMMAND $) + add_catch2_test(NAME ${name}) endmacro() add_cache_test(Cache unit_tests/test_Cache.cc) diff --git a/src/iocore/eventsystem/CMakeLists.txt b/src/iocore/eventsystem/CMakeLists.txt index 1eaf5cd29d8..cd29b1ebeb3 100644 --- a/src/iocore/eventsystem/CMakeLists.txt +++ b/src/iocore/eventsystem/CMakeLists.txt @@ -60,9 +60,9 @@ if(BUILD_TESTING) add_executable(test_MIOBufferWriter unit_tests/test_MIOBufferWriter.cc) target_link_libraries(test_MIOBufferWriter libswoc::libswoc Catch2::Catch2WithMain) - add_catch2_test(NAME test_EventSystem COMMAND test_EventSystem) - add_catch2_test(NAME test_IOBuffer COMMAND test_IOBuffer) - add_catch2_test(NAME test_MIOBufferWriter COMMAND test_MIOBufferWriter) + add_catch2_test(NAME test_EventSystem) + add_catch2_test(NAME test_IOBuffer) + add_catch2_test(NAME test_MIOBufferWriter) endif() diff --git a/src/iocore/hostdb/CMakeLists.txt b/src/iocore/hostdb/CMakeLists.txt index a3c52e34559..d1c6ed6fc73 100644 --- a/src/iocore/hostdb/CMakeLists.txt +++ b/src/iocore/hostdb/CMakeLists.txt @@ -37,10 +37,10 @@ if(BUILD_TESTING) add_executable(test_hostdb_HostFile test_HostFile.cc HostFile.cc HostDBInfo.cc) target_link_libraries(test_hostdb_HostFile PRIVATE ts::tscore ts::tsutil ts::inkevent Catch2::Catch2WithMain) - add_catch2_test(NAME test_hostdb_HostFile COMMAND $) + add_catch2_test(NAME test_hostdb_HostFile) add_executable(test_hostdb_RefCountCache test_RefCountCache.cc) target_link_libraries(test_hostdb_RefCountCache PRIVATE ts::tscore ts::tsutil ts::inkevent Catch2::Catch2WithMain) - add_test(NAME test_hostdb_RefCountCache COMMAND $) + add_test(NAME test_hostdb_RefCountCache COMMAND test_hostdb_RefCountCache) endif() diff --git a/src/iocore/io_uring/CMakeLists.txt b/src/iocore/io_uring/CMakeLists.txt index 20cb6633cc2..d2567811fd6 100644 --- a/src/iocore/io_uring/CMakeLists.txt +++ b/src/iocore/io_uring/CMakeLists.txt @@ -30,7 +30,7 @@ if(BUILD_TESTING) target_include_directories(test_iouring PRIVATE ${CATCH_INCLUDE_DIR}) - add_catch2_test(NAME test_iouring COMMAND $) + add_catch2_test(NAME test_iouring) endif() clang_tidy_check(inkuring) diff --git a/src/iocore/net/CMakeLists.txt b/src/iocore/net/CMakeLists.txt index a416ec18fe2..d296e8168c1 100644 --- a/src/iocore/net/CMakeLists.txt +++ b/src/iocore/net/CMakeLists.txt @@ -172,12 +172,13 @@ if(BUILD_TESTING) endif() set(LIBINKNET_UNIT_TEST_DIR "${CMAKE_SOURCE_DIR}/src/iocore/net/unit_tests") target_compile_definitions(test_net PRIVATE LIBINKNET_UNIT_TEST_DIR=${LIBINKNET_UNIT_TEST_DIR}) - add_catch2_test(NAME test_net COMMAND test_net) - if(NOT APPLE) + if(APPLE) # Disable ORD violation caused by double definition inside a stub file libinknet_stub.cc # see remap_test_dlopen_leak_suppression.txt for more info. - set_tests_properties(test_net PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_odr_violation=0") + add_catch2_test(NAME test_net PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_odr_violation=0") + else() + add_catch2_test(NAME test_net) endif() endif() diff --git a/src/mgmt/rpc/CMakeLists.txt b/src/mgmt/rpc/CMakeLists.txt index bee0f8929fd..1fface959d2 100644 --- a/src/mgmt/rpc/CMakeLists.txt +++ b/src/mgmt/rpc/CMakeLists.txt @@ -63,13 +63,13 @@ if(BUILD_TESTING) target_link_libraries( test_jsonrpc ts::tsutil Catch2::Catch2WithMain ts::rpcpublichandlers ts::jsonrpc_protocol libswoc::libswoc ) - add_catch2_test(NAME test_jsonrpc COMMAND test_jsonrpc) + add_catch2_test(NAME test_jsonrpc) add_executable( test_jsonrpcserver server/unit_tests/test_rpcserver.cc ${CMAKE_SOURCE_DIR}/src/shared/rpc/IPCSocketClient.cc ) target_link_libraries(test_jsonrpcserver Catch2::Catch2WithMain ts::jsonrpc_server ts::inkevent libswoc::libswoc) - add_catch2_test(NAME test_jsonrpcserver COMMAND test_jsonrpcserver) + add_catch2_test(NAME test_jsonrpcserver) endif() clang_tidy_check(jsonrpc_protocol) diff --git a/src/proxy/hdrs/CMakeLists.txt b/src/proxy/hdrs/CMakeLists.txt index 09dfc6f8b6c..abbd00bf707 100644 --- a/src/proxy/hdrs/CMakeLists.txt +++ b/src/proxy/hdrs/CMakeLists.txt @@ -57,13 +57,13 @@ if(BUILD_TESTING) target_link_libraries( test_proxy_hdrs PRIVATE ts::hdrs ts::tscore ts::inkevent libswoc::libswoc Catch2::Catch2WithMain lshpack ) - add_catch2_test(NAME test_proxy_hdrs COMMAND test_proxy_hdrs) + add_catch2_test(NAME test_proxy_hdrs) add_executable(test_proxy_hdrs_xpack unit_tests/test_XPACK.cc) target_link_libraries( test_proxy_hdrs_xpack PRIVATE ts::hdrs ts::tscore ts::tsutil libswoc::libswoc Catch2::Catch2WithMain lshpack ) - add_catch2_test(NAME test_proxy_hdrs_xpack COMMAND test_proxy_hdrs_xpack) + add_catch2_test(NAME test_proxy_hdrs_xpack) endif() clang_tidy_check(hdrs) diff --git a/src/proxy/http/CMakeLists.txt b/src/proxy/http/CMakeLists.txt index 55cf7ebd36e..1a059adb75f 100644 --- a/src/proxy/http/CMakeLists.txt +++ b/src/proxy/http/CMakeLists.txt @@ -66,7 +66,7 @@ if(BUILD_TESTING) unit_tests/test_PreWarm.cc ForwardedConfig.cc HttpBodyFactory.cc ) target_link_libraries(test_proxy_http PRIVATE Catch2::Catch2WithMain hdrs tscore inkevent proxy logging) - add_catch2_test(NAME test_proxy_http COMMAND test_proxy_http) + add_catch2_test(NAME test_proxy_http) endif(BUILD_TESTING) clang_tidy_check(http) diff --git a/src/proxy/http/remap/unit-tests/CMakeLists.txt b/src/proxy/http/remap/unit-tests/CMakeLists.txt index 4de87e8f08d..c9ea30f0938 100644 --- a/src/proxy/http/remap/unit-tests/CMakeLists.txt +++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt @@ -94,7 +94,7 @@ if(NOT APPLE) endif() if(NOT APPLE) - add_catch2_test(NAME test_PluginDso COMMAND $) + add_catch2_test(NAME test_PluginDso) endif() ### test_PluginFactory ######################################################################## @@ -133,7 +133,7 @@ target_link_libraries( ) if(NOT APPLE) - add_catch2_test(NAME test_PluginFactory COMMAND $) + add_catch2_test(NAME test_PluginFactory) endif() ### test_RemapPluginInfo ######################################################################## @@ -166,7 +166,7 @@ target_link_libraries( ) if(NOT APPLE) - add_catch2_test(NAME test_RemapPluginInfo COMMAND $) + add_catch2_test(NAME test_RemapPluginInfo) endif() # not in the same if as the above will be removed shortly. @@ -205,7 +205,7 @@ target_link_libraries( yaml-cpp::yaml-cpp ) -add_catch2_test(NAME test_NextHopStrategyFactory COMMAND $) +add_catch2_test(NAME test_NextHopStrategyFactory) ### test_NextHopRoundRobin ######################################################################## @@ -236,7 +236,7 @@ target_link_libraries( yaml-cpp::yaml-cpp ) -add_catch2_test(NAME test_NextHopRoundRobin COMMAND $) +add_catch2_test(NAME test_NextHopRoundRobin) ### test_NextHopConsistentHash ######################################################################## @@ -269,7 +269,7 @@ target_link_libraries( yaml-cpp::yaml-cpp ) -add_catch2_test(NAME test_NextHopConsistentHash COMMAND $) +add_catch2_test(NAME test_NextHopConsistentHash) ### test_RemapRules ######################################################################## add_executable(test_RemapRules "${PROJECT_SOURCE_DIR}/src/iocore/cache/unit_tests/stub.cc" test_RemapRules.cc) @@ -287,4 +287,4 @@ target_link_libraries( ts::jsonrpc_protocol ) -add_catch2_test(NAME test_RemapRules COMMAND $) +add_catch2_test(NAME test_RemapRules) diff --git a/src/proxy/http/unit_tests/CMakeLists.txt b/src/proxy/http/unit_tests/CMakeLists.txt index a487bef7435..ce43b420e9e 100644 --- a/src/proxy/http/unit_tests/CMakeLists.txt +++ b/src/proxy/http/unit_tests/CMakeLists.txt @@ -39,4 +39,4 @@ target_link_libraries( ts::jsonrpc_protocol ) -add_catch2_test(NAME test_http COMMAND $) +add_catch2_test(NAME test_http) diff --git a/src/proxy/http2/CMakeLists.txt b/src/proxy/http2/CMakeLists.txt index e769fe36225..4d13906dfc0 100644 --- a/src/proxy/http2/CMakeLists.txt +++ b/src/proxy/http2/CMakeLists.txt @@ -50,11 +50,11 @@ if(BUILD_TESTING) unit_tests/test_HpackIndexingTable.cc ) target_link_libraries(test_http2 PRIVATE Catch2::Catch2WithMain records tscore hdrs inkevent) - add_catch2_test(NAME test_http2 COMMAND test_http2) + add_catch2_test(NAME test_http2) add_executable(test_Http2DependencyTree unit_tests/test_Http2DependencyTree.cc) target_link_libraries(test_Http2DependencyTree PRIVATE Catch2::Catch2WithMain tscore libswoc::libswoc) - add_catch2_test(NAME test_Http2DependencyTree COMMAND test_Http2DependencyTree) + add_catch2_test(NAME test_Http2DependencyTree) add_executable(test_HPACK test_HPACK.cc HPACK.cc) target_link_libraries(test_HPACK PRIVATE tscore hdrs inkevent) diff --git a/src/proxy/http3/CMakeLists.txt b/src/proxy/http3/CMakeLists.txt index 4a492a862ac..af413cfa0d3 100644 --- a/src/proxy/http3/CMakeLists.txt +++ b/src/proxy/http3/CMakeLists.txt @@ -70,7 +70,7 @@ target_link_libraries( ts::hdrs ts::tscore ) -add_catch2_test(NAME test_http3 COMMAND test_http3) +add_catch2_test(NAME test_http3) add_executable(test_qpack test/main_qpack.cc test/test_QPACK.cc QPACK.cc) target_link_libraries( @@ -83,6 +83,6 @@ target_link_libraries( ts::hdrs ts::tscore ) -add_catch2_test(NAME test_qpack COMMAND test_qpack) +add_catch2_test(NAME test_qpack) clang_tidy_check(http3) diff --git a/src/proxy/logging/CMakeLists.txt b/src/proxy/logging/CMakeLists.txt index 27da4f05d85..1257ca7596d 100644 --- a/src/proxy/logging/CMakeLists.txt +++ b/src/proxy/logging/CMakeLists.txt @@ -42,12 +42,12 @@ if(BUILD_TESTING) add_executable(test_LogUtils LogUtils.cc unit-tests/test_LogUtils.cc) target_compile_definitions(test_LogUtils PRIVATE TEST_LOG_UTILS) target_link_libraries(test_LogUtils tscore ts::inkevent records Catch2::Catch2WithMain) - add_catch2_test(NAME test_LogUtils COMMAND test_LogUtils) + add_catch2_test(NAME test_LogUtils) add_executable(test_RolledLogDeleter LogUtils.cc RolledLogDeleter.cc unit-tests/test_LogUtils.cc) target_compile_definitions(test_RolledLogDeleter PRIVATE TEST_LOG_UTILS) target_link_libraries(test_RolledLogDeleter tscore ts::inkevent records Catch2::Catch2WithMain) - add_catch2_test(NAME test_RolledLogDeleter COMMAND test_RolledLogDeleter) + add_catch2_test(NAME test_RolledLogDeleter) endif() clang_tidy_check(logging) diff --git a/src/proxy/unit_tests/CMakeLists.txt b/src/proxy/unit_tests/CMakeLists.txt index b21fb327155..45570009103 100644 --- a/src/proxy/unit_tests/CMakeLists.txt +++ b/src/proxy/unit_tests/CMakeLists.txt @@ -25,4 +25,4 @@ if(NOT APPLE) target_link_options(test_proxy PRIVATE -Wl,--allow-multiple-definition) endif() -add_catch2_test(NAME test_proxy COMMAND $) +add_catch2_test(NAME test_proxy) diff --git a/src/records/CMakeLists.txt b/src/records/CMakeLists.txt index 6a4bc9ff2fc..78d559d3daa 100644 --- a/src/records/CMakeLists.txt +++ b/src/records/CMakeLists.txt @@ -42,7 +42,7 @@ target_link_libraries( if(BUILD_TESTING) add_executable(test_records unit_tests/unit_test_main.cc unit_tests/test_RecHttp.cc unit_tests/test_RecRegister.cc) target_link_libraries(test_records PRIVATE records Catch2::Catch2 ts::tscore libswoc::libswoc ts::inkevent) - add_catch2_test(NAME test_records COMMAND test_records) + add_catch2_test(NAME test_records) endif() clang_tidy_check(records) diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt index 03ade9cfda0..db137fbd1f8 100644 --- a/src/tscore/CMakeLists.txt +++ b/src/tscore/CMakeLists.txt @@ -183,7 +183,7 @@ if(BUILD_TESTING) target_link_libraries(test_tscore PRIVATE hwloc::hwloc) endif() - add_catch2_test(NAME test_tscore COMMAND $) + add_catch2_test(NAME test_tscore) endif() clang_tidy_check(tscore) diff --git a/src/tsutil/CMakeLists.txt b/src/tsutil/CMakeLists.txt index 49be0fb5538..46d87231fd9 100644 --- a/src/tsutil/CMakeLists.txt +++ b/src/tsutil/CMakeLists.txt @@ -85,7 +85,7 @@ if(BUILD_TESTING) target_link_libraries(test_tsutil PRIVATE tsutil Catch2::Catch2WithMain) - add_catch2_test(NAME test_tsutil COMMAND $) + add_catch2_test(NAME test_tsutil) endif() clang_tidy_check(tsutil) From 3fd03ead89c58b600bdece368d3e2af625914cd8 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Tue, 2 Dec 2025 12:55:38 -0700 Subject: [PATCH 05/12] cleanup and allow passing properites --- .../http/remap/unit-tests/CMakeLists.txt | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/proxy/http/remap/unit-tests/CMakeLists.txt b/src/proxy/http/remap/unit-tests/CMakeLists.txt index c9ea30f0938..b850fab185b 100644 --- a/src/proxy/http/remap/unit-tests/CMakeLists.txt +++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt @@ -94,7 +94,13 @@ if(NOT APPLE) endif() if(NOT APPLE) - add_catch2_test(NAME test_PluginDso) + add_catch2_test( + NAME + test_PluginDso + PROPERTIES + ENVIRONMENT + "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" + ) endif() ### test_PluginFactory ######################################################################## @@ -133,7 +139,13 @@ target_link_libraries( ) if(NOT APPLE) - add_catch2_test(NAME test_PluginFactory) + add_catch2_test( + NAME + test_PluginFactory + PROPERTIES + ENVIRONMENT + "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" + ) endif() ### test_RemapPluginInfo ######################################################################## @@ -166,20 +178,15 @@ target_link_libraries( ) if(NOT APPLE) - add_catch2_test(NAME test_RemapPluginInfo) -endif() - -# not in the same if as the above will be removed shortly. -if(NOT APPLE) - # Disable ORD violation caused by double definition inside a stub file libinknet_stub.cc - # see remap_test_dlopen_leak_suppression.txt for more info. - set_tests_properties( - test_RemapPluginInfo test_PluginDso test_PluginFactory + add_catch2_test( + NAME + test_RemapPluginInfo PROPERTIES - ENVIRONMENT - "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" + ENVIRONMENT + "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" ) endif() + ### test_NextHopStrategyFactory ######################################################################## add_executable( From 2ee45c9685728c0ab8faf62be0100ca75acb0b92 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 5 Jan 2026 13:34:57 -0600 Subject: [PATCH 06/12] try passing properties by name --- lib/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2bea3e65c14..71ac3532a82 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -51,8 +51,8 @@ if(BUILD_TESTING) # macro allows us to add common command line arguments to all tests. For now, # we ensure declaration order execution via --order decl. macro(add_catch2_test) - cmake_parse_arguments(CATCH2_TEST "" "NAME" "" ${ARGN}) - catch_discover_tests(${CATCH2_TEST_NAME} ${ARGN}) + cmake_parse_arguments(CATCH2_TEST "" "NAME" "PROPERTIES" ${ARGN}) + catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ${CATCH2_TEST_PROPERTIES}) endmacro() endif() From b8d3b7a90d948ed134348d4560918976bd229848 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 5 Jan 2026 14:10:27 -0600 Subject: [PATCH 07/12] specify environment --- lib/CMakeLists.txt | 4 ++-- src/iocore/net/CMakeLists.txt | 2 +- src/proxy/http/remap/unit-tests/CMakeLists.txt | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 71ac3532a82..2df9bf125ca 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -51,8 +51,8 @@ if(BUILD_TESTING) # macro allows us to add common command line arguments to all tests. For now, # we ensure declaration order execution via --order decl. macro(add_catch2_test) - cmake_parse_arguments(CATCH2_TEST "" "NAME" "PROPERTIES" ${ARGN}) - catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ${CATCH2_TEST_PROPERTIES}) + cmake_parse_arguments(CATCH2_TEST "" "NAME" "ENVIRONMENT" ${ARGN}) + catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ENVIRONMENT ${CATCH2_TEST_ENVIRONMENT}) endmacro() endif() diff --git a/src/iocore/net/CMakeLists.txt b/src/iocore/net/CMakeLists.txt index d296e8168c1..e3ee26561ed 100644 --- a/src/iocore/net/CMakeLists.txt +++ b/src/iocore/net/CMakeLists.txt @@ -176,7 +176,7 @@ if(BUILD_TESTING) if(APPLE) # Disable ORD violation caused by double definition inside a stub file libinknet_stub.cc # see remap_test_dlopen_leak_suppression.txt for more info. - add_catch2_test(NAME test_net PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_odr_violation=0") + add_catch2_test(NAME test_net ENVIRONMENT "ASAN_OPTIONS=detect_odr_violation=0") else() add_catch2_test(NAME test_net) endif() diff --git a/src/proxy/http/remap/unit-tests/CMakeLists.txt b/src/proxy/http/remap/unit-tests/CMakeLists.txt index b850fab185b..7de7eb9447a 100644 --- a/src/proxy/http/remap/unit-tests/CMakeLists.txt +++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt @@ -97,7 +97,6 @@ if(NOT APPLE) add_catch2_test( NAME test_PluginDso - PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" ) @@ -142,7 +141,6 @@ if(NOT APPLE) add_catch2_test( NAME test_PluginFactory - PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" ) @@ -181,7 +179,6 @@ if(NOT APPLE) add_catch2_test( NAME test_RemapPluginInfo - PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" ) From 2077073242f7904bf71e7b6d745210f0c5ecfbbe Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 5 Jan 2026 14:32:31 -0600 Subject: [PATCH 08/12] try again --- lib/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2df9bf125ca..6804c3837d4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -51,7 +51,8 @@ if(BUILD_TESTING) # macro allows us to add common command line arguments to all tests. For now, # we ensure declaration order execution via --order decl. macro(add_catch2_test) - cmake_parse_arguments(CATCH2_TEST "" "NAME" "ENVIRONMENT" ${ARGN}) + set(oneValueArgs NAME ENVIRONMENT) + cmake_parse_arguments(CATCH2_TEST "" ${oneValueArgs} "" ${ARGN}) catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ENVIRONMENT ${CATCH2_TEST_ENVIRONMENT}) endmacro() endif() From ffbf4c4b9e21e611b48ed5e933b59a33d52fe8fa Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 5 Jan 2026 15:47:17 -0600 Subject: [PATCH 09/12] avoid odr maybe --- src/proxy/http/remap/unit-tests/CMakeLists.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/proxy/http/remap/unit-tests/CMakeLists.txt b/src/proxy/http/remap/unit-tests/CMakeLists.txt index 7de7eb9447a..17f83632c6f 100644 --- a/src/proxy/http/remap/unit-tests/CMakeLists.txt +++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt @@ -104,14 +104,8 @@ endif() ### test_PluginFactory ######################################################################## add_executable( - test_PluginFactory - test_PluginFactory.cc - plugin_testing_common.cc - ../PluginFactory.cc - ../PluginDso.cc - ../RemapPluginInfo.cc - ${PROJECT_SOURCE_DIR}/src/iocore/net/libinknet_stub.cc - ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc + test_PluginFactory test_PluginFactory.cc plugin_testing_common.cc ../PluginFactory.cc ../PluginDso.cc + ../RemapPluginInfo.cc ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc ) target_compile_definitions(test_PluginFactory PRIVATE PLUGIN_DSO_TESTS) From d84620009230e28d183ad779401513eeb97b68d2 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 5 Jan 2026 16:03:44 -0600 Subject: [PATCH 10/12] avoid odr maybe --- src/proxy/http/remap/unit-tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proxy/http/remap/unit-tests/CMakeLists.txt b/src/proxy/http/remap/unit-tests/CMakeLists.txt index 17f83632c6f..1f54934e2a2 100644 --- a/src/proxy/http/remap/unit-tests/CMakeLists.txt +++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt @@ -143,7 +143,7 @@ endif() add_executable( test_RemapPluginInfo test_RemapPlugin.cc plugin_testing_common.cc ../PluginDso.cc ../RemapPluginInfo.cc - ${PROJECT_SOURCE_DIR}/src/iocore/net/libinknet_stub.cc ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc + ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc ) target_compile_definitions(test_RemapPluginInfo PRIVATE PLUGIN_DSO_TESTS) From 6060dc3e75ca82659e3ad9cb6af9f47ba4bf1152 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 9 Jan 2026 13:12:12 -0600 Subject: [PATCH 11/12] update catch2 macro, fix conflicts --- lib/CMakeLists.txt | 17 ++++++++++++++--- plugins/esi/test/CMakeLists.txt | 7 ++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 6804c3837d4..504212ae2cd 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -50,11 +50,22 @@ if(BUILD_TESTING) # done in one TEST_CASE expected to carry over into the next TEST_CASE. This # macro allows us to add common command line arguments to all tests. For now, # we ensure declaration order execution via --order decl. + # macro(add_catch2_test) + # set(oneValueArgs NAME ENVIRONMENT) + # cmake_parse_arguments(CATCH2_TEST "" ${oneValueArgs} "" ${ARGN}) + # catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ENVIRONMENT ${CATCH2_TEST_ENVIRONMENT}) + # endmacro() macro(add_catch2_test) - set(oneValueArgs NAME ENVIRONMENT) - cmake_parse_arguments(CATCH2_TEST "" ${oneValueArgs} "" ${ARGN}) - catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ENVIRONMENT ${CATCH2_TEST_ENVIRONMENT}) + cmake_parse_arguments(CATCH2_TEST "" "NAME" "ENVIRONMENT" ${ARGN}) + + set(_catch_properties) + if(CATCH2_TEST_ENVIRONMENT) + list(APPEND _catch_properties ENVIRONMENT "${CATCH2_TEST_ENVIRONMENT}") + endif() + + catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ${_catch_properties}) endmacro() + endif() if(NOT TARGET yaml-cpp::yaml-cpp) diff --git a/plugins/esi/test/CMakeLists.txt b/plugins/esi/test/CMakeLists.txt index e6e78e4299d..f2332270e83 100644 --- a/plugins/esi/test/CMakeLists.txt +++ b/plugins/esi/test/CMakeLists.txt @@ -21,11 +21,8 @@ target_link_libraries(esitest PUBLIC esi-common esicore) macro(ADD_ESI_TEST NAME) add_executable(${NAME} print_funcs.cc ${ARGN}) target_link_libraries(${NAME} PRIVATE esitest) - add_catch2_test(NAME ${NAME} COMMAND $) - # Use ASan leak suppression for intentional DbgCtl leaks (issue #12776) - set_tests_properties( - ${NAME} PROPERTIES ENVIRONMENT - "LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/esi_test_leak_suppression.txt" + add_catch2_test( + NAME ${NAME} ENVIRONMENT "LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/esi_test_leak_suppression.txt" ) endmacro() From 60dcb5ee8ac703e320106b5bb455a955a7b0d07a Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 9 Jan 2026 14:08:22 -0600 Subject: [PATCH 12/12] Try pre_test discovery mode --- lib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 504212ae2cd..2738fa917e7 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -63,7 +63,7 @@ if(BUILD_TESTING) list(APPEND _catch_properties ENVIRONMENT "${CATCH2_TEST_ENVIRONMENT}") endif() - catch_discover_tests(${CATCH2_TEST_NAME} PROPERTIES ${_catch_properties}) + catch_discover_tests(${CATCH2_TEST_NAME} DISCOVERY_MODE PRE_TEST PROPERTIES ${_catch_properties}) endmacro() endif()