From 75fc32db6c5f46dec20db6be865ecfa8d1b18758 Mon Sep 17 00:00:00 2001 From: Jan Stephan Date: Tue, 5 Sep 2023 20:54:19 +0200 Subject: [PATCH] Let CMake print TSan warning --- test/unit/core/CMakeLists.txt | 9 +++++++-- test/unit/core/src/ThreadPool.cpp | 11 +---------- test/unit/mem/fence/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/test/unit/core/CMakeLists.txt b/test/unit/core/CMakeLists.txt index f63bb2dc2a60..756905db7f3d 100644 --- a/test/unit/core/CMakeLists.txt +++ b/test/unit/core/CMakeLists.txt @@ -1,5 +1,4 @@ -# -# Copyright 2018-2020 Benjamin Worpitz, Axel Huebl, Jan Stephan +# Copyright 2023 Benjamin Worpitz, Jan Stephan, Antonio Di Pilato # SPDX-License-Identifier: MPL-2.0 # @@ -7,6 +6,12 @@ set(_TARGET_NAME "coreTest") append_recursive_files_add_to_src_group("src/" "src/" "cpp" _FILES_SOURCE) +# TODO(bgruber): Revisit this in the future on a new CI image. This problem does not happen locally. +if(CMAKE_CXX_FLAGS MATCHES ".*-fsanitize=thread.*") + message(WARNING "Part of the threadpool test fails the TSan CI and is therefore disabled. See also: https://github.com/alpaka-group/alpaka/issues/2101") + set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/src/ThreadPool.cpp" PROPERTIES COMPILE_DEFINITIONS "ALPAKA_USES_TSAN") +endif() + alpaka_add_executable( ${_TARGET_NAME} ${_FILES_SOURCE}) diff --git a/test/unit/core/src/ThreadPool.cpp b/test/unit/core/src/ThreadPool.cpp index 5819f281db5f..730f5c4c132d 100644 --- a/test/unit/core/src/ThreadPool.cpp +++ b/test/unit/core/src/ThreadPool.cpp @@ -6,12 +6,6 @@ #include -#if defined(__has_feature) -# if __has_feature(thread_sanitizer) -# define TSAN -# endif -#endif - TEST_CASE("threadpool", "[core]") { alpaka::core::detail::ThreadPool tp{2}; @@ -22,10 +16,7 @@ TEST_CASE("threadpool", "[core]") CHECK_THROWS_AS(f1.get(), std::runtime_error); -#ifdef TSAN -# warning "Part of the threadpool test fails the TSAN CI and is therefore disabled." - // TODO(bgruber): Revisit this in the future on a new CI image. This problem does not happen locally. -#else +#ifndef ALPAKA_USES_TSAN try { f2.get(); diff --git a/test/unit/mem/fence/CMakeLists.txt b/test/unit/mem/fence/CMakeLists.txt index 09f9dd0d572b..132462d67289 100644 --- a/test/unit/mem/fence/CMakeLists.txt +++ b/test/unit/mem/fence/CMakeLists.txt @@ -4,7 +4,7 @@ # if (CMAKE_CXX_FLAGS MATCHES ".*-fsanitize=thread.*") - message(WARNING "TSAN does not support memory fences yet. The fenceTest has been disabled. See also: https://github.com/google/sanitizers/issues/1352") + message(WARNING "TSan does not support memory fences yet. The fenceTest has been disabled. See also: https://github.com/google/sanitizers/issues/1352") return() endif()