Skip to content

Commit d091f7a

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

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

test/run_generator_tests.sh

Lines changed: 15 additions & 1 deletion
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

@@ -162,7 +174,9 @@ add_ini_files_from_macros()
162174
local macro_files=$@
163175
for mf in ${macro_files} ; do
164176
# Strip anything before MC/config/, if any, to get the macro relative path
177+
# if any, strip the leading O2DPG_ROOT path to only grep for the relative trailing path
165178
if [[ "${mf}" == *"MC/config"* ]] ; then
179+
mf=${mf##${O2DPG_ROOT}/}
166180
mf=${mf#*MC/config/}
167181
mf="MC/config/${mf}"
168182
fi

0 commit comments

Comments
 (0)