diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 6e28a50eb15..2738fa917e7 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: @@ -48,10 +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) - cmake_parse_arguments(CATCH2_TEST "" "NAME" "COMMAND" ${ARGN}) - add_test(NAME ${CATCH2_TEST_NAME} COMMAND ${CATCH2_TEST_COMMAND} --order decl) + 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} DISCOVERY_MODE PRE_TEST PROPERTIES ${_catch_properties}) endmacro() + endif() if(NOT TARGET yaml-cpp::yaml-cpp) 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/esi/test/CMakeLists.txt b/plugins/esi/test/CMakeLists.txt index c9bc8c2d5f7..f2332270e83 100644 --- a/plugins/esi/test/CMakeLists.txt +++ b/plugins/esi/test/CMakeLists.txt @@ -21,23 +21,20 @@ 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 $) - # Use ASan leak suppression for intentional DbgCtl leaks (issue #12776) - set_tests_properties( - ${NAME}_esi 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() -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/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 2775cef4e35..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 test_cache_${name} COMMAND $) + add_catch2_test(NAME ${name}) 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/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 7cc9ada3248..d1c6ed6fc73 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) - 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 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..e3ee26561ed 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 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/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}; 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..1f54934e2a2 100644 --- a/src/proxy/http/remap/unit-tests/CMakeLists.txt +++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt @@ -94,19 +94,18 @@ if(NOT APPLE) endif() if(NOT APPLE) - add_catch2_test(NAME test_PluginDso COMMAND $) + add_catch2_test( + NAME + test_PluginDso + ENVIRONMENT + "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" + ) 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) @@ -133,13 +132,18 @@ target_link_libraries( ) if(NOT APPLE) - add_catch2_test(NAME test_PluginFactory COMMAND $) + add_catch2_test( + NAME + test_PluginFactory + ENVIRONMENT + "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" + ) endif() ### test_RemapPluginInfo ######################################################################## 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) @@ -166,20 +170,14 @@ target_link_libraries( ) if(NOT APPLE) - add_catch2_test(NAME test_RemapPluginInfo COMMAND $) -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 - PROPERTIES - ENVIRONMENT - "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt" + add_catch2_test( + NAME + test_RemapPluginInfo + 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( @@ -205,7 +203,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 +234,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 +267,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 +285,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)