From 534d841773ee5947baeeacf0da63262a3ac76936 Mon Sep 17 00:00:00 2001 From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de> Date: Sat, 28 Oct 2023 15:29:51 +0000 Subject: [PATCH] algo: Refactor test cmake. --- algo/CMakeLists.txt | 7 +++- algo/test/CMakeLists.txt | 81 ++++++++++------------------------------ 2 files changed, 25 insertions(+), 63 deletions(-) diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt index fe4e905d41..01de74a9e6 100644 --- a/algo/CMakeLists.txt +++ b/algo/CMakeLists.txt @@ -51,12 +51,15 @@ if (CBM_ONLINE_STANDALONE) add_subdirectory(../external external) endif() - add_subdirectory(log) add_subdirectory(data) -add_subdirectory(test) add_subdirectory(ca) +# exclude unittests from being build inside the container +if (NOT CBM_ONLINE_STANDALONE) + add_subdirectory(test) +endif() + set(DEVICE_SRCS base/gpu/DeviceImage.cxx base/gpu/Params.cxx diff --git a/algo/test/CMakeLists.txt b/algo/test/CMakeLists.txt index dcd036d4c9..298c38feaf 100644 --- a/algo/test/CMakeLists.txt +++ b/algo/test/CMakeLists.txt @@ -1,63 +1,22 @@ -Macro(CreateGTestExeAndAddTest _testname _includeDirs _linkDirs _sources _pub_dep _pvt_dep _int_dep _testdepend) - - add_executable(${_testname} ${_sources}) - target_link_libraries(${_testname} PUBLIC ${_pub_dep} PRIVATE ${_pvt_dep} INTERFACE ${_int_dep} ) - target_include_directories(${_testname} PUBLIC ${_includeDirs}) - Gen_Exe_Script(${_testname}) - string(REPLACE ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} new_path ${CMAKE_CURRENT_SOURCE_DIR} - ) - Add_Test(${_testname} ${new_path}/${_testname}.sh) - If(NOT ${_testdepend} STREQUAL "") - Set_Tests_Properties(${_testname} PROPERTIES DEPENDS ${_testdepend}) - EndIf() -EndMacro(CreateGTestExeAndAddTest) - - -# get_target_property(_inDir Gtest INTERFACE_INCLUDE_DIRECTORIES) -# set_property(TARGET Gtest APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_inDir}/..") - -set(PVT_DEPS - Algo - Gtest - GtestMain +Function(AddBasicTest name) + set(PVT_DEPS + Algo + Gtest + GtestMain ) - - -Set(TimeClusterTriggerSources - _GTestTimeClusterTrigger.cxx -) - -CreateGTestExeAndAddTest(_GTestTimeClusterTrigger "${INCLUDE_DIRECTORIES}" "${LINK_DIRECTORIES}" - "${TimeClusterTriggerSources}" "${PUB_DEPS}" "${PVT_DEPS}" "${INT_DEPS}" "") - -Set(EventBuilderSources - _GTestEventBuilder.cxx -) - -CreateGTestExeAndAddTest(_GTestEventBuilder "${INCLUDE_DIRECTORIES}" "${LINK_DIRECTORIES}" - "${EventBuilderSources}" "${PUB_DEPS}" "${PVT_DEPS}" "${INT_DEPS}" "") - -Set(DigiEventSelectorSources - _GTestDigiEventSelector.cxx -) - -CreateGTestExeAndAddTest(_GTestDigiEventSelector "${INCLUDE_DIRECTORIES}" "${LINK_DIRECTORIES}" - "${DigiEventSelectorSources}" "${PUB_DEPS}" "${PVT_DEPS}" "${INT_DEPS}" "") - -Set(YamlConfigSources - _GTestYamlConfig.cxx -) -CreateGTestExeAndAddTest(_GTestYamlConfig "${INCLUDE_DIRECTORIES}" "${LINK_DIRECTORIES}" - "${YamlConfigSources}" "${PUB_DEPS}" "${PVT_DEPS}" "${INT_DEPS}" "") - -Set(PartitionedVectorSources - _GTestPartitionedVector.cxx -) -CreateGTestExeAndAddTest(_GTestPartitionedVector "${INCLUDE_DIRECTORIES}" "${LINK_DIRECTORIES}" - "${PartitionedVectorSources}" "${PUB_DEPS}" "${PVT_DEPS}" "${INT_DEPS}" "") - -Set(PartitionedSpanSources _GTestPartitionedSpan.cxx) -CreateGTestExeAndAddTest(_GTestPartitionedSpan "${INCLUDE_DIRECTORIES}" "${LINK_DIRECTORIES}" - "${PartitionedSpanSources}" "${PUB_DEPS}" "${PVT_DEPS}" "${INT_DEPS}" "") + add_executable(${name} ${name}.cxx) + target_link_libraries(${name} PRIVATE ${PVT_DEPS}) + Add_Test( + NAME ${name} + COMMAND ${name} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + ) +EndFunction() + +AddBasicTest(_GTestTimeClusterTrigger) +AddBasicTest(_GTestEventBuilder) +AddBasicTest(_GTestDigiEventSelector) +AddBasicTest(_GTestYamlConfig) +AddBasicTest(_GTestPartitionedVector) +AddBasicTest(_GTestPartitionedSpan) -- GitLab