Debian Codegraph @

libstdc++-v3/testsuite/experimental/simd/driver.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 type=float
4 abi=0
5 name=
6 srcdir="$(cd "${0%/*}" && pwdscip-shell system . . pwd.)/tests"
7 sim="$GCC_TEST_SIMULATOR"
8
9 # output_mode values:
10 # print only failures with minimal context
11 readonly really_quiet=0
12 # as above plus same-line output of last successful test
13 readonly same_line=1
14 # as above plus percentage
15 readonly percentage=2
16 # print one line per finished test with minimal context on failure
17 readonly verbose=3
18 # print one line per finished test with full output of the compiler and test
19 readonly really_verbose=4
20
21 output_mode=$really_quiet
22 [scip-shell system . . `[`. -t 1 ] && output_mode=$same_line
23
24 timeout=180
25 run_expensive=false
26 if [scip-shell system . . `[`. -n "$GCC_TEST_RUN_EXPENSIVE" ]; then
27 run_expensive=true
28 fi
29 keep_failed=false
30 only=
31
32 usagescip-shell shell shell-project 0.0.0 usage().() {
33 catscip-shell system . . cat. <<EOF
34 Usage: $0 [Options] <g++ invocation>
35
36 Options:
37 -h, --help Print this message and exit.
38 -q, --quiet Disable same-line progress output (default if stdout is
39 not a tty).
40 -p, --percentage Add percentage to default same-line progress output.
41 -v, --verbose Print one line per test and minimal extra information on
42 failure.
43 -vv Print all compiler and test output.
44 -t <type>, --type <type>
45 The value_type to test (default: $type).
46 -a [0-9], --abi [0-9]
47 The ABI tag subset to test (default: $abi).
48 -n <name>, --name <name>
49 The name of the test (required).
50 -k, --keep-failed Keep executables of failed tests.
51 --srcdir <path> The source directory of the tests (default: $srcdir).
52 --sim <executable> Path to an executable that is prepended to the test
53 execution binary (default: the value of
54 GCC_TEST_SIMULATOR).
55 --timeout-factor <x>
56 Multiply the default timeout with x.
57 -x, --run-expensive Compile and run tests marked as expensive (default:
58 true if GCC_TEST_RUN_EXPENSIVE is set, false otherwise).
59 -o <pattern>, --only <pattern>
60 Compile and run only tests matching the given pattern.
61 EOF
62 }
63
64 while [scip-shell system . . `[`. $# -gt 0 ]; do
65 case "$1" in
66 -h|--help)
67 usagescip-shell shell shell-project 0.0.0 usage().
68 exit
69 ;;
70 -q|--quiet)
71 output_mode=$really_quiet
72 ;;
73 -p|--percentage)
74 output_mode=$percentage
75 ;;
76 -v|--verbose)
77 if [scip-shell system . . `[`. $output_mode -lt $verbose ]; then
78 output_mode=$verbose
79 else
80 output_mode=$really_verbose
81 fi
82 ;;
83 -x|--run-expensive)
84 run_expensive=true
85 ;;
86 -k|--keep-failed)
87 keep_failed=true
88 ;;
89 -o|--only)
90 only="$2"
91 shift
92 ;;
93 -t|--type)
94 type="$2"
95 shift
96 ;;
97 -a|--abi)
98 abi="$2"
99 shift
100 ;;
101 -n|--name)
102 name="$2"
103 shift
104 ;;
105 --srcdir)
106 srcdir="$2"
107 shift
108 ;;
109 --sim)
110 sim="$2"
111 shift
112 ;;
113 --timeout-factor)
114 timeout=$(awkscip-shell system . . awk. "BEGIN { print int($timeout * $2) }")
115 shift
116 ;;
117 --)
118 shift
119 break
120 ;;
121 --*=*)
122 opt="$1"
123 shift
124 value=${opt#*=}
125 set -- ${opt%=$value} "$value" ${1+"$@"}
126 continue
127 ;;
128 -[ahknopqtvx][ahknopqtvx]*)
129 opt="$1"
130 shift
131 next=${opt#??}
132 set -- ${opt%$next} "-$next" ${1+"$@"}
133 continue
134 ;;
135 -*)
136 echoscip-shell system . . echo. "Error: Unrecognized option '$1'" >&2
137 exit 1
138 ;;
139 *)
140 break
141 ;;
142 esac
143 shift
144 done
145
146 if [scip-shell system . . `[`. $output_mode = $percentage ]; then
147 inc_progressscip-shell shell shell-project 0.0.0 inc_progress().() {
148 {
149 flockscip-shell system . . flock. -n 9
150 n=$(($(catscip-shell system . . cat. .progress) + 1))
151 echoscip-shell system . . echo. $n >&9
152 echoscip-shell system . . echo. $n
153 } 9<>.progress
154 }
155 fi
156
157 CXX="$1"
158 shift
159 CXXFLAGS="$@"
160 src="${srcdir}/${name}.cc"
161 shorttype=$(echoscip-shell system . . echo. $type|sedscip-shell system . . sed. -e 's/long /l/' -e 's/unsigned /u/' -e 's/signed /s/')
162 testname="${name}-${shorttype}-${abi}"
163 exe="${testname}.exe"
164 log="${testname}.log"
165 sum="${testname}.sum"
166 if [scip-shell system . . `[`. -n "$only" ]; then
167 if echoscip-shell system . . echo. "$testname"|awkscip-shell system . . awk. "{ exit /$only/ }"; then
168 touchscip-shell system . . touch. "$log" "$sum"
169 [scip-shell system . . `[`. $output_mode = $percentage ] && inc_progressscip-shell shell shell-project 0.0.0 inc_progress(). >/dev/nullscip-shell filesystem . . `/dev/null`.
170 exit 0
171 fi
172 fi
173
174 if [scip-shell system . . `[`. $abi -eq 0 ]; then
175 abiflag=""
176 elif [scip-shell system . . `[`. $abi -gt 0 -a $abi -lt 10 ]; then
177 abiflag="-DEXTENDEDTESTS=$((abi-1))"
178 else
179 echoscip-shell system . . echo. "Error: The -a argument must be a value between 0 and 9 (inclusive)." >&2
180 exit 1
181 fi
182
183 if [scip-shell system . . `[`. $output_mode = $percentage ]; then
184 show_progressscip-shell shell shell-project 0.0.0 show_progress().() {
185 n=$(inc_progressscip-shell shell shell-project 0.0.0 inc_progress().)
186 read total < .progress_total
187 total=${total}0
188 priscip-shell system . . printf.ntfscip-shell system . . printf. "\e[1G\e[K[%3d %%] ${src##*/} $type $abiflag" \
189 $((n * 1005 / total))
190 }
191 trap 'show_progress' EXIT
192 prefix="\e[1G\e[K"
193 elif [scip-shell system . . `[`. $output_mode = $same_line ]; then
194 show_progressscip-shell shell shell-project 0.0.0 show_progress().() {
195 printfscip-shell system . . printf. "\e[1G\e[K${src##*/} $type $abiflag"
196 }
197 trap 'show_progress' EXIT
198 prefix="\e[1G\e[K"
199 else
200 prefix=""
201 fi
202
203 failscip-shell shell shell-project 0.0.0 fail().() {
204 printfscip-shell system . . printf. "$prefix"
205 echoscip-shell system . . echo. "FAIL: $src $type $abiflag ($*)" | teescip-shell system . . tee. -a "$sum" "$log"
206 }
207
208 xpassscip-shell shell shell-project 0.0.0 xpass().() {
209 printfscip-shell system . . printf. "$prefix"
210 echoscip-shell system . . echo. "XPASS: $src $type $abiflag ($*)" | teescip-shell system . . tee. -a "$sum" "$log"
211 }
212
213 xfailscip-shell shell shell-project 0.0.0 xfail().() {
214 [scip-shell system . . `[`. $output_mode -ge $verbose ] && echoscip-shell system . . echo. "XFAIL: $src $type $abiflag ($*)"
215 echoscip-shell system . . echo. "XFAIL: $src $type $abiflag ($*)" >> "$sum"
216 echoscip-shell system . . echo. "XFAIL: $src $type $abiflag ($*)" >> "$log"
217 }
218
219 passscip-shell shell shell-project 0.0.0 pass().() {
220 [scip-shell system . . `[`. $output_mode -ge $verbose ] && echoscip-shell system . . echo. "PASS: $src $type $abiflag ($*)"
221 echoscip-shell system . . echo. "PASS: $src $type $abiflag ($*)" >> "$sum"
222 echoscip-shell system . . echo. "PASS: $src $type $abiflag ($*)" >> "$log"
223 }
224
225 unsupportedscip-shell shell shell-project 0.0.0 unsupported().() {
226 testscip-shell system . . test.
227 [scip-shell system . . `[`. $output_mode -ge $verbose ] && echoscip-shell system . . echo. "UNSUPPORTED: $src $type $abiflag ($*)"
228 echoscip-shell system . . echo. "UNSUPPORTED: $src $type $abiflag ($*)" >> "$sum"
229 echoscip-shell system . . echo. "UNSUPPORTED: $src $type $abiflag ($*)" >> "$log"
230 }
231
232 write_log_and_verbosescip-shell shell shell-project 0.0.0 write_log_and_verbose().() {
233 echoscip-shell system . . echo. "$*" >> "$log"
234 if [scip-shell system . . `[`. $output_mode = $really_verbose ]; then
235 if [scip-shell system . . `[`. -z "$COLUMNS" ] || ! type fmt>/dev/nullscip-shell filesystem . . `/dev/null`.; then
236 echoscip-shell system . . echo. "$*"
237 else
238 echoscip-shell system . . echo. "$*" | fmtscip-shell system . . fmt. -w $COLUMNS -s - || catscip-shell system . . cat.
239 fi
240 fi
241 }
242
243 matchesscip-shell shell shell-project 0.0.0 matches().() {
244 eval "case '$1' in
245 $2) return 0;; esac"
246 return 1
247 }
248
249 test_selectorscip-shell shell shell-project 0.0.0 test_selector().() {
250 string="$1"
251 pat_type="${string%% *}"
252 if matchesscip-shell shell shell-project 0.0.0 matches(). "$shorttype" "$pat_type"; then
253 string="${string#* }"
254 pat_abi="${string%% *}"
255 if matchesscip-shell shell shell-project 0.0.0 matches(). "$abi" "$pat_abi"; then
256 string="${string#* }"
257 pat_triplet="${string%% *}"
258 [scip-shell system . . `[`. -z "$target_triplet" ] && target_triplet=$($CXX -dumpmachine)
259 if matchesscip-shell shell shell-project 0.0.0 matches(). "$target_triplet" "$pat_triplet"; then
260 pat_flags="${string#* }"
261 if matchesscip-shell shell shell-project 0.0.0 matches(). "$CXXFLAGS" "*$pat_flags*"; then
262 return 0
263 fi
264 fi
265 fi
266 fi
267 return 1
268 }
269
270 trap "rm -f '$log' '$sum' $exe; exit" INT
271 rmscip-shell system . . rm. -f "$log" "$sum"
272 touchscip-shell system . . touch. "$log" "$sum"
273
274 read_src_optionscip-shell shell shell-project 0.0.0 read_src_option().() {
275 local key tmp var
276 key="$1"
277 var="$2"
278 [scip-shell system . . `[`. -z "$var" ] && var="$1"
279 local tmp="$(headscip-shell system . . head. -n25 "$src" | grepscip-shell system . . grep. "^//\\s*${key}: ")"
280 if [scip-shell system . . `[`. -n "$tmp" ]; then
281 tmp="$(echoscip-shell system . . echo. "${tmp#//*${key}: }" | sedscip-shell system . . sed. -e 's/ \+/ /g' -e 's/^ //' -e 's/$//')"
282 eval "$var=\"$tmp\""
283 else
284 return 1
285 fi
286 }
287
288 if read_src_optionscip-shell shell shell-project 0.0.0 read_src_option(). skip; then
289 if test_selectorscip-shell shell shell-project 0.0.0 test_selector(). "$skip"; then
290 # silently skip this test
291 exit 0
292 fi
293 fi
294 if read_src_optionscip-shell shell shell-project 0.0.0 read_src_option(). only; then
295 if ! test_selectorscip-shell shell shell-project 0.0.0 test_selector(). "$only"; then
296 # silently skip this test
297 exit 0
298 fi
299 fi
300
301 if ! $run_expensive; then
302 if read_src_optionscip-shell shell shell-project 0.0.0 read_src_option(). expensive; then
303 if test_selectorscip-shell shell shell-project 0.0.0 test_selector(). "$expensive"; then
304 unsupportedscip-shell shell shell-project 0.0.0 unsupported(). "skip expensive tests"
305 exit 0
306 fi
307 fi
308 fi
309
310 if read_src_optionscip-shell shell shell-project 0.0.0 read_src_option(). xfail; then
311 if test_selectorscip-shell shell shell-project 0.0.0 test_selector(). "${xfail#* }"; then
312 xfail="${xfail%% *}"
313 else
314 unset xfail
315 fi
316 fi
317
318 read_src_optionscip-shell shell shell-project 0.0.0 read_src_option(). timeout
319
320 if read_src_optionscip-shell shell shell-project 0.0.0 read_src_option(). timeout-factor factor; then
321 timeout=$(awkscip-shell system . . awk. "BEGIN { print int($timeout * $factor) }")
322 fi
323
324 log_outputscip-shell shell shell-project 0.0.0 log_output().() {
325 if [scip-shell system . . `[`. $output_mode = $really_verbose ]; then
326 maxcol=${1:-1024}
327 awkscip-shell system . . awk. "
328 BEGIN { count = 0 }
329 /^###exitstatus### [0-9]+$/ { exit \$2 }
330 {
331 print >> \"$log\"
332 if (count >= 1000) {
333 print \"Aborting: too much output\" >> \"$log\"
334 print \"Aborting: too much output\"
335 exit 125
336 }
337 ++count
338 if (length(\$0) > $maxcol) {
339 i = 1
340 while (i + $maxcol <= length(\$0)) {
341 len = $maxcol
342 line = substr(\$0, i, len)
343 len = match(line, / [^ ]*$/)
344 if (len <= 0) {
345 len = match(substr(\$0, i), / [^ ]/)
346 if (len <= 0) len = $maxcol
347 }
348 print substr(\$0, i, len)
349 i += len
350 }
351 print substr(\$0, i)
352 } else {
353 print
354 }
355 }
356 END { close(\"$log\") }
357 "
358 else
359 awkscip-shell system . . awk. "
360 BEGIN { count = 0 }
361 /^###exitstatus### [0-9]+$/ { exit \$2 }
362 {
363 print >> \"$log\"
364 if (count >= 1000) {
365 print \"Aborting: too much output\" >> \"$log\"
366 print \"Aborting: too much output\"
367 exit 125
368 }
369 ++count
370 }
371 END { close(\"$log\") }
372 "
373 fi
374 }
375
376 verify_compilationscip-shell shell shell-project 0.0.0 verify_compilation().() {
377 log_outputscip-shell shell shell-project 0.0.0 log_output(). $COLUMNS
378 exitstatus=$?
379 if [scip-shell system . . `[`. $exitstatus -eq 0 ]; then
380 warnings=$(grepscip-shell system . . grep. -ic 'warning:' "$log")
381 if [scip-shell system . . `[`. $warnings -gt 0 ]; then
382 failscip-shell shell shell-project 0.0.0 fail(). "excess warnings:" $warnings
383 if [scip-shell system . . `[`. $output_mode = $verbose ]; then
384 grepscip-shell system . . grep. -i 'warning:' "$log" | headscip-shell system . . head. -n5
385 fi
386 elif [scip-shell system . . `[`. "$xfail" = "compile" ]; then
387 xpassscip-shell shell shell-project 0.0.0 xpass(). "test for excess errors"
388 else
389 passscip-shell shell shell-project 0.0.0 pass(). "test for excess errors"
390 fi
391 return 0
392 else
393 if [scip-shell system . . `[`. $exitstatus -eq 124 ]; then
394 failscip-shell shell shell-project 0.0.0 fail(). "timeout: test for excess errors"
395 else
396 errors=$(grepscip-shell system . . grep. -ic 'error:' "$log")
397 if [scip-shell system . . `[`. "$xfail" = "compile" ]; then
398 xfailscip-shell shell shell-project 0.0.0 xfail(). "excess errors:" $errors
399 exit 0
400 else
401 failscip-shell shell shell-project 0.0.0 fail(). "excess errors:" $errors
402 fi
403 fi
404 if [scip-shell system . . `[`. $output_mode = $verbose ]; then
405 grepscip-shell system . . grep. -i 'error:' "$log" | headscip-shell system . . head. -n5
406 fi
407 return 1
408 fi
409 }
410
411 verify_testscip-shell shell shell-project 0.0.0 verify_test().() {
412 log_outputscip-shell shell shell-project 0.0.0 log_output(). $COLUMNS
413 exitstatus=$?
414 if [scip-shell system . . `[`. $exitstatus -eq 0 ]; then
415 if [scip-shell system . . `[`. "$xfail" = "run" ]; then
416 $keep_failed || rmscip-shell system . . rm. "$exe"
417 xpassscip-shell shell shell-project 0.0.0 xpass(). "execution test"
418 else
419 rmscip-shell system . . rm. "$exe"
420 passscip-shell shell shell-project 0.0.0 pass(). "execution test"
421 fi
422 return 0
423 else
424 $keep_failed || rmscip-shell system . . rm. "$exe"
425 if [scip-shell system . . `[`. $output_mode = $verbose ]; then
426 grepscip-shell system . . grep. -i fail "$log" | headscip-shell system . . head. -n5
427 fi
428 if [scip-shell system . . `[`. $exitstatus -eq 124 ]; then
429 failscip-shell shell shell-project 0.0.0 fail(). "timeout: execution test"
430 elif [scip-shell system . . `[`. "$xfail" = "run" ]; then
431 xfailscip-shell shell shell-project 0.0.0 xfail(). "execution test"
432 else
433 failscip-shell shell shell-project 0.0.0 fail(). "execution test"
434 fi
435 return 1
436 fi
437 }
438
439 write_log_and_verbosescip-shell shell shell-project 0.0.0 write_log_and_verbose(). "$CXX $src $@ -D_GLIBCXX_SIMD_TESTTYPE=$type $abiflag -o $exe"
440 {
441 timeoutscip-shell system . . timeout. --foreground $timeout "$CXX" "$src" "$@" "-D_GLIBCXX_SIMD_TESTTYPE=$type" $abiflag -o "$exe" 2>&1 <&-
442 printfscip-shell system . . printf. "###exitstatus### %d\n" $?
443 } | verify_compilationscip-shell shell shell-project 0.0.0 verify_compilation(). || exit 0
444 if [scip-shell system . . `[`. -n "$sim" ]; then
445 write_log_and_verbosescip-shell shell shell-project 0.0.0 write_log_and_verbose(). "$sim ./$exe"
446 else
447 write_log_and_verbosescip-shell shell shell-project 0.0.0 write_log_and_verbose(). "./$exe"
448 timeout=$(awkscip-shell system . . awk. "BEGIN { print int($timeout / 2) }")
449 fi
450 {
451 timeoutscip-shell system . . timeout. --foreground $timeout $sim "./$exe" 2>&1 <&-
452 printfscip-shell system . . printf. "###exitstatus### %d\n" $?
453 } | verify_testscip-shell shell shell-project 0.0.0 verify_test(). || exit 0
454
455 # vim: sw=2 et cc=81 si