Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-29 07:35:52

0001 #!/bin/bash
0002 #=================================================================================
0003 #
0004 #  AIDA Detector description implementation 
0005 #---------------------------------------------------------------------------------
0006 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0007 # All rights reserved.
0008 #
0009 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0010 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0011 #
0012 #=================================================================================
0013 
0014 usage()  {
0015     echo "run_test_in_loop.sh -opt [-opt]";
0016     echo "   -n         <name>        Supply test name";
0017     echo "   --name     <name>        Supply test name";
0018     echo "   -l         <number>      Number of test loops";
0019     echo "   --loops    <number>      Number of test loops";
0020     echo "   -j         <number>      Parallelism flag";
0021     echo "   --parallel <number>      Parallelism flag";
0022     echo "   -g         <dir>         Non default Geant4 data directory";
0023     echo "   --g4-data  <dir>         Non default Geant4 data directory";
0024     echo "   -h                       Show this help.";
0025     echo "   --help                   Show this help.";
0026     exit EINVAL;
0027 }
0028 
0029 PARSED_ARGUMENTS=$(getopt -a -n run_test_in_loop -o hg:Nl:R:j: --longoptions help,g4-data:,show-only,loops:,test-regex:,parallel: -- "[run_test_in_loop]" $*)
0030 VALID_ARGUMENTS=$?
0031 if [ "$VALID_ARGUMENTS" != "0" ]; then
0032     do_print "Invalid arguments to cmake step";
0033     usage;
0034 fi;
0035 
0036 noop=;
0037 test_name=;
0038 num_loop=1
0039 parallel=10;
0040 g4_data_dir=;
0041 eval set -- "$PARSED_ARGUMENTS";
0042 while :
0043 do
0044     case "${1}" in
0045         -g | --g4-data)       g4_data_dir=${2};           shift 2 ;;
0046         -l | --loops)         num_loop=${2};              shift 2 ;;
0047         -R | --tests-regex)   test_name="-R ${2}";        shift 2 ;;
0048         -j | --parallel)      parallel=${2};              shift 2 ;;
0049         -N | --show-only)     noop="-N";                  shift ;;
0050         -h | --help)    usage;                            shift ;;
0051         # -- means the end of the arguments; drop this, and break out of the while loop
0052         --) shift;  break;;
0053         # If invalid options were passed, then getopt should have reported an error,
0054         # which we checked as VALID_ARGUMENTS when getopt was called...
0055         *) do_print " Unexpected option: $1 - this should not happen."
0056             usage; shift; break;;
0057     esac;
0058 done;
0059 #
0060 if test -z "${num_loop}"; then
0061     usage;
0062 fi;
0063 #
0064 if test -z "${g4_data_dir}"; then
0065     g4_data_dir=/scratch/online/frankm/SW/Geant4Data;
0066 fi;
0067 #
0068 #
0069 #
0070 if test -n "${g4_data_dir}"; then
0071     export GEANT4_DATA_DIR=${g4_data_dir};
0072     export G4ABLADATA=${GEANT4_DATA_DIR}/G4ABLA3.3;
0073     export G4CHANNELINGDATA=${GEANT4_DATA_DIR}/G4CHANNELING2.0;
0074     export G4LEDATA=${GEANT4_DATA_DIR}/G4EMLOW8.8;
0075     export G4ENSDFSTATEDATA=${GEANT4_DATA_DIR}/G4ENSDFSTATE3.0;
0076     export G4INCLDATA=${GEANT4_DATA_DIR}/G4INCL1.3;
0077     export G4NEUTRONHPDATA=${GEANT4_DATA_DIR}/G4NDL4.7.1;
0078     export G4PARTICLEXSDATA=${GEANT4_DATA_DIR}/G4PARTICLEXS4.2;
0079     export G4PIIDATA=${GEANT4_DATA_DIR}/G4PII1.3;
0080     export G4SAIDXSDATA=${GEANT4_DATA_DIR}/G4SAIDDATA2.0;
0081     export G4LEVELGAMMADATA=${GEANT4_DATA_DIR}/PhotonEvaporation6.1.2;
0082     export G4RADIOACTIVEDATA=${GEANT4_DATA_DIR}/RadioactiveDecay6.1.2;
0083     export G4REALSURFACEDATA=${GEANT4_DATA_DIR}/RealSurface2.2;
0084 fi;
0085 #
0086 exec_command()  {
0087     $* | gawk '{ print strftime("[%Y-%m-%d %H:%M:%S] | "), $0 }';
0088 }
0089 #
0090 line="==============================";
0091 for i in $(seq 1 ${num_loop}); do
0092     exec_command echo "${line}${line}${line}${line}${line}";
0093     exec_command echo "Executing test "${test_name}" in loop number ${i}";
0094     exec_command ctest -j ${parallel} ${noop} ${test_name};
0095     if test "$?" = "0"; then
0096         exec_command echo "=====> Test ${i} SUCCEEDED: exit code: $? ";
0097     else
0098         exec_command echo "=====> Test ${i}  FAILED: exit code: $?";
0099         exec_command echo "${line}${line}${line}${line}${line}";
0100         exit $?;
0101     fi;
0102 done;
0103 exec_command echo "${line}${line}${line}${line}${line}";