diff --git a/scripts/compareRootFiles.cpp b/scripts/compareRootFiles.cpp index 1c076d5ebeb3ee12c91c8221ec043b1e3950dd72..2747c142d201c46ba6de19b16a0e9226c7a9a3dc 100644 --- a/scripts/compareRootFiles.cpp +++ b/scripts/compareRootFiles.cpp @@ -212,6 +212,11 @@ int compareRootFiles(std::string file1, std::string file2, " ~ Number of entries does not match!"); } + if(t1EntryCount == 0) { + std::cout << " o Skipping empty tree!" << std::endl; + continue; + } + std::cout << " o Preparing for tree readout..." << std::endl; TTreeReader t1Reader(tree1); TTreeReader t2Reader(tree2); diff --git a/scripts/testReproducibility.sh b/scripts/testReproducibility.sh index a846f4600cf8887f05d8a4f12666688fdadbfc2c..d14e37fe2a5457dfc71375b7dc133814447dff98 100755 --- a/scripts/testReproducibility.sh +++ b/scripts/testReproducibility.sh @@ -10,43 +10,68 @@ set -uo pipefail # Check whether the user did specify the name of the example to be run ARGC=$# -if [[ $ARGC -lt 1 ]]; then - echo "Usage: "$0" <name of example>" - exit +if [[ $ARGC -lt 2 ]]; then + echo "" + echo " Usage: "$0" <example> <output1> [<output2> ...]" + echo "" + echo " <example> is the example name (which is the executable name without the leading 'ACTFW' and the trailing 'Example')" + echo " <outputN> is the output name (which is the output file name without the trailing 'Test.root')" + echo "" + exit 42 fi -# Compute the name of the example executable and its output file +# Compute the name of the example executable executable=ACTFW$1Example -output=$1Test.root -# Drop any stale result from previous runs of the example -rm -f $output +# Compute the output file names +for ((i = 2; i <= $ARGC; i++)); do + eval output=\$${i}Test.root + eval outputs[$i]=$output +done -# Run the example in multi-threaded mode, back up the results +# Drop any remaining output file from previous runs of the example +for output in "${outputs[@]}"; do + rm -f $output ST$output MT$output +done + +# Run the example in multi-threaded mode eval "$executable" result=$? if [[ result -ne 0 ]]; then echo "Multi-threaded run failed!" - exit result + exit $result fi -mt_output=MT$output -mv $output $mt_output -# Run the example in single-threaded mode, back up the results +# Back up the multi-threaded results +for output in "${outputs[@]}"; do + mv $output MT$output +done + +# Run the example in single-threaded mode eval "OMP_NUM_THREADS=1 $executable" result=$? if [[ result -ne 0 ]]; then echo "Single-threaded run failed!" - exit result + exit $result fi -st_output=ST$output -mv $output $st_output -# Check whether the results were identical (up to thread-induced event reordering) -cmd="root -b -q -l -x -e '.x compareRootFiles.cpp(\"$st_output\", \"$mt_output\")'" -eval $cmd -result=$? +# Back up the single-threaded results +for output in "${outputs[@]}"; do + mv $output ST$output +done + +# Check whether the results were identical (up to thread-induced reordering) +for output in "${outputs[@]}"; do + # Compare the active results files + cmd="root -b -q -l -x -e '.x compareRootFiles.cpp(\"ST$output\", \"MT$output\")'" + eval $cmd + result=$? + + # If the results were different, abort and return the output status code + if [[ result -ne 0 ]]; then + exit $result + fi -# Clean up, and return 0 if the results were identical -rm -f $mt_output $st_output -exit $result + # Otherwise clean up and continue + rm ST$output MT$output +done