-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_all.sh
executable file
·238 lines (197 loc) · 5.71 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
# Copyright 2019-2022 ETH Zurich and the DaCe authors. All rights reserved.
set -a
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
PYTHONPATH=$SCRIPTPATH
DACE_debugprint="${DACE_debugprint:-0}"
DACE_testing_serialization="${DACE_testing_serialization:-1}"
DACE_cache="${DACE_cache:-single}"
DACE_optimizer_interface="${DACE_optimizer_interface:-dace.transformation.optimizer.SDFGOptimizer}"
DACE_optimizer_transform_on_call="${DACE_optimizer_transform_on_call:-1}"
NOSTATUSBAR="${NOSTATUSBAR:-0}"
ERRORS=0
FAILED_TESTS=""
SKIPS=0
SKIPPED_TESTS=""
TESTS=0
CURTEST=""
TESTPREFIX=""
TOTAL_TESTS=0
PYTHON_BINARY="${PYTHON_BINARY:-python3}"
TEST_TIMEOUT=10
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m'
TGAP=" "
join_by_newline() {
for a in $*; do
echo $a
done
echo 9999
}
bail() {
ERRORSTR="$TESTPREFIX$1"
/bin/echo -e "${RED}ERROR${NC} in $ERRORSTR" 1>&2
ERRORS=`expr $ERRORS + 1`
FAILED_TESTS="${FAILED_TESTS} $ERRORSTR\n"
}
bail_skip() {
ERRORSTR="$TESTPREFIX$1"
/bin/echo -e "${YELLOW}SKIPPING${NC} $ERRORSTR" 1>&2
SKIPS=`expr $SKIPS + 1`
SKIPPED_TESTS="${SKIPPED_TESTS} $ERRORSTR\n"
}
test_start() {
TESTS=`expr $TESTS + 1`
CURTEST="$TESTPREFIX$1"
echo "---------- TEST: $TESTPREFIX$1 ----------"
}
testcmd() {
if [ $NOSTATUSBAR -ne 0 ]; then
$*
return
fi
#$* | tee -a test.log
TESTCNT=`expr $TESTS - 1`
MSG="($TESTCNT / $TOTAL_TESTS) $CURTEST (Fails: $ERRORS)"
($* || echo "_TFAIL_ $?") |& awk "BEGIN{printf \"$MSG\r\"} /_TFAIL_/{printf \"$TGAP\r\"; exit \$NF} {printf \"$TGAP\r\"; print; printf \"$MSG\r\";} END{printf \"$TGAP\r\"}"
}
################################################
runtest_cpp() {
test_start $1
testcmd g++ -std=c++14 -Wall -Wextra -O3 -march=native -ffast-math -fopenmp -fPIC \
-I $SCRIPTPATH/dace/runtime/include $1 -o ./$1.out
if [ $? -ne 0 ]; then bail "$1 (compilation)"; fi
testcmd ./$1.out
retval=$?
rm -f $1.out
if [ $retval -ne 0 ]; then bail $1; fi
}
runtest_cu() {
test_start $1
testcmd nvcc -O3 -I $SCRIPTPATH/dace/runtime/include $1 -o ./$1.out
if [ $? -ne 0 ]; then bail "$1 (compilation)"; fi
# Check if GPU tests can be run
nvidia-smi >/dev/null 2>&1
if [ $? -ne 0 ]; then bail_skip $1; return; fi
testcmd ./$1.out
retval=$?
rm -f $1.out
if [ $? -ne 0 ]; then bail $1; fi
}
runtest_octave() {
test_start $1
testcmd $PYTHON_BINARY $SCRIPTPATH/dace/frontend/octave/dacelab.py $1
if [ $? -ne 0 ]; then bail $1; fi
}
runtest_py() {
test_start $1
yes | testcmd $PYTHON_BINARY $1
if [ $? -ne 0 ]; then bail $1; fi
}
runtest_sh() {
test_start $1
testcmd ./$1
retval=$?
if [ $retval -eq 99 ]; then bail_skip $1; return; fi
if [ $retval -ne 0 ]; then bail $1; fi
}
endreport() {
PASSED=`expr $TESTS - $ERRORS - $SKIPS`
TOTAL=`expr $TESTS - $SKIPS`
echo "$PASSED / $TOTAL tests passed"
if [ $SKIPS -ne 0 ]; then
printf "Skipped tests:\n${SKIPPED_TESTS}"
fi
if [ $ERRORS -ne 0 ]; then
printf "Failed tests:\n${FAILED_TESTS}"
exit 1
fi
}
echo "====== All-Inclusive Test Runner ======"
cd $SCRIPTPATH/tests
SUBTESTS=`find . -type d -not -path '*/\.*' | cut -c3- | grep -v "/[._]" | grep -v '^[._]'`
DACE_compiler_use_cache=0
DACE_optimizer_detect_control_flow=1
# Specific test(s)
if [ $# -ne 0 ]; then
TOTAL_TESTS=$#
for arg in "$@"; do
if [[ $arg == *_test.cpp ]]; then
runtest_cpp $arg
elif [[ $arg == *_test.cu ]]; then
runtest_cu $arg
elif [[ $arg == *_test.py ]]; then
runtest_py $arg
elif [[ $arg == *.m ]]; then
runtest_octave $arg
elif [[ $arg == *_test.sh ]]; then
runtest_sh $arg
fi
done
endreport
exit 0
fi
# Count tests first
counttests() {
for file in *_test.cpp; do
if [ $file == '*_test.cpp' ]; then break; fi # No files found
TOTAL_TESTS=`expr $TOTAL_TESTS + 1`
done
for file in *_test.cu; do
if [ $file == '*_test.cu' ]; then break; fi # No files found
TOTAL_TESTS=`expr $TOTAL_TESTS + 1`
done
for file in *_test.py; do
if [ $file == '*_test.py' ]; then break; fi # No files found
TOTAL_TESTS=`expr $TOTAL_TESTS + 1`
done
for file in *.m; do
if [ $file == '*.m' ]; then break; fi # No files found
TOTAL_TESTS=`expr $TOTAL_TESTS + 1`
done
for file in *_test.sh; do
if [ $file == '*_test.sh' ]; then break; fi # No files found
TOTAL_TESTS=`expr $TOTAL_TESTS + 1`
done
}
# Count tests in top-level folder
cd $SCRIPTPATH/tests
counttests
# Count sub-tests
for test in $SUBTESTS; do
cd $SCRIPTPATH/tests/$test
counttests
done
################################################################
runtests() {
for file in *_test.cpp; do
if [ $file == '*_test.cpp' ]; then break; fi # No files found
runtest_cpp $file
done
for file in *_test.cu; do
if [ $file == '*_test.cu' ]; then break; fi # No files found
runtest_cu $file
done
for file in *_test.py; do
if [ $file == '*_test.py' ]; then break; fi # No files found
runtest_py $file
done
for file in *.m; do
if [ $file == '*.m' ]; then break; fi # No files found
runtest_octave $file
done
for file in *_test.sh; do
if [ $file == '*_test.sh' ]; then break; fi # No files found
runtest_sh $file
done
}
cd $SCRIPTPATH/tests
TESTPREFIX=""
runtests
for test in $SUBTESTS; do
cd $SCRIPTPATH/tests/$test
TESTPREFIX="$test/"
runtests
done
endreport