From a828c248b33743e34bfb9a6a00cc63676903c532 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Tue, 4 Feb 2014 12:57:06 +0000 Subject: [PATCH] - added tests to examples ILDExDet, ILDExSimu, noviceN04 - fixed env scripts - increased version to v00-06 - updated documentation --- CMakeLists.txt | 10 +++--- ReadMe.txt | 10 ++++++ cmake/run_test_package.sh | 29 +++++++++++++++ cmake/thisdd4hep.sh | 13 +++++-- cmake/thisdd4hep_package.sh.in | 17 +++++++++ doc/release.notes | 18 ++++++++++ examples/CMakeLists.txt | 8 ++++- examples/CTestConfig.cmake | 13 +++++++ examples/ILDExDet/CMakeLists.txt | 59 +++++++++++++++++++++++++++++++ examples/ILDExSimu/CMakeLists.txt | 30 +++++++++++++++- examples/noviceN04/CMakeLists.txt | 45 ++++++++++++++--------- 11 files changed, 226 insertions(+), 26 deletions(-) create mode 100755 cmake/run_test_package.sh create mode 100644 examples/CTestConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b8cd87fd..873655e7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(DD4hep) # project version SET( DD4hep_VERSION_MAJOR 0 ) -SET( DD4hep_VERSION_MINOR 5 ) +SET( DD4hep_VERSION_MINOR 6 ) SET( DD4hep_VERSION_PATCH 0 ) SET( DD4hep_VERSION "${DD4hep_VERSION_MAJOR}.${DD4hep_VERSION_MINOR}" ) @@ -108,11 +108,9 @@ add_subdirectory(UtilityApps) #---Configuration------------------------------------------------------------------- -# ----for APPLE scripts have to set the DYLD_LIBRARY_PATH ? -if( APPLE ) +# ----for APPLE scripts have to set the DYLD_LIBRARY_PATH +if( APPLE ) set( USE_DYLD 1) -else() - set( USE_DYLD 0) endif() configure_file(cmake/thisdd4hep.csh thisdd4hep.csh @ONLY) @@ -125,7 +123,7 @@ install(FILES ${CMAKE_BINARY_DIR}/thisdd4hep.csh ${CMAKE_BINARY_DIR}/thisdd4hep. install(PROGRAMS ${CMAKE_BINARY_DIR}/run_test.sh DESTINATION bin ) -# PERMISSIONS OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_EXECUTE, WORLD_READ, WORLD_EXECUTE, + #----------------------------------------------------------------------------------- display_std_variables() diff --git a/ReadMe.txt b/ReadMe.txt index 71222af8e..96afc9955 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -194,6 +194,16 @@ or build all examples in one go: geoConverter -compact2lcdd -input file:../compact/ILDEx.xml -output ILD_toy.lcdd +- running example tests: + ----------------------- + + make install ; make test + + or: + ctest -V -R converter + ctest -V -R sim + ctest -V -R noviceN04 + 9) run SLIC simulation on lccd file created with DD4Hep: diff --git a/cmake/run_test_package.sh b/cmake/run_test_package.sh new file mode 100755 index 000000000..d108c97e0 --- /dev/null +++ b/cmake/run_test_package.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# +# Simple script to run DD4hep tests +# - sources this${PackageName}.sh first and then +# calls the command (given as first argument) +# with all following arguments +# + + +#----- initialize environment for this package - including DD4hep + +source @CMAKE_INSTALL_PREFIX@/bin/this@PackageName@.sh + +#----- parse command line - first argument is the +# test to run +command=$1 +theargs="" +shift +for i in "$@" ; do + if [ $i != ${command} ] ; then + theargs="${theargs} $i" + fi +done + +#echo " #### LD_LIBRARY_PATH = : ${LD_LIBRARY_PATH}" + +echo " ### running test : '" ${command} ${theargs} "'" +${command} ${theargs} diff --git a/cmake/thisdd4hep.sh b/cmake/thisdd4hep.sh index d2fdbbd0a..f89ce8746 100644 --- a/cmake/thisdd4hep.sh +++ b/cmake/thisdd4hep.sh @@ -3,9 +3,11 @@ # # This script if for the csh like shells, see thisdd4hep.csh for csh like shells. # -# Author: Pere Mato +# Author: Pere Mato. F. Gaede +#echo " ### thisdd4hep.sh: initialize the environment for DD4hep ! " + if [ "x${BASH_ARGV[0]}" = "x" ]; then if [ ! -f bin/thisdd4hep.sh ]; then echo ERROR: must "cd where/dd4hep/is" before calling ". bin/thisdd4hep.sh" for this version of bash! @@ -28,8 +30,15 @@ then # ---------- initialze geant4 environment test -r ${G4ENV_INIT} && { cd $(dirname ${G4ENV_INIT}) ; . ./$(basename ${G4ENV_INIT}) ; cd $OLDPWD ; } + +#---- if geant4 was built with external CLHEP we have to extend the dynamic search path if [ @GEANT4_WITH_CLHEP@ ] ; then - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CLHEP_LIBRARY_PATH@ + if [ @USE_DYLD@ ] + then + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:@CLHEP_LIBRARY_PATH@ + else + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CLHEP_LIBRARY_PATH@ + fi fi fi diff --git a/cmake/thisdd4hep_package.sh.in b/cmake/thisdd4hep_package.sh.in index b100116a4..dd11907c4 100644 --- a/cmake/thisdd4hep_package.sh.in +++ b/cmake/thisdd4hep_package.sh.in @@ -17,3 +17,20 @@ then else export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CMAKE_INSTALL_PREFIX@/lib fi + + +# -- need to extend dynamic search path for all external libraries: + +for lp in @External_LIBRARY_DIRS@ +do + + + if [ @USE_DYLD@ ] + then + # echo " ### export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${lp} " + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${lp} + else + # echo " ### export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lp} " + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lp} + fi +done diff --git a/doc/release.notes b/doc/release.notes index ddc251828..0ad9ac86b 100644 --- a/doc/release.notes +++ b/doc/release.notes @@ -1,6 +1,24 @@ DD4hep ---- Release Notes ================================= + + -------- +| v00-06 | sixth beta release ... + -------- + +2014/02/04 Frank Gaede +----------------------- + - fixed environment scripts thisdd4hep.sh and this${PackageName}.sh + to also export library pathes for external libraries (CLHEP, LCIO, gear) + + - added some simple tests to ILDExDet, ILDExSimu and noviceN04 + - provide cmake script run_test_package.sh ( configured as run_test_${PackageName} ) + to call test binaries after initializing the environment + (needed for automated/nightly tests) + + - updated Readme.txt wrt build procedure and running the tests + + 2014/01/17 Markus Frank -------------------------- - Prepare implementation of Alignment using Release and Grap features of TGeoVolume diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ca4723349..6fea6e78d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -16,6 +16,12 @@ cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) project(DD4hepExample) +#---Testing------------------------------------------------------------------------- +if(BUILD_TESTING) + include(CTest) + enable_testing() +endif(BUILD_TESTING) +#---------------------------------------------------------------------------------- # # (un)comment as needed # @@ -27,7 +33,7 @@ add_subdirectory(CLICSiD) add_subdirectory(noviceN04) -#---- does not build on mac ... +#---- does not build on mac or ubuntu ... #add_subdirectory(Segmentation) diff --git a/examples/CTestConfig.cmake b/examples/CTestConfig.cmake new file mode 100644 index 000000000..d69479965 --- /dev/null +++ b/examples/CTestConfig.cmake @@ -0,0 +1,13 @@ +## This file should be placed in the root directory of your project. +## Then modify the CMakeLists.txt file in the root directory of your +## project to incorporate the testing dashboard. +## # The following are required to uses Dart and the Cdash dashboard +## ENABLE_TESTING() +## INCLUDE(CTest) +set(CTEST_PROJECT_NAME "DD4hep") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "aidasoft.desy.de") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=DD4hep") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/examples/ILDExDet/CMakeLists.txt b/examples/ILDExDet/CMakeLists.txt index 4ca814bd8..96a14b69d 100644 --- a/examples/ILDExDet/CMakeLists.txt +++ b/examples/ILDExDet/CMakeLists.txt @@ -41,7 +41,16 @@ find_package( ROOT REQUIRED ) set( ROOT_COMPONENT_LIBRARIES Geom Reflex) + find_package( GEAR REQUIRED) + +# add all gear library pathes to External_LIBRARY_DIRS for the environment script +foreach(lp ${GEAR_LIBRARY_DIRS}) + set( External_LIBRARY_DIRS "${External_LIBRARY_DIRS} ${lp}") +endforeach(lp) +#message( STATUS " *** pathes : ${External_LIBRARY_DIRS} " ) + + #------------------------------------------------------------- # add additional packages here @@ -81,6 +90,16 @@ else() endif() +#---Testing------------------------------------------------------------------------- +if(BUILD_TESTING) + include(CTest) + enable_testing() +endif(BUILD_TESTING) + +configure_file( ${DD4hep_ROOT}/cmake/run_test_package.sh run_test_${PackageName}.sh @ONLY) +INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run_test_${PackageName}.sh + DESTINATION bin ) + #---- configure run environment --------------- configure_file( ${DD4hep_ROOT}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY) @@ -102,5 +121,45 @@ install(TARGETS ${PackageName} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ) + # to do: add corresponding uninstall... #------------------------------------------------------- + + + +#################################### +# +# Add Tests foir ILDExDet here +# +#################################### + +SET( test_name "test_converter_lcdd" ) +ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" + geoConverter -compact2lcdd -input ${CMAKE_SOURCE_DIR}/ILDExDet/compact/ILDEx.xml -output ILDExDet.lcdd ) +#----- here we simply require that at least 100 volumes have been converted +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION " Handled [1-9][0-9][0-9]+ volumes" ) + +SET( test_name "test_converter_gdml" ) +ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" + geoConverter -compact2gdml -input ${CMAKE_SOURCE_DIR}/ILDExDet/compact/ILDEx.xml -output ILDExDet.gdml ) +#----- here we simply require that at least 100 volumes have been converted +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION " Handled [1-9][0-9][0-9]+ volumes" ) + +SET( test_name "test_converter_vis" ) +ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" + geoConverter -compact2vis -input ${CMAKE_SOURCE_DIR}/ILDExDet/compact/ILDEx.xml -output ILDExDet.vis ) +#----- here we simply require that at least 100 volumes have been converted +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION " Handled [1-9][0-9][0-9]+ volumes" ) + + +#SET( test_name "test_converter_pandora" ) +#ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" +# geoConverter -compact2pandora -input ${CMAKE_SOURCE_DIR}/ILDExDet/compact/ILDEx.xml -output ILDExDet.pandora ) +##----- here we simply require that at least 100 volumes have been converted +#SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION " Handled [1-9][0-9][0-9]+ volumes" ) + + +# no explicit failed condition +#SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "TEST_FAILED" ) + + diff --git a/examples/ILDExSimu/CMakeLists.txt b/examples/ILDExSimu/CMakeLists.txt index c46f236dc..7ab346f3c 100644 --- a/examples/ILDExSimu/CMakeLists.txt +++ b/examples/ILDExSimu/CMakeLists.txt @@ -54,6 +54,10 @@ INCLUDE(${Geant4_USE_FILE}) # this also takes care of geant 4 definitions and find_package(LCIO REQUIRED) +# add all lcio library pathes to External_LIBRARY_DIRS for the environment script +foreach(lp ${LCIO_LIBRARY_DIRS}) + set( External_LIBRARY_DIRS "${External_LIBRARY_DIRS} ${lp}") +endforeach(lp) #------------------------------------------------------------- @@ -90,6 +94,16 @@ target_link_libraries(${PackageName} ${DD4hep_LIBRARIES} ) +#---Testing------------------------------------------------------------------------- +if(BUILD_TESTING) + include(CTest) + enable_testing() +endif(BUILD_TESTING) + +configure_file( ${DD4hep_ROOT}/cmake/run_test_package.sh run_test_${PackageName}.sh @ONLY) +INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run_test_${PackageName}.sh + DESTINATION bin ) + #---Rootmap generation-------------------------------------------------------------- # fg: not needed here (?) #if(APPLE) @@ -116,4 +130,18 @@ install(TARGETS ${PackageName} # to do: add corresponding uninstall... -#------------------------------------------------------- \ No newline at end of file +#------------------------------------------------------- + +#################################### +# +# Add Tests foir ILDExSimu here +# +#################################### + +SET( test_name "test_sim_ildexdet" ) +ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" + ILDExSimu file:${CMAKE_CURRENT_SOURCE_DIR}/../ILDExDet/compact/ILDEx.xml file:${CMAKE_CURRENT_SOURCE_DIR}/../ILDExDet/compact/geant4.xml ${CMAKE_CURRENT_SOURCE_DIR}/run1.mac ) + +#----- check for typical expected output: +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION " Begin of event: 2" ) +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "-End of Run-" ) diff --git a/examples/noviceN04/CMakeLists.txt b/examples/noviceN04/CMakeLists.txt index 127d34565..0bfbfab6a 100644 --- a/examples/noviceN04/CMakeLists.txt +++ b/examples/noviceN04/CMakeLists.txt @@ -44,16 +44,8 @@ set( ROOT_COMPONENT_LIBRARIES Geom Reflex) # add additional packages here find_package(Geant4 REQUIRED ui_all vis_all) -##---Handle the case CLHEP is not included in Geant4------------------------------ -#if(NOT Geant4_clhep_FOUND) -# find_package(CLHEP REQUIRED) -# set(Geant4_INCLUDE_DIRS ${Geant4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}) -# set(Geant4_LIBRARIES ${Geant4_LIBRARIES} ${CLHEP_LIBRARIES}) -#endif() -INCLUDE(${Geant4_USE_FILE}) # this also takes care of geant 4 definitions and include dirs - -#find_package(LCIO REQUIRED) +INCLUDE(${Geant4_USE_FILE}) # this also takes care of geant 4 definitions and include dirs #------------------------------------------------------------- @@ -87,14 +79,18 @@ target_link_libraries(${PackageName} ${DD4hep_LIBRARIES} add_executable( exampleN04 exampleN04.cc ) -target_link_libraries(exampleN04 ${PackageName} -# ${DD4hep_LIBRARIES} -# ${ROOT_LIBRARIES} -# ${ROOT_COMPONENT_LIBRARIES} -# ${Geant4_LIBRARIES} -# ${LCIO_LIBRARIES} - ) +target_link_libraries(exampleN04 ${PackageName} ) + +#---Testing------------------------------------------------------------------------- +if(BUILD_TESTING) + include(CTest) + enable_testing() +endif(BUILD_TESTING) + +configure_file( ${DD4hep_ROOT}/cmake/run_test_package.sh run_test_${PackageName}.sh @ONLY) +INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run_test_${PackageName}.sh + DESTINATION bin ) #---Rootmap generation-------------------------------------------------------------- if(APPLE) @@ -104,6 +100,9 @@ else() endif() + + + #---- configure run environment --------------- configure_file( ${DD4hep_ROOT}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY) @@ -145,3 +144,17 @@ install(TARGETS ${PackageName} exampleN04 # to do: add corresponding uninstall... #------------------------------------------------------- + + +#################################### +# +# Add Tests foir noviceN04 here +# +#################################### + +SET( test_name "test_noviceN04" ) +ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" + exampleN04 file:${CMAKE_CURRENT_SOURCE_DIR}/compact/N04.xml file:${CMAKE_CURRENT_SOURCE_DIR}/compact/geant4.xml ${CMAKE_CURRENT_SOURCE_DIR}/exampleN04.in ) + +#----- check for typical expected output: +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION " Number of events processed : 3" ) -- GitLab