IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 622884af authored by Hans Dembinski's avatar Hans Dembinski
Browse files

Merge branch 'sanitizers' into 'master'

Adding sanitizers (temporarily disabled globally until bugs are fixed)

See merge request !106
parents c6913f51 fb9cff3e
No related branches found
No related tags found
No related merge requests found
Showing
with 124 additions and 112 deletions
......@@ -2,6 +2,12 @@ image: corsika/devel:u-18.04
variables:
GIT_SSL_NO_VERIFY: "1"
## Runtime options for sanitizers
# (detect_leaks=0 because leak detection doesn't work in CI, but you can
# try to test with leak detection locally by using detect_leaks=1)
UBSAN_OPTIONS: "print_stacktrace=1"
LSAN_OPTIONS: "log_threads=1"
ASAN_OPTIONS: "detect_leaks=0:detect_stack_use_after_return=1"
build:
stage: build
......@@ -11,7 +17,7 @@ build:
- mkdir build
- cd build
- cmake ..
- cmake --build . -- -j 4
- cmake --build . -- -j 4
- ctest -j4 -V >& test.log
after_script:
- cd build
......
......@@ -13,6 +13,9 @@ enable_language (Fortran)
# ignore many irrelevant Up-to-date messages during install
set (CMAKE_INSTALL_MESSAGE LAZY)
# TEMPORARY: this should be removed, the sanitizers should be always enabled
option(CORSIKA_SANITIZERS_ENABLED "temporary way to globally disable sanitizers until the currently failing tests are fixed" OFF)
# directory for local cmake modules
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
include (CorsikaUtilities) # a few cmake function
......
......@@ -95,11 +95,61 @@ endmacro(CORSIKA_ADD_FILES_ABSOLUTE)
#################################################
#
# central macro to activate unit tests in cmake
# central macro to register unit tests in cmake
#
# 1) Simple use:
# Pass the name of the test.cc file as the first
# argument, without the ".cc" extention.
#
# Example: CORSIKA_ADD_TEST (testSomething)
#
# This generates target testSomething from file testSomething.cc.
#
# 2) Customize sources:
# If 1) doesn't work, use the SOURCES keyword to explicitly
# specify the sources.
#
# Example: CORSIKA_ADD_TEST (testSomething
# SOURCES source1.cc source2.cc someheader.h)
#
# 3) Customize sanitizers:
# You can override which sanitizers are compiled into the
# test, but only do this if the defaults do not work.
#
# Example: CORSIKA_ADD_TEST (testSomething SANITIZE undefined)
#
# Only uses the sanitizer for undefined behavior.
#
# In all cases, you can further customize the target with
# target_link_libraries(testSomething ...) and so on.
#
# TEMPORARY: All sanitizers are currently globally disabled by default, to enable them,
# set CORSIKA_SANITIZERS_ENABLED to TRUE.
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()
function (CORSIKA_ADD_TEST name)
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/)
if (CORSIKA_SANITIZERS_ENABLED)
# -O1 is suggested in clang docs to get reasonable performance
target_compile_options(${name} PRIVATE -O1 -fno-omit-frame-pointer -fsanitize=${sanitize} -fno-sanitize-recover=all)
set_target_properties(${name} PROPERTIES LINK_FLAGS "-fsanitize=${sanitize}")
endif()
add_test (NAME ${name} COMMAND ${name} -o ${PROJECT_BINARY_DIR}/test_outputs/junit-${name}.xml -r junit)
endfunction (CORSIKA_ADD_TEST)
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
target_link_libraries (cascade_example SuperStupidStack CORSIKAunits
# 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
......@@ -42,11 +36,12 @@ 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
target_link_libraries (boundary_example SuperStupidStack CORSIKAunits CORSIKAlogging
CORSIKA_ADD_TEST (boundary_example)
target_link_libraries (boundary_example
SuperStupidStack
CORSIKAunits
CORSIKAlogging
CORSIKArandom
ProcessSibyll
CORSIKAcascade
......@@ -60,12 +55,12 @@ 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
target_link_libraries (cascade_proton_example SuperStupidStack CORSIKAunits
CORSIKA_ADD_TEST (cascade_proton_example)
target_link_libraries (cascade_proton_example
SuperStupidStack
CORSIKAunits
CORSIKAlogging
CORSIKArandom
ProcessSibyll
......@@ -84,14 +79,13 @@ 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
CORSIKA_ADD_TEST(vertical_EAS)
target_link_libraries (vertical_EAS
SuperStupidStack
CORSIKAunits
CORSIKAlogging
CORSIKArandom
ProcessSibyll
......@@ -110,14 +104,11 @@ target_link_libraries (vertical_EAS SuperStupidStack CORSIKAunits
CORSIKAprocesssequence
)
install (TARGETS vertical_EAS DESTINATION share/examples)
# CORSIKA_ADD_TEST (vertical_EAS) not yet...
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)
......@@ -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)
......@@ -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)
......@@ -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)
......@@ -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)
......@@ -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)
......@@ -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)
......@@ -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)
......@@ -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
......@@ -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
......@@ -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)
......@@ -52,8 +52,7 @@ install (
# --------------------
# code unit testing
#add_executable (testNullModel testNullModel.cc)
#CORSIKA_ADD_TEST (testNullModel testNullModel.cc)
#target_link_libraries (
# testNullModel ProcessNullModel
# CORSIKAsetup
......@@ -61,5 +60,4 @@ install (
# CORSIKAunits
# CORSIKAthirdparty # for catch2
# )
# CORSIKA_ADD_TEST(testNullModel)
......@@ -51,14 +51,12 @@ install (
# --------------------
# code unit testing
#~ add_executable (ProcessHadronicElasticModel testProcessHadronicElasticModel.cc)
#~ target_link_libraries (
#~ testProcessHadronicElasticModel
#~ ProcessHadronicElasticModel
#~ CORSIKAsetup
#~ CORSIKAgeometry
#~ CORSIKAunits
#~ CORSIKAthirdparty # for catch2
#~ )
#~ CORSIKA_ADD_TEST(testNullModel)
# CORSIKA_ADD_TEST (testProcessHadronicElasticModel)
# target_link_libraries (
# testProcessHadronicElasticModel
# ProcessHadronicElasticModel
# CORSIKAsetup
# CORSIKAgeometry
# CORSIKAunits
# CORSIKAthirdparty # for catch2
# )
......@@ -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)
......@@ -48,10 +48,10 @@ install (
# --------------------
# code unit testing
add_executable (testParticleCut
CORSIKA_ADD_TEST(testParticleCut SOURCES
testParticleCut.cc
${MODEL_HEADERS}
)
)
target_link_libraries (
testParticleCut
......@@ -64,4 +64,3 @@ target_link_libraries (
CORSIKAenvironment
CORSIKAthirdparty # for catch2
)
CORSIKA_ADD_TEST(testParticleCut)
......@@ -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)
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment