Back to home page

EIC code displayed by LXR

 
 

    


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 ADD_TEST( t_test_python_import "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0052   pytest ${PROJECT_SOURCE_DIR}/DDTest/python/test_import.py)
0053 SET_TESTS_PROPERTIES( t_test_python_import PROPERTIES FAIL_REGULAR_EXPRESSION  "Exception;EXCEPTION;ERROR;Error" )
0054 
0055 if (DD4HEP_USE_GEANT4)
0056 
0057   ADD_TEST( t_test_python_import_ddg4 "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0058     pytest ${PROJECT_SOURCE_DIR}/DDTest/python/test_import_ddg4.py)
0059   SET_TESTS_PROPERTIES( t_test_python_import_ddg4 PROPERTIES FAIL_REGULAR_EXPRESSION  "Exception;EXCEPTION;ERROR;Error" )
0060 
0061   if(DD4HEP_USE_HEPMC3)
0062     set(TEST_HEPMC3_EXTENSIONS)
0063 
0064     if(DD4HEP_HEPMC3_COMPRESSION_SUPPORT)
0065       file(ARCHIVE_CREATE
0066         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc.gz
0067         PATHS ${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/geantinos.hepmc
0068         FORMAT raw
0069         COMPRESSION GZip)
0070       list(APPEND TEST_HEPMC3_EXTENSIONS .gz)
0071       file(ARCHIVE_CREATE
0072         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc.xz
0073         PATHS ${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/geantinos.hepmc
0074         FORMAT raw
0075         COMPRESSION XZ)
0076       list(APPEND TEST_HEPMC3_EXTENSIONS .xz)
0077       file(ARCHIVE_CREATE
0078         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc.bz2
0079         PATHS ${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/geantinos.hepmc
0080         FORMAT raw
0081         COMPRESSION BZip2)
0082       list(APPEND TEST_HEPMC3_EXTENSIONS .bz2)
0083     endif()
0084 
0085     foreach(TEST_HEPMC3_EXTENSION "" ${TEST_HEPMC3_EXTENSIONS})
0086       if("${TEST_HEPMC3_EXTENSION}" STREQUAL "")
0087         set(TEST_HEPMC3_INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/Pythia_output.hepmc${TEST_HEPMC3_EXTENSION}")
0088       else()
0089         set(TEST_HEPMC3_INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/geantinos.hepmc${TEST_HEPMC3_EXTENSION}")
0090       endif()
0091       get_filename_component(TEST_HEPMC3_INPUT_FILE_NAME "${TEST_HEPMC3_INPUT_FILE}" NAME)
0092       string(REPLACE "." "_" TEST_NAME "test_ddsim_hepmc3_${TEST_HEPMC3_INPUT_FILE_NAME}")
0093 
0094       add_test( t_${TEST_NAME} "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0095         ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=1
0096         --outputFile=${TEST_NAME}.root --inputFiles ${TEST_HEPMC3_INPUT_FILE}
0097         --part.userParticleHandler=)
0098 
0099       # Tests causes G4Exception about: Isomer level 9 may be ambiguous, just a warning
0100       # space before Exception intentional!!!
0101       set_tests_properties( t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION  "ERROR;Error; Exception" )
0102     endforeach()
0103   endif()
0104 
0105   foreach(TEST_NAME
0106       test_EventReaders
0107       )
0108     add_executable(${TEST_NAME} src/${TEST_NAME}.cc)
0109     if(DD4HEP_USE_HEPMC3)
0110       target_compile_definitions(${TEST_NAME} PRIVATE DD4HEP_USE_HEPMC3)
0111     endif()
0112     if(DD4HEP_USE_LCIO)
0113       target_compile_definitions(${TEST_NAME} PRIVATE DD4HEP_USE_LCIO)
0114     endif()
0115     target_link_libraries(${TEST_NAME} DD4hep::DDCore DD4hep::DDRec DD4hep::DDG4)
0116     target_include_directories(${TEST_NAME} PRIVATE ./include)
0117     install(TARGETS ${TEST_NAME} DESTINATION bin)
0118 
0119     add_test(NAME t_${TEST_NAME} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/run_test.sh ${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR})
0120     set_tests_properties(t_${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "TEST_FAILED")
0121   endforeach(TEST_NAME)
0122 
0123 
0124   set(DDSIM_OUTPUT_FILES .root)
0125 
0126   if(DD4HEP_USE_LCIO)
0127     LIST(APPEND DDSIM_OUTPUT_FILES .slcio)
0128   endif()
0129 
0130   if(DD4HEP_USE_EDM4HEP)
0131     LIST(APPEND DDSIM_OUTPUT_FILES edm4hep.root)
0132   endif()
0133 
0134   foreach(OUTPUT_FILE IN LISTS DDSIM_OUTPUT_FILES)
0135     ADD_TEST( t_test_ddsim_${OUTPUT_FILE} "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0136       ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -G -N=2
0137       --outputFile=testSid${OUTPUT_FILE}
0138       --gun.position \"0.0 0.0 1.0*cm\" --gun.direction \"1.0 0.0 1.0\" --gun.momentumMax 100*GeV --part.userParticleHandler=)
0139     SET_TESTS_PROPERTIES( t_test_ddsim_${OUTPUT_FILE} PROPERTIES FAIL_REGULAR_EXPRESSION  " Exception; EXCEPTION;ERROR;Error" )
0140   endforeach()
0141 
0142   add_test( t_ddsimUserPlugins "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0143     ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=10
0144     --outputFile=t_ddsimUserPlugins.root -G
0145     --steeringFile ${CMAKE_CURRENT_SOURCE_DIR}/python/userPluginsSteeringFile.PY
0146     --part.userParticleHandler=
0147   )
0148 
0149   add_test( t_ddsimUserActions "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
0150     ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=10
0151     --outputFile=t_ddsimUserActions.root -G
0152     --steeringFile ${CMAKE_CURRENT_SOURCE_DIR}/python/userActionsSteeringFile.PY
0153     --action.event "Geant4TestEventAction/EventActionCLI1"
0154     --action.step "Geant4TestStepAction/StepActionCLI1,Geant4TestStepAction/StepActionCLI2"
0155     --action.step '\[ \"Geant4TestStepAction/StepActionCLI3\" , \"Geant4TestStepAction/StepActionCLI4\" \]'
0156     --action.stack '\{ \"name\" : \"Geant4TestStackAction/StackActionCLI1\" , \"parameter\" : \{ \"Property_int\" : 10 \} \}'
0157     --action.stack '\[ \{ \"name\" : \"Geant4TestStackAction/StackActionCLI2\" , \"parameter\" : { \"Property_int\" : 10 \} \} \]'
0158     --printLevel VERBOSE
0159   )
0160   set_tests_properties( t_ddsimUserActions PROPERTIES
0161     PASS_REGULAR_EXPRESSION "Deleting object StepActionCLI1"
0162   )
0163 
0164 endif()
0165 install(DIRECTORY include/DD4hep DESTINATION include)
0166 
0167 
0168 # Test that GrammarUnparsed and GrammarParsed fail to be compiled
0169 add_executable(test_failToCompile src/test_failToCompileGrammar.cc)
0170 target_link_libraries(test_failToCompile DD4hep::DDCore)
0171 # Avoid building these targets normally
0172 set_target_properties(test_failToCompile PROPERTIES
0173   EXCLUDE_FROM_ALL TRUE
0174   EXCLUDE_FROM_DEFAULT_BUILD TRUE)
0175 
0176 add_test(NAME TestFailToCompile
0177   COMMAND ${CMAKE_COMMAND} --build . --target test_failToCompile --config $<CONFIGURATION>
0178   WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
0179 set_tests_properties(TestFailToCompile
0180   PROPERTIES
0181   PASS_REGULAR_EXPRESSION "The header files GrammarParsed.h and GrammarUnparsed.h may not be included in the same compilation unit")