Warning, /DD4hep/DDTest/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 #=================================================================================
0002 # AIDA Detector description implementation
0003 #---------------------------------------------------------------------------------
0004 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 # All rights reserved.
0006 #
0007 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 #
0010 #=================================================================================
0011
0012 add_library(DDTest INTERFACE)
0013 add_library(DD4hep::DDTest ALIAS DDTest)
0014
0015 dd4hep_use_python_executable()
0016 target_include_directories(DDTest INTERFACE include)
0017
0018 foreach(TEST_NAME
0019 test_example
0020 test_bitfield64
0021 test_bitfieldcoder
0022 test_DetType
0023 test_PolarGridRPhi2
0024 test_cellDimensions
0025 test_cellDimensionsRPhi2
0026 test_segmentationHandles
0027 test_Evaluator
0028 test_shapes
0029 )
0030 add_executable(${TEST_NAME} src/${TEST_NAME}.cc)
0031 target_link_libraries(${TEST_NAME} DD4hep::DDCore DD4hep::DDRec DD4hep::DDTest)
0032 install(TARGETS ${TEST_NAME} RUNTIME DESTINATION bin)
0033
0034 set(cmd ${CMAKE_INSTALL_PREFIX}/bin/run_test.sh ${TEST_NAME})
0035 add_test(NAME t_${TEST_NAME} COMMAND ${cmd} ${TEST_NAME})
0036 set_tests_properties(t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "TEST_FAILED")
0037 endforeach()
0038
0039 foreach(TEST_NAME
0040 test_units
0041 test_surface
0042 )
0043 add_executable(${TEST_NAME} src/${TEST_NAME}.cc)
0044 target_link_libraries(${TEST_NAME} DD4hep::DDCore DD4hep::DDRec DD4hep::DDTest)
0045 install(TARGETS ${TEST_NAME} RUNTIME DESTINATION bin)
0046 add_test(NAME t_${TEST_NAME}
0047 COMMAND ${CMAKE_INSTALL_PREFIX}/bin/run_test.sh ${TEST_NAME} file:${CMAKE_CURRENT_SOURCE_DIR}/units.xml)
0048 set_tests_properties(t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "TEST_FAILED")
0049 endforeach()
0050
0051 find_program(HAVE_PYTEST pytest)
0052 if(NOT HAVE_PYTEST)
0053 message(WARNING "pytest not found! Skipping pytest tests.")
0054 endif()
0055
0056 if(HAVE_PYTEST)
0057 ADD_TEST( t_test_python_import "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0058 pytest ${PROJECT_SOURCE_DIR}/DDTest/python/test_import.py)
0059 SET_TESTS_PROPERTIES( t_test_python_import PROPERTIES FAIL_REGULAR_EXPRESSION "Exception;EXCEPTION;ERROR;Error" )
0060 endif()
0061
0062 if (DD4HEP_USE_GEANT4)
0063 if(HAVE_PYTEST)
0064 ADD_TEST( t_test_python_import_ddg4 "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0065 pytest ${PROJECT_SOURCE_DIR}/DDTest/python/test_import_ddg4.py)
0066 SET_TESTS_PROPERTIES( t_test_python_import_ddg4 PROPERTIES FAIL_REGULAR_EXPRESSION "Exception;EXCEPTION;ERROR;Error" )
0067 endif()
0068 if(DD4HEP_USE_HEPMC3)
0069 set(TEST_HEPMC3_EXTENSIONS)
0070
0071 if(DD4HEP_HEPMC3_COMPRESSION_SUPPORT)
0072 file(ARCHIVE_CREATE
0073 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc.gz
0074 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/geantinos.hepmc
0075 FORMAT raw
0076 COMPRESSION GZip)
0077 list(APPEND TEST_HEPMC3_EXTENSIONS .gz)
0078 file(ARCHIVE_CREATE
0079 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc.xz
0080 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/geantinos.hepmc
0081 FORMAT raw
0082 COMPRESSION XZ)
0083 list(APPEND TEST_HEPMC3_EXTENSIONS .xz)
0084 file(ARCHIVE_CREATE
0085 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc.bz2
0086 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/geantinos.hepmc
0087 FORMAT raw
0088 COMPRESSION BZip2)
0089 list(APPEND TEST_HEPMC3_EXTENSIONS .bz2)
0090 endif()
0091
0092 foreach(TEST_HEPMC3_EXTENSION "" ${TEST_HEPMC3_EXTENSIONS})
0093 if("${TEST_HEPMC3_EXTENSION}" STREQUAL "")
0094 set(TEST_HEPMC3_INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/Pythia_output.hepmc${TEST_HEPMC3_EXTENSION}")
0095 else()
0096 set(TEST_HEPMC3_INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc${TEST_HEPMC3_EXTENSION}")
0097 endif()
0098 get_filename_component(TEST_HEPMC3_INPUT_FILE_NAME "${TEST_HEPMC3_INPUT_FILE}" NAME)
0099 string(REPLACE "." "_" TEST_NAME "test_ddsim_hepmc3_${TEST_HEPMC3_INPUT_FILE_NAME}")
0100
0101 add_test( t_${TEST_NAME} "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0102 ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=1
0103 --outputFile=${TEST_NAME}.root --inputFiles ${TEST_HEPMC3_INPUT_FILE}
0104 --part.userParticleHandler=)
0105
0106 # Tests causes G4Exception about: Isomer level 9 may be ambiguous, just a warning
0107 # space before Exception intentional!!!
0108 set_tests_properties( t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR;Error; Exception" )
0109 endforeach()
0110 endif()
0111
0112 foreach(TEST_NAME
0113 test_EventReaders
0114 )
0115 add_executable(${TEST_NAME} src/${TEST_NAME}.cc)
0116 if(DD4HEP_USE_HEPMC3)
0117 target_compile_definitions(${TEST_NAME} PRIVATE DD4HEP_USE_HEPMC3)
0118 endif()
0119 if(DD4HEP_USE_EDM4HEP)
0120 target_compile_definitions(${TEST_NAME} PRIVATE DD4HEP_USE_EDM4HEP)
0121 endif()
0122 if(DD4HEP_USE_LCIO)
0123 target_compile_definitions(${TEST_NAME} PRIVATE DD4HEP_USE_LCIO)
0124 endif()
0125 target_link_libraries(${TEST_NAME} DD4hep::DDCore DD4hep::DDRec DD4hep::DDG4)
0126 target_include_directories(${TEST_NAME} PRIVATE ./include)
0127 install(TARGETS ${TEST_NAME} DESTINATION bin)
0128
0129 add_test(NAME t_${TEST_NAME} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/run_test.sh ${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR})
0130 set_tests_properties(t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "TEST_FAILED")
0131 endforeach(TEST_NAME)
0132
0133
0134 set(DDSIM_OUTPUT_FILES .root)
0135
0136 if(DD4HEP_USE_LCIO)
0137 LIST(APPEND DDSIM_OUTPUT_FILES .slcio)
0138 endif()
0139
0140 if(DD4HEP_USE_EDM4HEP)
0141 LIST(APPEND DDSIM_OUTPUT_FILES edm4hep.root)
0142 endif()
0143
0144 foreach(OUTPUT_FILE IN LISTS DDSIM_OUTPUT_FILES)
0145 ADD_TEST( t_test_ddsim_${OUTPUT_FILE} "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0146 ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -G -N=2
0147 --outputFile=testSid${OUTPUT_FILE}
0148 --gun.position \"0.0 0.0 1.0*cm\" --gun.direction \"1.0 0.0 1.0\" --gun.momentumMax 100*GeV --part.userParticleHandler=)
0149 SET_TESTS_PROPERTIES( t_test_ddsim_${OUTPUT_FILE} PROPERTIES FAIL_REGULAR_EXPRESSION " Exception; EXCEPTION;ERROR;Error" )
0150 endforeach()
0151
0152 add_test( t_ddsimUserPlugins "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0153 ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=10
0154 --outputFile=t_ddsimUserPlugins.root -G
0155 --steeringFile ${CMAKE_CURRENT_SOURCE_DIR}/python/userPluginsSteeringFile.PY
0156 --part.userParticleHandler=
0157 )
0158
0159 add_test( t_ddsimUserActions "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0160 ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=10
0161 --outputFile=t_ddsimUserActions.root -G
0162 --steeringFile ${CMAKE_CURRENT_SOURCE_DIR}/python/userActionsSteeringFile.PY
0163 --action.event "Geant4TestEventAction/EventActionCLI1"
0164 --action.step "Geant4TestStepAction/StepActionCLI1,Geant4TestStepAction/StepActionCLI2"
0165 --action.step '\[ \"Geant4TestStepAction/StepActionCLI3\" , \"Geant4TestStepAction/StepActionCLI4\" \]'
0166 --action.stack '\{ \"name\" : \"Geant4TestStackAction/StackActionCLI1\" , \"parameter\" : \{ \"Property_int\" : 10 \} \}'
0167 --action.stack '\[ \{ \"name\" : \"Geant4TestStackAction/StackActionCLI2\" , \"parameter\" : { \"Property_int\" : 10 \} \} \]'
0168 --printLevel VERBOSE
0169 )
0170 set_tests_properties( t_ddsimUserActions PROPERTIES
0171 PASS_REGULAR_EXPRESSION "Deleting object StepActionCLI1"
0172 )
0173
0174 if(DD4HEP_USE_EDM4HEP AND TARGET podio::podioIO)
0175 add_test( t_ddsimEDM4hepPlugins "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0176 ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=3
0177 --outputFile=ddsim_edm4hep_ZH.root
0178 --inputFiles=${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/ZH250_ISR.edm4hep.root
0179 --part.userParticleHandler=
0180 )
0181 endif()
0182
0183 endif()
0184 install(DIRECTORY include/DD4hep DESTINATION include)
0185
0186
0187 # Test that GrammarUnparsed and GrammarParsed fail to be compiled
0188 add_executable(test_failToCompile src/test_failToCompileGrammar.cc)
0189 target_link_libraries(test_failToCompile DD4hep::DDCore)
0190 # Avoid building these targets normally
0191 set_target_properties(test_failToCompile PROPERTIES
0192 EXCLUDE_FROM_ALL TRUE
0193 EXCLUDE_FROM_DEFAULT_BUILD TRUE)
0194
0195 add_test(NAME TestFailToCompile
0196 COMMAND ${CMAKE_COMMAND} --build . --target test_failToCompile --config $<CONFIGURATION>
0197 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
0198 set_tests_properties(TestFailToCompile
0199 PROPERTIES
0200 PASS_REGULAR_EXPRESSION "The header files GrammarParsed.h and GrammarUnparsed.h may not be included in the same compilation unit")