adds TSAN/ASAN buid settings

This commit is contained in:
2025-11-09 20:19:54 +01:00
parent 687c544ccb
commit bd032c08ce
14 changed files with 48 additions and 22 deletions

1
.gitignore vendored
View File

@@ -50,3 +50,4 @@
/CMakeUserPresets.json
/*.scview
/*.log
/config

View File

@@ -7,6 +7,9 @@ project(SCC_Test)
option(FULL_TEST_SUITE "enable also long-running tests" OFF)
option(ENABLE_SCV "Enable use of SCV" OFF)
option(ENABLE_CLANG_TIDY "Enable clang-tidy checks" OFF)
option(ENABLE_CLANG_FORMAT "Enable clang-format targets" OFF)
option(THREAD_SANITIZER "Enable thread sanitizer TSan" OFF)
option(ADDR_SANITIZER "Enable address sanitizer ASan" OFF)
include(GNUInstallDirs)
include(BuildType)
@@ -30,7 +33,15 @@ if(ENABLE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
endif()
if (THREAD_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -O0 -g")
elseif(ADDR_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O0 -g")
else()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
endif()
if(ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
@@ -44,7 +55,9 @@ if(ENABLE_CLANG_TIDY)
endif()
set(CLANG_FORMAT_EXCLUDE_PATTERNS "/third_party/" "/build/")
find_package(ClangFormat)
if(ENABLE_CLANG_FORMAT)
find_package(ClangFormat)
endif()
find_package(ZLIB)
find_package(lz4)
# This line finds the boost lib and headers.
@@ -57,7 +70,6 @@ find_package(Catch2)
include(SystemCPackage)
include(CTest)
include(Catch)
enable_testing()
set(WITH_SCP4SCC ON)
add_subdirectory(scc)

2
scc

Submodule scc updated: 0a3b2697a5...cc35ebf490

View File

@@ -5,5 +5,6 @@ add_executable(${PROJECT_NAME}
${test_util_SOURCE_DIR}/sc_main.cpp
)
target_link_libraries (${PROJECT_NAME} PUBLIC test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -6,4 +6,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries (${PROJECT_NAME} PUBLIC test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -6,4 +6,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries (${PROJECT_NAME} PUBLIC test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -5,5 +5,6 @@ add_executable(${PROJECT_NAME}
${test_util_SOURCE_DIR}/sc_main.cpp
)
target_link_libraries (${PROJECT_NAME} PUBLIC test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -6,4 +6,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries (${PROJECT_NAME} PUBLIC test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -5,4 +5,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries (${PROJECT_NAME} PUBLIC scc::busses test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -5,4 +5,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries (${PROJECT_NAME} PUBLIC scc::components test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -6,4 +6,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries (${PROJECT_NAME} PUBLIC test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()

View File

@@ -1,8 +1,5 @@
message(STATUS "SC_VERSION is ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH}")
if(SC_VERSION_MAJOR GREATER 2)
add_executable (quantum_keeper_mt
sc_main.cpp
)
add_executable (quantum_keeper_mt sc_main.cpp)
target_link_libraries (quantum_keeper_mt LINK_PUBLIC scc-sysc)
add_test(NAME quantum_keeper_mt COMMAND quantum_keeper_mt)
endif()

View File

@@ -27,7 +27,7 @@ struct initiator : ::sc_core ::sc_module {
SC_THREAD(run);
}
~initiator() {}
~initiator() = default;
private:
void run() {
@@ -79,7 +79,7 @@ struct top_module : ::sc_core ::sc_module {
SC_THREAD(run);
}
~top_module() {}
~top_module() = default;
void b_transport(tlm::tlm_generic_payload& gp, sc_core::sc_time& t) {
SCCDEBUG(SCMOD) << "Received b_transport call at local time " << t;

View File

@@ -5,4 +5,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries (${PROJECT_NAME} PUBLIC scc::components test_util)
catch_discover_tests(${PROJECT_NAME})
if(NOT THREAD_SANITIZER)
catch_discover_tests(${PROJECT_NAME})
endif()