forked from acts-project/acts
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtestReproducibility.sh
More file actions
executable file
·79 lines (68 loc) · 2.16 KB
/
testReproducibility.sh
File metadata and controls
executable file
·79 lines (68 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
#
# This script tests whether the output of a certain ACTS framework example is
# reproducible between single-threaded and multi-threaded runs. For example,
# "./testReproducibility.sh ActsExampleFatrasGeneric" will run the
# ActsExampleFatrasGeneric in single-threaded and multi-threaded mode and
# check whether the output is the same aside from threading-induced event reordering.
#
set -uo pipefail
# Check whether the user did specify the name of the example to be run
ARGC=$#
if [[ $ARGC -lt 2 ]]; then
echo ""
echo " Usage: "$0" <example> <flags> <output1> [<output2> ...]"
echo ""
echo " <example> is the executable name (e.g. ActsExampleFatrasGeneric)"
echo " <flags> is a string containing CLI flags (e.g. \"-n 5\")"
echo " <outputN> is the output name (which is the output file name without the trailing '.root')"
echo ""
exit 42
fi
# Compute the name of the example executable
executable="$1 $2 --output-root true"
echo ${executable}
# Compute the output file names
for ((i = 3; i <= $ARGC; i++)); do
eval output=\$${i}.root
eval outputs[$i]=$output
done
# 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
fi
# Back up the multi-threaded results
for output in "${outputs[@]}"; do
mv $output MT$output
done
# Run the example in single-threaded mode
eval "${executable} -j 1"
result=$?
if [[ result -ne 0 ]]; then
echo "Single-threaded run failed!"
exit $result
fi
# 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.C(\"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
# Otherwise clean up and continue
rm ST$output MT$output
done