diff --git a/CMakeModules/CorsikaUtilities.cmake b/CMakeModules/CorsikaUtilities.cmake index abd7bfcde005a3354a20f59c551198e12ecbd154..ece233ed9fa4cb3fd8c6953de4ab94ba19385614 100644 --- a/CMakeModules/CorsikaUtilities.cmake +++ b/CMakeModules/CorsikaUtilities.cmake @@ -98,15 +98,28 @@ endmacro(CORSIKA_ADD_FILES_ABSOLUTE) # central macro to activate unit tests in cmake # -function (CORSIKA_ADD_TEST name) +function (CORSIKA_ADD_TEST) + cmake_parse_arguments(PARSE_ARGV 1 _ "" "SANITIZE" "SOURCES") + + set(name ${ARGV0}) + + if (NOT __SOURCES) + set(sources ${name}.cc) + else() + set(sources ${__SOURCES}) + endif() + + if (NOT __SANITIZE) + set(sanitize "address,undefined") + else() + set(sanitize ${__SANITIZE}) + endif() + + add_executable(${name} ${sources}) + target_compile_options(${name} PRIVATE -g) # do not skip asserts target_include_directories (${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/test_outputs/) - add_test (NAME ${name} COMMAND ${name} -o ${PROJECT_BINARY_DIR}/test_outputs/junit-${name}.xml -r junit) - # set(sanitize "address,implicit-integer-truncation,implicit-conversion,integer,alignment,bool,builtin,bounds,enum,float-cast-overflow,function,pointer-overflow,return,shift,shift-base,shift-exponent,unreachable,vla-bound,vptr") - # standard options not ideal, because we want to allow divide-by-zero for floats, - # but gcc-7 doesn't support all the detailed flags - set(sanitize "address,undefined") target_compile_options(${name} PRIVATE -fno-omit-frame-pointer -fsanitize=${sanitize} -fno-sanitize-recover=all) set_target_properties(${name} PROPERTIES LINK_FLAGS "-fsanitize=${sanitize}") - + add_test (NAME ${name} COMMAND ${name} -o ${PROJECT_BINARY_DIR}/test_outputs/junit-${name}.xml -r junit) endfunction (CORSIKA_ADD_TEST) diff --git a/Documentation/Examples/CMakeLists.txt b/Documentation/Examples/CMakeLists.txt index c677f3ab9a3dccd82235fee8d4690be4de697d17..80855d599e6f7ca6942ad1b7a04cf21d0218fe50 100644 --- a/Documentation/Examples/CMakeLists.txt +++ b/Documentation/Examples/CMakeLists.txt @@ -1,29 +1,20 @@ -add_executable (helix_example helix_example.cc) -target_compile_options(helix_example PRIVATE -g) # do not skip asserts -target_link_libraries(helix_example CORSIKAgeometry CORSIKAunits) -install (TARGETS helix_example DESTINATION share/examples) CORSIKA_ADD_TEST (helix_example) +target_link_libraries (helix_example CORSIKAgeometry CORSIKAunits) +install (TARGETS helix_example DESTINATION share/examples) -add_executable (geometry_example geometry_example.cc) -target_compile_options(geometry_example PRIVATE -g) # do not skip asserts +CORSIKA_ADD_TEST (geometry_example) target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits) install (TARGETS geometry_example DESTINATION share/examples) -CORSIKA_ADD_TEST (geometry_example) -add_executable (logger_example logger_example.cc) -target_compile_options(logger_example PRIVATE -g) # do not skip asserts +CORSIKA_ADD_TEST (logger_example) target_link_libraries (logger_example CORSIKAunits CORSIKAlogging) install (TARGETS logger_example DESTINATION share/examples) -CORSIKA_ADD_TEST (logger_example) -add_executable (stack_example stack_example.cc) -target_compile_options(stack_example PRIVATE -g) # do not skip asserts +CORSIKA_ADD_TEST (stack_example) target_link_libraries (stack_example SuperStupidStack CORSIKAunits CORSIKAlogging) -CORSIKA_ADD_TEST (stack_example) -add_executable (cascade_example cascade_example.cc) -target_compile_options(cascade_example PRIVATE -g) # do not skip asserts +CORSIKA_ADD_TEST (cascade_example) target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogging CORSIKArandom @@ -42,10 +33,30 @@ target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAprocesssequence ) install (TARGETS cascade_example DESTINATION share/examples) -CORSIKA_ADD_TEST (cascade_example) -add_executable (boundary_example boundary_example.cc) -target_compile_options(boundary_example PRIVATE -g) # do not skip asserts +if (Pythia8_FOUND) + # address sanitizer is making this example too slow, so we only do "undefined" + CORSIKA_ADD_TEST (cascade_example SANITIZE "undefined") + target_link_libraries (cascade_example SuperStupidStack CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + CORSIKAcascade + ProcessEnergyLoss + ProcessStackInspector + ProcessTrackWriter + ProcessTrackingLine + CORSIKAprocesses + CORSIKAcascade + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) + install (TARGETS cascade_example DESTINATION share/examples) +endif() + +CORSIKA_ADD_TEST (boundary_example) target_link_libraries (boundary_example SuperStupidStack CORSIKAunits CORSIKAlogging CORSIKArandom ProcessSibyll @@ -60,11 +71,9 @@ target_link_libraries (boundary_example SuperStupidStack CORSIKAunits CORSIKAlog CORSIKAprocesssequence ) install (TARGETS boundary_example DESTINATION share/examples) -CORSIKA_ADD_TEST (boundary_example) if (Pythia8_FOUND) - add_executable (cascade_proton_example cascade_proton_example.cc) - target_compile_options(cascade_proton_example PRIVATE -g) # do not skip asserts + CORSIKA_ADD_TEST (cascade_proton_example) target_link_libraries (cascade_proton_example SuperStupidStack CORSIKAunits CORSIKAlogging CORSIKArandom @@ -84,40 +93,36 @@ if (Pythia8_FOUND) CORSIKAenvironment CORSIKAprocesssequence ) - install (TARGETS cascade_proton_example DESTINATION share/examples) - CORSIKA_ADD_TEST (cascade_proton_example) endif() -add_executable (vertical_EAS vertical_EAS.cc) -target_compile_options(vertical_EAS PRIVATE -g) # do not skip asserts -target_link_libraries (vertical_EAS SuperStupidStack CORSIKAunits - CORSIKAlogging - CORSIKArandom - ProcessSibyll - CORSIKAcascade - ProcessEnergyLoss - ProcessTrackWriter - ProcessTrackingLine - ProcessHadronicElasticModel - ProcessParticleCut - ProcessStackInspector - CORSIKAprocesses - CORSIKAcascade - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - CORSIKAprocesssequence - ) -install (TARGETS vertical_EAS DESTINATION share/examples) -# CORSIKA_ADD_TEST (vertical_EAS) not yet... +if (Pythia8_FOUND) + # CORSIKA_ADD_TEST (vertical_EAS) not yet... + CORSIKA_ADD_TEST(vertical_EAS) + target_link_libraries (vertical_EAS SuperStupidStack CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + CORSIKAcascade + ProcessEnergyLoss + ProcessTrackWriter + ProcessTrackingLine + ProcessHadronicElasticModel + ProcessStackInspector + CORSIKAprocesses + CORSIKAcascade + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) + install (TARGETS vertical_EAS DESTINATION share/examples) +endif() -add_executable (staticsequence_example staticsequence_example.cc) -target_compile_options(staticsequence_example PRIVATE -g) # do not skip asserts +CORSIKA_ADD_TEST (staticsequence_example) target_link_libraries (staticsequence_example CORSIKAprocesssequence CORSIKAunits CORSIKAgeometry CORSIKAlogging) install (TARGETS staticsequence_example DESTINATION share/examples) -CORSIKA_ADD_TEST (staticsequence_example) diff --git a/Environment/CMakeLists.txt b/Environment/CMakeLists.txt index 13fd4f1e736d70a00b8380fdb6de6d906349b4a5..f32254e6ff526c4c992af99568e306f4d1e377f1 100644 --- a/Environment/CMakeLists.txt +++ b/Environment/CMakeLists.txt @@ -49,12 +49,10 @@ install ( # -------------------- # code unit testing -add_executable (testEnvironment testEnvironment.cc) - +CORSIKA_ADD_TEST(testEnvironment) target_link_libraries ( testEnvironment CORSIKAsetup CORSIKAenvironment CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testGeometry) diff --git a/Framework/Cascade/CMakeLists.txt b/Framework/Cascade/CMakeLists.txt index cce178637582bb48a8b17d1017bc489802c192aa..e4890d87a6df375206cc2ebfad42b5abc42f4721 100644 --- a/Framework/Cascade/CMakeLists.txt +++ b/Framework/Cascade/CMakeLists.txt @@ -32,11 +32,7 @@ install ( # ---------------- # code unit testing -add_executable ( - testCascade - testCascade.cc - ) - +CORSIKA_ADD_TEST(testCascade) target_link_libraries ( testCascade # CORSIKAutls @@ -55,4 +51,3 @@ target_link_libraries ( CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testCascade) diff --git a/Framework/Geometry/CMakeLists.txt b/Framework/Geometry/CMakeLists.txt index 510d8e3922f2c7c9a1bbd0578bea34f74641e500..6cda1a6fff3b6cfd069ec521f92dc7e2f77f66cc 100644 --- a/Framework/Geometry/CMakeLists.txt +++ b/Framework/Geometry/CMakeLists.txt @@ -67,20 +67,18 @@ install ( # -------------------- # code unit testing -add_executable (testGeometry testGeometry.cc) +CORSIKA_ADD_TEST(testGeometry) target_link_libraries ( testGeometry CORSIKAgeometry CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testGeometry) -add_executable (testFourVector testFourVector.cc) +CORSIKA_ADD_TEST(testFourVector) target_link_libraries ( testFourVector CORSIKAgeometry CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testFourVector) diff --git a/Framework/Logging/CMakeLists.txt b/Framework/Logging/CMakeLists.txt index 056aaad3549077dcf063243536c6d17b97a1e4a6..0926ad6576a74bb2585daba367461613e42f07c6 100644 --- a/Framework/Logging/CMakeLists.txt +++ b/Framework/Logging/CMakeLists.txt @@ -38,15 +38,11 @@ install ( # ---------------- # code unit testing -add_executable ( - testLogging - testLogging.cc - ) +CORSIKA_ADD_TEST (testLogging) target_link_libraries ( testLogging CORSIKAlogging CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST (testLogging) diff --git a/Framework/Particles/CMakeLists.txt b/Framework/Particles/CMakeLists.txt index cde894b095905f226a8e3a781bcc9f3b0daeb896..48f1b76926ec72eb0b83ed18bde939142c1b3365 100644 --- a/Framework/Particles/CMakeLists.txt +++ b/Framework/Particles/CMakeLists.txt @@ -82,16 +82,14 @@ install ( # -------------------- # code unit testing -add_executable ( - testParticles - testParticles.cc - ${PROJECT_BINARY_DIR}/Framework/Particles/GeneratedParticleProperties.inc - ) - +CORSIKA_ADD_TEST(testParticles + SOURCES + testParticles.cc + ${PROJECT_BINARY_DIR}/Framework/Particles/GeneratedParticleProperties.inc +) target_link_libraries ( testParticles CORSIKAparticles CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testParticles) diff --git a/Framework/ProcessSequence/CMakeLists.txt b/Framework/ProcessSequence/CMakeLists.txt index 33aad8236f6b2943d083fd95addcea1698700d43..c1a4c77830c559edd56dd0d7307eca12daa96ab8 100644 --- a/Framework/ProcessSequence/CMakeLists.txt +++ b/Framework/ProcessSequence/CMakeLists.txt @@ -45,11 +45,7 @@ target_link_libraries ( #-- -- -- -- -- -- -- -- #code unit testing -add_executable ( - testProcessSequence - testProcessSequence.cc - ) - +CORSIKA_ADD_TEST(testProcessSequence) target_link_libraries ( testProcessSequence CORSIKAsetup @@ -57,4 +53,3 @@ target_link_libraries ( CORSIKAprocesssequence CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testProcessSequence) diff --git a/Framework/Random/CMakeLists.txt b/Framework/Random/CMakeLists.txt index bbbe8d32d484373f6ed62495893508c5996dd59f..b553d8c44e01cdc678a27d311d96645744a374dc 100644 --- a/Framework/Random/CMakeLists.txt +++ b/Framework/Random/CMakeLists.txt @@ -46,11 +46,9 @@ install ( # -------------------- # code unit testing -add_executable (testRandom testRandom.cc) - +CORSIKA_ADD_TEST(testRandom) target_link_libraries ( testRandom CORSIKArandom CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testRandom) diff --git a/Framework/StackInterface/CMakeLists.txt b/Framework/StackInterface/CMakeLists.txt index fa0edbef35fe95ba01cd10381247380423d28a67..91b09a2ee22af91c289c4ae977d61e7738462872 100644 --- a/Framework/StackInterface/CMakeLists.txt +++ b/Framework/StackInterface/CMakeLists.txt @@ -34,14 +34,11 @@ install ( ) #code testing -add_executable (testStackInterface testStackInterface.cc) -target_link_libraries (testStackInterface CORSIKAstackinterface CORSIKAthirdparty) # for catch2 CORSIKA_ADD_TEST(testStackInterface) +target_link_libraries (testStackInterface CORSIKAstackinterface CORSIKAthirdparty) # for catch2 -add_executable (testSecondaryView testSecondaryView.cc) -target_link_libraries (testSecondaryView CORSIKAstackinterface CORSIKAthirdparty) # for catch2 CORSIKA_ADD_TEST(testSecondaryView) +target_link_libraries (testSecondaryView CORSIKAstackinterface CORSIKAthirdparty) # for catch2 -add_executable (testCombinedStack testCombinedStack.cc) -target_link_libraries (testCombinedStack CORSIKAstackinterface CORSIKAthirdparty) # for catch2 CORSIKA_ADD_TEST(testCombinedStack) +target_link_libraries (testCombinedStack CORSIKAstackinterface CORSIKAthirdparty) # for catch2 diff --git a/Framework/Units/CMakeLists.txt b/Framework/Units/CMakeLists.txt index 639c5cbd8e589f8d3e98623773776a93636a4828..226396ea49132616c57a64a92cb13ddf18783686 100644 --- a/Framework/Units/CMakeLists.txt +++ b/Framework/Units/CMakeLists.txt @@ -20,6 +20,5 @@ target_include_directories (CORSIKAunits install (FILES ${CORSIKAunits_HEADERS} DESTINATION include/${CORSIKAunits_NAMESPACE}) # code testing -add_executable (testUnits testUnits.cc) -target_link_libraries (testUnits CORSIKAunits CORSIKAthirdparty) # for catch2 CORSIKA_ADD_TEST(testUnits) +target_link_libraries (testUnits CORSIKAunits CORSIKAthirdparty) # for catch2 diff --git a/Framework/Utilities/CMakeLists.txt b/Framework/Utilities/CMakeLists.txt index 763c534f1c6df580d04211e0d29f87588758418a..5624ea4f024c35d23def2ca8544a17a6bc980810 100644 --- a/Framework/Utilities/CMakeLists.txt +++ b/Framework/Utilities/CMakeLists.txt @@ -72,20 +72,16 @@ install ( # -------------------- # code unit testing -add_executable (testCOMBoost testCOMBoost.cc) - +CORSIKA_ADD_TEST(testCOMBoost) target_link_libraries ( testCOMBoost CORSIKAutilities CORSIKAthirdparty # for catch2 ) -add_executable (testCorsikaFenv testCorsikaFenv.cc) - +CORSIKA_ADD_TEST(testCorsikaFenv) target_link_libraries ( testCorsikaFenv CORSIKAutilities CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testCOMBoost) -add_test(testCorsikaFenv testCorsikaFenv) diff --git a/Processes/NullModel/CMakeLists.txt b/Processes/NullModel/CMakeLists.txt index c3355c77c93904d61fa61aab8d5a23fe9b1a5416..e84d6d9246833cd4e2e763cebd5ef238119a9bfa 100644 --- a/Processes/NullModel/CMakeLists.txt +++ b/Processes/NullModel/CMakeLists.txt @@ -50,8 +50,7 @@ install ( # -------------------- # code unit testing -add_executable (testNullModel testNullModel.cc) - +CORSIKA_ADD_TEST(testNullModel) target_link_libraries ( testNullModel ProcessNullModel @@ -60,4 +59,3 @@ target_link_libraries ( CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testNullModel) diff --git a/Processes/Pythia/CMakeLists.txt b/Processes/Pythia/CMakeLists.txt index adc953090c31505acf4fd4c6c85dd85435ca136c..ae6467108c5cb0b938ded042d770301d5da811d4 100644 --- a/Processes/Pythia/CMakeLists.txt +++ b/Processes/Pythia/CMakeLists.txt @@ -68,12 +68,12 @@ install ( # -------------------- # code unit testing -add_executable (testPythia + +CORSIKA_ADD_TEST(testPythia + SOURCES testPythia.cc ${MODEL_HEADERS} - ) - - +) target_link_libraries ( testPythia ProcessPythia @@ -85,4 +85,3 @@ target_link_libraries ( ${PYTHIA8_LIBRARY} ) -CORSIKA_ADD_TEST(testPythia) diff --git a/Processes/Sibyll/CMakeLists.txt b/Processes/Sibyll/CMakeLists.txt index 58b83f9b8ebccc6292752982ea26735944e536a2..46b19c5009867bcae6b2ea285585d261bed52b4f 100644 --- a/Processes/Sibyll/CMakeLists.txt +++ b/Processes/Sibyll/CMakeLists.txt @@ -100,10 +100,11 @@ install ( # -------------------- # code unit testing -add_executable (testSibyll +CORSIKA_ADD_TEST(testSibyll + SOURCES testSibyll.cc ${MODEL_HEADERS} - ) +) target_link_libraries ( testSibyll @@ -114,4 +115,3 @@ target_link_libraries ( CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testSibyll) diff --git a/Processes/StackInspector/CMakeLists.txt b/Processes/StackInspector/CMakeLists.txt index f8297639672f215e7a34e2330bd8e8387454d185..cbf216ca9094463912ff36eade3293660aba967b 100644 --- a/Processes/StackInspector/CMakeLists.txt +++ b/Processes/StackInspector/CMakeLists.txt @@ -52,8 +52,7 @@ install ( # -------------------- # code unit testing -add_executable (testStackInspector testStackInspector.cc) - +CORSIKA_ADD_TEST(testStackInspector) target_link_libraries ( testStackInspector ProcessStackInspector @@ -61,4 +60,3 @@ target_link_libraries ( CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testStackInspector) diff --git a/Processes/TrackingLine/CMakeLists.txt b/Processes/TrackingLine/CMakeLists.txt index c8b950532dd5e34b092f29d071604e9b8e4b75cf..24dcabc8b0c7d581baddbde0e817fa96ffe0a7c3 100644 --- a/Processes/TrackingLine/CMakeLists.txt +++ b/Processes/TrackingLine/CMakeLists.txt @@ -47,11 +47,9 @@ install (FILES ${MODEL_HEADERS} DESTINATION include/${MODEL_NAMESPACE}) # #-- -- -- -- -- -- -- -- -- -- # #code unit testing -add_executable (testTrackingLine testTrackingLine.cc) - +CORSIKA_ADD_TEST(testTrackingLine) target_link_libraries ( testTrackingLine ProcessTrackingLine CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testTrackingLine) diff --git a/Stack/NuclearStackExtension/CMakeLists.txt b/Stack/NuclearStackExtension/CMakeLists.txt index 6032c0b90218790d6622a0474af371c62687b711..6a035375e3dc100af848c84aad484aff3f55fc6c 100644 --- a/Stack/NuclearStackExtension/CMakeLists.txt +++ b/Stack/NuclearStackExtension/CMakeLists.txt @@ -31,11 +31,7 @@ install ( # ---------------- # code unit testing -add_executable ( - testNuclearStackExtension - testNuclearStackExtension.cc - ) - +CORSIKA_ADD_TEST(testNuclearStackExtension) target_link_libraries ( testNuclearStackExtension SuperStupidStack @@ -45,4 +41,3 @@ target_link_libraries ( CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testNuclearStackExtension) diff --git a/Stack/SuperStupidStack/CMakeLists.txt b/Stack/SuperStupidStack/CMakeLists.txt index d787f0d033ce0977a96c875412685c4dc1f1d38c..777e65a3d1352f1085b7b057003d01e32e9ba4c5 100644 --- a/Stack/SuperStupidStack/CMakeLists.txt +++ b/Stack/SuperStupidStack/CMakeLists.txt @@ -31,11 +31,7 @@ install ( # ---------------- # code unit testing -add_executable ( - testSuperStupidStack - testSuperStupidStack.cc - ) - +CORSIKA_ADD_TEST(testSuperStupidStack) target_link_libraries ( testSuperStupidStack CORSIKAgeometry @@ -43,4 +39,3 @@ target_link_libraries ( CORSIKAunits CORSIKAthirdparty # for catch2 ) -CORSIKA_ADD_TEST(testSuperStupidStack)