From 4b60a3ef38d0fb7d9d69d95daa24eafee4d347bc Mon Sep 17 00:00:00 2001 From: Niklas Uhl Date: Thu, 13 Jun 2024 08:21:21 +0200 Subject: [PATCH] Do no use sanitizers in tests by default (#735) * Run gtest_test_discovery pre test instead of post build The current behavior does not work well with parallel builds using `make`. * Disable sanitizers for testing by default. They lead to segfaults and issues with dynamic loading sometimes ... --- tests/CMakeLists.txt | 2 +- tests/cmake/KampingTestHelper.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 29bda50c0..9281d1811 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,7 +17,7 @@ if (NOT N EQUAL 0) ) endif () -option(KAMPING_TEST_ENABLE_SANITIZERS "Enable undefined behavior sanitizer and address sanitizer." ON) +option(KAMPING_TEST_ENABLE_SANITIZERS "Enable undefined behavior sanitizer and address sanitizer." OFF) # Registering tests without MPI: kamping_register_test(test_checking_casts FILES checking_casts_test.cpp) diff --git a/tests/cmake/KampingTestHelper.cmake b/tests/cmake/KampingTestHelper.cmake index ca8d41434..ab399a860 100644 --- a/tests/cmake/KampingTestHelper.cmake +++ b/tests/cmake/KampingTestHelper.cmake @@ -24,7 +24,7 @@ function (kamping_register_test KAMPING_TARGET_NAME) add_executable(${KAMPING_TARGET_NAME} ${KAMPING_FILES}) target_link_libraries(${KAMPING_TARGET_NAME} PRIVATE gtest gtest_main gmock kamping_base) target_compile_options(${KAMPING_TARGET_NAME} PRIVATE ${KAMPING_WARNING_FLAGS}) - gtest_discover_tests(${KAMPING_TARGET_NAME} WORKING_DIRECTORY ${PROJECT_DIR}) + gtest_discover_tests(${KAMPING_TARGET_NAME} WORKING_DIRECTORY ${PROJECT_DIR} DISCOVERY_MODE PRE_TEST) kamping_set_kassert_flags(${KAMPING_TARGET_NAME} ${ARGN}) if (NOT ${KAMPING_NO_GLIBCXX_DEBUG_CONTAINERS}) target_compile_definitions(${KAMPING_TARGET_NAME} PRIVATE -D_GLIBCXX_DEBUG)