Skip to content

Commit a2c5293

Browse files
committed
Custom number of events in generator test
1 parent cf337d1 commit a2c5293

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

test/run_generator_tests.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ get_test_script_path_for_ini()
7676
echo ${path_to_test_script}
7777
}
7878

79+
get_nevents_from_ini()
80+
{
81+
# function to force the number of events to be simulated from the ini file (default = 100)
82+
# Syntax: #NEV> 10 (space between #NEV> and the number is mandatory)
83+
# To be used only if external generator takes too long to run causing timeouts in CI
84+
local ini_path=${1}
85+
local nev=$(grep "#NEV>" ${ini_path} | tail -n 1 | awk '{print $2}' | tr -d ' ')
86+
[[ "${nev}" == "" ]] && nev=100
87+
echo ${nev}
88+
}
7989

8090
exec_test()
8191
{
@@ -89,12 +99,14 @@ exec_test()
8999
local RET=0
90100
# this is how our test script is expected to be called
91101
local test_script=$(get_test_script_path_for_ini ${ini_path})
102+
# get the number of events to be simulated from the ini file
103+
local nev=$(get_nevents_from_ini ${ini_path})
92104
# prepare the header of the log files
93105
echo "### Testing ${ini_path} with generator ${generator} ###" > ${LOG_FILE_KINE}
94106
echo "### Testing ${ini_path} with generator ${generator} ###" > ${LOG_FILE_GENERIC_KINE}
95107
echo "### Testing ${ini_path} with generator ${generator} ###" > ${LOG_FILE_SIM}
96108
# run the simulation, fail if not successful
97-
o2-sim -g ${generator_lower} ${trigger} --noGeant -n 100 -j 4 --configFile ${ini_path} --configKeyValues "GeneratorPythia8.includePartonEvent=true" >> ${LOG_FILE_SIM} 2>&1
109+
o2-sim -g ${generator_lower} ${trigger} --noGeant -n ${nev} -j 4 --configFile ${ini_path} --configKeyValues "GeneratorPythia8.includePartonEvent=true" >> ${LOG_FILE_SIM} 2>&1
98110
RET=${?}
99111
[[ "${RET}" != "0" ]] && { remove_artifacts ; return ${RET} ; }
100112

@@ -161,11 +173,8 @@ add_ini_files_from_macros()
161173
# given a list of macros, collect all INI files which contain at least one of them
162174
local macro_files=$@
163175
for mf in ${macro_files} ; do
164-
# Strip anything before MC/config/, if any, to get the macro relative path
165-
if [[ "${mf}" == *"MC/config"* ]] ; then
166-
mf=${mf#*MC/config/}
167-
mf="MC/config/${mf}"
168-
fi
176+
# if any, strip the leading O2DPG_ROOT path to only grep for the relative trailing path
177+
mf=${mf##${O2DPG_ROOT}/}
169178
local other_ini_files=$(grep -r -l ${mf} | grep ".ini$")
170179
# so this macro is not included in any of the INI file,
171180
# maybe it is included by another macro which is then included in an INI file

0 commit comments

Comments
 (0)