-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests
executable file
·117 lines (100 loc) · 2.34 KB
/
run_tests
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#! /bin/sh
#
# Helper script to run tests and generate a test report
#
usage()
{
cat <<EOF
run_tests: [-r RUNNER] [-vx]
v verbose output (default=no)
k keep going, ignore errors (default=no)
x XML output (default=no)
r RUNNER runner shell script for non-native targets (default=none)
EOF
}
toggle()
{
case $1 in
no) echo "yes" ;;
yes) echo "no" ;;
*) fatal "Unknown value to toggle ($1)" ;;
esac
}
vecho()
{
if [ ${verbose} = "yes" ] ; then
echo "$*"
fi
}
verbose=no
keep_going=no
xml=no
runner=
while getopts "kr:vx" OPT
do
case "$OPT" in
r) runner=${OPTARG} ;;
k) keep_going=`toggle ${keep_going}` ;;
v) verbose=`toggle ${verbose}` ;;
x) xml=`toggle ${xml}` ;;
*) usage; exit 1;
esac
done
shiftcount=`expr $OPTIND - 1`
shift $shiftcount
UNITTESTS="$*"
if [ "X${runner}" != "X" ] ; then
runner=`realpath ${runner}`
fi
STARTPWD=`pwd`
RESULTFILE="$STARTPWD/report.xml"
for unittest in ${UNITTESTS}
do
cd ${STARTPWD}
dir=`dirname ${unittest}`
base=`basename ${unittest}`
echo Running ${unittest}
cd ${dir}
if [ -r test_prep_cleanup.sh ] ; then
./test_prep_cleanup.sh prepare
if [ $? -ne 0 ] ; then
echo $base
fi
fi
if [ ${xml} = "yes" ] ; then
echo ${dir} | grep "RRADE_tests/T" 2>&1 > /dev/null
RRADE_TESTS=$?
echo ${base} | egrep "_FCT$|TypeAbstraction_Memory$" 2>&1 > /dev/null
RRADE_TESTS_EXCEPTIONS=$?
if [ "$RRADE_TESTS_EXCEPTIONS" = "0" ]; then
${runner} ./${base} -l junit >> "$STARTPWD/$base-result.xml"
elif [ "$RRADE_TESTS" = "0" ]; then
${runner} ./${base} -ojunit >> "$STARTPWD/$base-result.xml"
else
${runner} ./${base} -l junit >> "$STARTPWD/$base-result.xml"
fi
RETURN_CODE=$?
# check for bad test run
egrep "0/0 tests|usage.*testName.*junit" $STARTPWD/$base-result.xml 2>&1 > /dev/null
if [ "$?" = "0" ]; then
echo "Test ${unittest} produced bad test output (no tests run)"
exit 1;
fi
else
${runner} ./${base}
RETURN_CODE=$?
fi
if [ $RETURN_CODE -ne 0 ] ; then
echo Test ${base} failed:
if [ ${xml} = "yes" ] ; then
cat "$STARTPWD/$base-result.xml"
fi
if [ ${keep_going} = "no" ]; then
exit 1;
fi
fi
if [ -r test_prep_cleanup.sh ] ; then
./test_prep_cleanup.sh cleanup
fi
done
exit 0