-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_all.sh
155 lines (117 loc) · 3.52 KB
/
test_all.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/sh
set -u
if [ -z "$HIMAN" ]; then
if [ "$1" = "release" ]; then
export HIMAN=$(pwd)/../himan-bin/build/release/himan
else
export HIMAN=$(pwd)/../himan-bin/build/debug/himan
fi
fi
root=$PWD
. $root/bin/database-config.sh
LOGDIR=/tmp/$(id -un)
mkdir -p $LOGDIR
txtund=$(tput sgr 0 1) # Underline
txtbld=$(tput bold) # Bold
txtred=$(tput setaf 1) # Red
txtgrn=$(tput setaf 2) # Green
txtylw=$(tput setaf 3) # Yellow
txtblu=$(tput setaf 4) # Blue
txtpur=$(tput setaf 5) # Purple
txtcyn=$(tput setaf 6) # Cyan
txtwht=$(tput setaf 7) # White
txtrst=$(tput sgr0) # Text reset
function cleanup(){
rm -rf $LOGDIR
$root/bin/stop-radon-database.sh
}
function find_and_execute(){
echo "Running $1"
cd $root/$1
failed=0
succeeded=0
failed_tests=""
for f in $(find . -maxdepth 2 -type f -name "*.sh" -print | sort); do
dbase=$(dirname $f)
sbase=$(basename $f)
cd $root/$1/$dbase
LOGFILE="$LOGDIR/$sbase.log"
printf "%-20s %-25s %-50s " \
$dbase \
$sbase \
" (log: $LOGFILE)"
RESULT=""
starttime=$(date +%s%N)
sh $sbase > $LOGFILE 2>&1
ret=$?
stoptime=$(date +%s%N)
duration=$((($stoptime - $starttime) / 1000000))
if [ $ret -ne 0 ]; then
RESULT="[${txtred}FAILED${txtrst}]"
else
RESULT="[${txtgrn}SUCCESS${txtrst}]"
fi
printf "%-25s duration: ${duration}ms\n" $RESULT
if [ $ret -ne 0 ]; then
cat $LOGFILE
failed=$((1+$failed))
failed_tests="$failed_tests $f"
else
succeeded=$((1+$succeeded))
fi
rm -f $LOGFILE
done
total=$((failed+$succeeded))
prcnt=$((100*$succeeded/$total))
echo "summary: $succeeded/$total tests succeeded ($prcnt %)"
if [ $failed -ne 0 ]; then
echo "failed tests were:"
for f in $failed_tests; do
echo " * $f"
done
cleanup
exit 1
fi
cd $root
}
echo "Using himan executable from: $HIMAN"
echo "==============================================================="
sh $root/bin/check-for-gpu.sh
echo "==============================================================="
if [ $# -eq 1 ]; then
if [ "$1" != "smoke-tests" ] && [ "$1" != "unit-tests" ] && [ "$1" != "integration-tests" ] && [ "$1" != "functional-tests" ] && [ "$1" != "performance-tests" ]; then
echo "usage: $0 [ smoke-tests unit-tests integration-tests functional-tests performance-tests ]"
exit 1
fi
if [ "$1" = "unit-tests" ] || [ "$1" = "performance-tests" ] ; then
echo "Building $1"
sh $root/$1/makesh > /dev/null
fi
if [ "$1" = "integration-tests" ] || [ "$1" = "functional-tests" ]; then
set -e
$root/bin/stop-radon-database.sh
$root/bin/start-radon-database.sh
set +e
fi
find_and_execute $1
else
find_and_execute smoke-tests
echo "Building unit-tests"
sh $root/unit-tests/makesh > /dev/null
find_and_execute unit-tests
set -e
$root/bin/stop-radon-database.sh
$root/bin/start-radon-database.sh
set +e
if [ $? -ne 0 ]; then
exit 1
fi
find_and_execute integration-tests
find_and_execute functional-tests
echo "Performance tests are disabled"
# echo "Building performance-tests"
# sh $root/performance-tests/makesh > /dev/null
# find_and_execute performance-tests
fi
cleanup
echo "All clear -- hurraah!"