-
Notifications
You must be signed in to change notification settings - Fork 0
/
testwrapper.sh
executable file
·126 lines (115 loc) · 4.12 KB
/
testwrapper.sh
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
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
# Runs syndicate tests in PATHDIR, puts TAP results in TESTDIR
# Syntax:
# -b <build url> populate tap results with url info
# -c callgrind on all tests
# -d run with python debugger
# -i interactively ask which test to run
# -n <test number> run the test number specified
# -m memcheck / valgrind on all tests
# -o run with operf profiler
# -v enable verbose testrunner debug logs
buildurl=''
if [[ $@ =~ -b ]]; then
buildurl=`echo $@ | sed -e 's/^.*-b //g' | awk '{ print "-b " $1 }'`
fi
debug=''
if [[ $@ =~ -d ]]; then
debug='-m pdb'
fi
verbosedebug=''
if [[ $@ =~ -v ]]; then
verbosedebug='-d'
fi
testnumber=0
if [[ $@ =~ -n ]]; then
testnumber=`echo $@ | sed -e 's/^.*-n//g' -e 's/^ *0*//g' | xargs printf "%03d"`
fi
# bring in config (in the same directory as this script)
source "${BASH_SOURCE%/*}/config.sh"
# Start testing
echo "Start Time: `date +'%F %T'`"
start_t=`date +%s`
echo "Working in: '`pwd`'"
# remove old results
rm -f ${RESULTDIR}/*.tap
# run the tests
if [ $testnumber -eq 0 ]; then
for test in $(ls ${TESTDIR}/*.yml); do
testname=${test##*/}
runtest=1
if [[ $@ =~ -i ]]; then
runtest=0
read -p "Run ${testname}? (y/n): " run
if [[ $run =~ [Yy] ]]; then
runtest=1
fi
fi
if [ $runtest == 1 ]; then
if [[ -n `cat $test | grep "debug:.*disable"` ]]; then
echo "Skipping test: '${testname}' (disabled)"
else
printf "Running test: '${testname}'"
if [[ $@ =~ -c ]]; then
valgrindcmd="-c ${OUTPUTDIR}/${testname%.*}.callgrind"
echo " (Callgrind)"
python $debug ${CONFIG_ROOT}/testrunner.py $valgrindcmd -t /tmp/${testname%.*}.tap ${test} /tmp/${testname%.*}.out
rm /tmp/${testname%.*}.tap /tmp/${testname%.*}.out*
printf " : '${testname}'"
fi
valgrindcmd=''
if [[ $@ =~ -m ]]; then
valgrindcmd="-m ${OUTPUTDIR}/${testname%.*}.valgrind"
echo " (Memcheck)"
else
echo ""
fi
python $debug ${CONFIG_ROOT}/testrunner.py $verbosedebug $valgrindcmd $buildurl -t ${RESULTDIR}/${testname%.*}.tap ${test} ${OUTPUTDIR}/${testname%.*}.out
if [[ $@ =~ -o ]]; then
operfcmd="-o ${OUTPUTDIR}/${testname%.*}.operf"
echo " : '${testname}' (operf)"
python $debug ${CONFIG_ROOT}/testrunner.py $operfcmd -t /tmp/${testname%.*}.tap ${test} /tmp/${testname%.*}.out
rm /tmp/${testname%.*}.tap /tmp/${testname%.*}.out*
fi
fi
fi
done
else
test=`find ${TESTDIR} -name "*${testnumber}_*.yml" | grep -v notsupported`
testname=${test##*/}
printf "Running test: '${testname}'"
if [[ $@ =~ -c ]]; then
valgrindcmd="-c ${OUTPUTDIR}/${testname%.*}.callgrind"
echo " (Callgrind)"
python ${CONFIG_ROOT}/testrunner.py $valgrindcmd -t /tmp/${testname%.*}.tap ${test} /tmp/${testname%.*}.out
rm /tmp/${testname%.*}.tap /tmp/${testname%.*}.out*
printf " : '${testname}'"
fi
valgrindcmd=''
if [[ $@ =~ -m ]]; then
valgrindcmd="-m ${OUTPUTDIR}/${testname%.*}.valgrind"
echo " (Memcheck)"
else
echo ""
fi
python $debug ${CONFIG_ROOT}/testrunner.py $verbosedebug $valgrindcmd -t ${RESULTDIR}/${testname%.*}.tap ${test} ${OUTPUTDIR}/${testname%.*}.out
if [ -n "`ls /tmp/*.cglist 2>/dev/null`" ]; then
rm /tmp/*.cglist
fi
if [[ $@ =~ -o ]]; then
operfcmd="-o ${OUTPUTDIR}/${testname%.*}.operf"
echo " : '${testname}' (operf)"
python $debug ${CONFIG_ROOT}/testrunner.py $verbosedebug $operfcmd -t /tmp/${testname%.*}.tap ${test} /tmp/${testname%.*}.out
rm /tmp/${testname%.*}.tap /tmp/${testname%.*}.out*
fi
fi
echo "Copying logs..."
cp -r /tmp/synd-* $OUTPUTDIR
# change permissions.
# ${OUTPUTDIR} and ${OUTPUTDIR}/.gitignore are owned by the host account thus shouldn't be modified.
chmod -R a+rwx ${OUTPUTDIR}/*.out
chmod -R a+rwx ${OUTPUTDIR}/[0-9][0-9][0-9]_*
chmod -R a+rwx ${OUTPUTDIR}/synd-*
echo "End Time: `date +'%F %T'`"
end_t=`date +%s`
echo "Elapsed Time: $((${end_t} - ${start_t}))s"