Revert wrong checkin
[official-gcc.git] / gcc / testsuite / go.test / go-test.exp
blobf0285a25cffa4425e10487d0bc3f8b4c052d2d7d
1 # Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
2 # Written by Ian Lance Taylor <iant@google.com>.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
19 # Test using the testsuite for the gc Go compiler. In these tests the
20 # first line is a shell script to run. That line expects the
21 # following environment variables to be set:
22 # A The file extension of the object file and the name of the executable
23 # G The name of the compiler
24 # L The name of the linker
25 # F The basename of the test
26 # D The directory of the test.
28 # Typical command lines:
29 # // $G $D/$F.go && $L $F.$A && ./$A.out
30 # // $G $D/$F.go && $L $F.$A || echo BUG: known to fail incorrectly
31 # // $G $D/$F.go && echo BUG: compilation succeeds incorrectly
32 # // $G $D/$F.go || echo BUG: compilation should succeed
34 load_lib go-dg.exp
35 load_lib go-torture.exp
37 # Implement errchk
38 proc errchk { test opts } {
39 global dg-do-what-default
40 global DEFAULT_GOCFLAGS
41 global runtests
43 set saved-dg-do-what-default ${dg-do-what-default}
44 set dg-do-what-default compile
45 set filename [file tail $test]
46 if { "$filename" == "$test" } {
47 set filename "errchk-$filename"
49 set fdin [open $test r]
50 fconfigure $fdin -encoding binary
51 set fdout [open $filename w]
52 fconfigure $fdout -encoding binary
53 while { [gets $fdin copy_line] >= 0 } {
54 if [string match "*////*" $copy_line] {
55 puts $fdout $copy_line
56 continue
58 regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
59 if [string match "*dg-error*.\**" $out_line] {
60 # I worked out the right number of backslashes by
61 # experimentation, not analysis.
62 regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
64 if [string match "*dg-error*\{*" $out_line] {
65 set index [string first "dg-error" $out_line]
66 regsub -start $index -all "\{" $out_line "\\\\\[\\\{\\\\\]" out_line
68 if [string match "*dg-error*\}*\}" $out_line] {
69 set index [string first "dg-error" $out_line]
70 regsub -start $index -all "\}\(.\)" $out_line "\\\\\[\\\}\\\\\]\\1" out_line
72 if [string match "*dg-error*\(*" $out_line] {
73 set index [string first "dg-error" $out_line]
74 regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
76 if [string match "*dg-error*\)*\}" $out_line] {
77 set index [string first "dg-error" $out_line]
78 regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
80 if [string match "*dg-error*\[.\]*" $out_line] {
81 set index [string first "dg-error" $out_line]
82 regsub -all "\\\[\\.\\\]" $out_line "\\\\\[.\\\\\]" out_line
84 puts $fdout $out_line
86 close $fdin
87 close $fdout
89 set hold_runtests $runtests
90 set runtests "go-test.exp"
91 go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
92 set runtests $hold_runtests
94 file delete $filename
95 set dg-do-what-default ${saved-dg-do-what-default}
98 # This is an execution test which should fail.
99 proc go-execute-xfail { test } {
100 global DEFAULT_GOCFLAGS
101 global runtests
103 set filename [file tail $test]
104 set fdin [open $test r]
105 set fdout [open $filename w]
106 puts $fdout "// { dg-do run { xfail *-*-* } }"
107 while { [gets $fdin copy_line] >= 0 } {
108 puts $fdout $copy_line
110 close $fdin
111 close $fdout
113 set hold_runtests $runtests
114 set runtests "go-test.exp"
115 go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
116 set runtests $hold_runtests
118 file delete $filename
121 # N.B. Keep in sync with libgo/configure.ac.
122 proc go-set-goarch { } {
123 global target_triplet
125 switch -glob $target_triplet {
126 "alpha*-*-*" {
127 set goarch "alpha"
129 "arm*-*-*" -
130 "ep9312*-*-*" -
131 "strongarm*-*-*" -
132 "xscale-*-*" {
133 set goarch "arm"
135 "i?86-*-*" -
136 "x86_64-*-*" {
137 if [check_effective_target_ilp32] {
138 set goarch "386"
139 } else {
140 set goarch "amd64"
143 "mips*-*-*" {
144 if [check_no_compiler_messages mipso32 assembly {
145 #if _MIPS_SIM != _ABIO32
146 #error FOO
147 #endif
148 }] {
149 set goarch "mipso32"
150 } elseif [check_no_compiler_messages mipsn32 assembly {
151 #if _MIPS_SIM != _ABIN32
152 #error FOO
153 #endif
154 }] {
155 set goarch "mipsn32"
156 } elseif [check_no_compiler_messages mipsn64 assembly {
157 #if _MIPS_SIM != _ABI64
158 #error FOO
159 #endif
160 }] {
161 set goarch "mipsn64"
162 } elseif [check_no_compiler_messages mipso64 assembly {
163 #if _MIPS_SIM != _ABIO64
164 #error FOO
165 #endif
166 }] {
167 set goarch "mipso64"
168 } else {
169 perror "$target_triplet: unrecognized MIPS ABI"
170 return ""
173 "sparc*-*-*" {
174 if [check_effective_target_ilp32] {
175 set goarch "sparc"
176 } else {
177 set goarch "sparc64"
180 default {
181 perror "$target_triplet: unhandled architecture"
182 return ""
185 verbose -log "Setting GOARCH=$goarch" 1
186 setenv GOARCH $goarch
189 proc go-gc-tests { } {
190 global srcdir subdir
191 global runtests
192 global GCC_UNDER_TEST
193 global TOOL_OPTIONS
194 global TORTURE_OPTIONS
195 global dg-do-what-default
196 global go_execute_args
197 global target_triplet
199 # If a testcase doesn't have special options, use these.
200 global DEFAULT_GOCFLAGS
201 if ![info exists DEFAULT_GOCFLAGS] {
202 set DEFAULT_GOCFLAGS " -pedantic-errors"
205 # Set GOARCH for tests that need it.
206 go-set-goarch
208 # Running all the torture options takes too long and, since the
209 # frontend ignores the standard options, it doesn't significantly
210 # improve testing.
211 set saved_torture_options $TORTURE_OPTIONS
212 set TORTURE_OPTIONS [ list { -O2 -g }]
214 set saved-dg-do-what-default ${dg-do-what-default}
216 set testdir [pwd]
218 set tests [lsort [find $srcdir/$subdir *.go]]
219 foreach test $tests {
220 if ![runtest_file_p $runtests $test] {
221 continue
224 # Skip the files in bench and garbage; they are not tests.
225 if [string match "*go.test/test/bench/*" $test] {
226 continue
228 if [string match "*go.test/test/garbage/*" $test] {
229 continue
232 # Skip files in sub-subdirectories: they are components of
233 # other tests.
234 if [string match "*go.test/test/*/*/*" $test] {
235 continue
238 set name [dg-trim-dirname $srcdir $test]
240 # Skip certain tests if target is RTEMS OS.
241 if [istarget "*-*-rtems*"] {
242 if { [string match "*go.test/test/args.go" \
243 $test] \
244 || [string match "*go.test/test/env.go" \
245 $test] } {
246 untested "$name: uses the command-line or environment variables"
247 continue
250 if { [string match "*go.test/test/stack.go" \
251 $test] \
252 || [string match "*go.test/test/peano.go" \
253 $test] \
254 || [string match "*go.test/test/chan/goroutines.go" \
255 $test] } {
256 untested "$name: has very high memory requirement"
257 continue
261 set fd [open $test r]
263 set lines_ok 1
265 while 1 {
266 if { [gets $fd test_line] < 0 } {
267 close $fd
268 clone_output "$test: could not read first line"
269 unresolved $name
270 set lines_ok 0
271 break
274 if { [ string match "*nacl*exit 0*" $test_line ] \
275 || [ string match "*exit 0*nacl*" $test_line ] \
276 || [ string match "*Android*exit 0*" $test_line ] \
277 || [ string match "*exit 0*Android*" $test_line ] } {
278 continue
281 break
284 if { $lines_ok == 0 } {
285 continue
288 set lineno 1
289 set test_line1 $test_line
291 while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
292 set lineno [expr $lineno + 1]
293 if { [eval "gets \$fd test_line$lineno"] < 0 } {
294 close $fd
295 clone_output "$test: could not read line $lineno"
296 unresolved $name
297 set lines_ok 0
298 break
301 if { $lines_ok == 0 } {
302 continue
305 close $fd
307 set go_execute_args ""
308 if { [regexp ".*\\\$A.out (\[^|&>\].*)\$" $test_line match progargs] } {
309 set go_execute_args $progargs
310 verbose -log "$test: go_execute_args is $go_execute_args"
311 set index [string last " $progargs" $test_line]
312 set test_line [string replace $test_line $index end]
313 } elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
314 && [getenv GCCGO_RUN_ALL_TESTS] == "" } {
315 # goroutines.go spawns by default 10000 threads, which is too much
316 # for many OSes.
317 if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
318 set go_execute_args 64
319 } elseif { ![is_remote host] && ![is_remote target] } {
320 # When using low ulimit -u limit, use maximum of
321 # a quarter of that limit and 10000 even when running expensive
322 # tests, otherwise parallel tests might fail after fork failures.
323 set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
324 if { [string is integer -strict $nproc] } {
325 set nproc [expr $nproc / 4]
326 if { $nproc > 10000 } { set nproc 10000 }
327 if { $nproc < 16 } { set nproc 16 }
328 set go_execute_args $nproc
331 if { "$go_execute_args" != "" } {
332 verbose -log "$test: go_execute_args is $go_execute_args"
336 if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
337 && $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
338 # 64bit.go is a special case.
339 set go_execute_args ""
340 set hold_runtests $runtests
341 set runtests "go-test.exp"
342 set dg-do-what-default "link"
343 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
344 set output_file "./[file rootname [file tail $test]].exe"
345 set base "[file rootname [file tail $test]]"
346 if [isnative] {
347 if { [catch "exec $output_file >$base-out.go"] != 0 } {
348 fail "$name execution"
349 } else {
350 pass "$name execution"
351 file delete $base-out.x
352 go-torture-execute "./$base-out.go"
354 file delete $base-out.go
356 file delete $output_file
357 set runtests $hold_runtests
358 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
359 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
360 || $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
361 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
362 || [string match \
363 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
364 $test_line]
365 || [string match \
366 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
367 $test_line]
368 || [string match \
369 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
370 $test_line]
371 || [string match \
372 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
373 $test_line]
374 || [string match \
375 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
376 $test_line] } {
377 # This is a vanilla execution test.
378 go-torture-execute $test
379 file delete core [glob -nocomplain core.*]
380 } elseif { [string match \
381 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
382 $test_line] \
383 || [string match "// \$G \$F.go && \$L \$F.\$A #*" \
384 $test_line]
385 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
386 # This is a vanilla compile and link test.
387 set dg-do-what-default "link"
388 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
389 } elseif { [string match "// \$G \$D/\$F.go" $test_line] \
390 || [string match "// \$G \$D/\$F.go || echo BUG*" \
391 $test_line] \
392 || [string match "// \$G \$F.go || echo BUG*" \
393 $test_line] \
394 || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
395 $test_line] } {
396 # This is a vanilla compile test.
397 set dg-do-what-default "assemble"
398 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
399 } elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
400 $test_line] \
401 || $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
402 || $test_line == "// ! \$G \$D/\$F.go" \
403 || $test_line == "// ! \$G \$F.go" \
404 || [string match "// ! \$G \$D/\$F.go || echo BUG*" \
405 $test_line] } {
406 # This is a compile test which should fail.
407 set dg-do-what-default "assemble"
408 setup_xfail "*-*-*"
409 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
410 } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
411 $test_line] \
412 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
413 $test_line] \
414 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
415 $test_line] \
416 || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
417 && $test_line2 == "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
418 go-execute-xfail $test
419 } elseif { [string match "// errchk \$G \$F.go" $test_line] \
420 || [string match "// errchk \$G -e \$F.go" $test_line] \
421 || [string match "// errchk \$G \$D/\$F.go" $test_line] \
422 || [string match "//errchk \$G \$D/\$F.go" $test_line] \
423 || [string match "// errchk \$G -e \$D/\$F.go" \
424 $test_line] \
425 || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
426 || [string match "// ! errchk \$G -e \$D/\$F.go" \
427 $test_line] \
428 || [string match "// errchk \$G \$F.go || true" \
429 $test_line] \
430 || [string match "// errchk \$G \$D/\$F.go || true" \
431 $test_line] \
432 || [string match "// errchk \$G -e \$D/\$F.go || true" \
433 $test_line] \
434 || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
435 $test_line] } {
436 errchk $test ""
437 } elseif { [string match \
438 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
439 $test_line] } {
440 set hold_runtests $runtests
441 set runtests "go-test.exp"
442 set dg-do-what-default "assemble"
443 regsub "\\.go$" $test ".dir/bug0.go" file1
444 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
445 regsub "\\.go$" $test ".dir/bug1.go" file2
446 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
447 file delete "[file rootname [file tail $file1]].o"
448 set runtests $hold_runtests
449 } elseif { [string match \
450 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
451 $test_line] \
452 || [string match \
453 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
454 $test_line] } {
455 if { [string match \
456 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
457 $test_line] } {
458 set name1 "p1.go"
459 set name2 "p2.go"
460 } else {
461 set name1 "bug0.go"
462 set name2 "bug1.go"
464 set hold_runtests $runtests
465 set runtests "go-test.exp"
466 set dg-do-what-default "assemble"
467 regsub "\\.go$" $test ".dir/$name1" file1
468 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
469 regsub "\\.go$" $test ".dir/$name2" file2
470 errchk $file2 ""
471 file delete "[file rootname [file tail $file1]].o"
472 set runtests $hold_runtests
473 } elseif { [string match \
474 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
475 $test_line] } {
476 set hold_runtests $runtests
477 set runtests "go-test.exp"
478 set dg-do-what-default "assemble"
479 regsub "\\.go$" $test ".dir/bug0.go" file1
480 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
481 regsub "\\.go$" $test ".dir/bug1.go" file2
482 setup_xfail "*-*-*"
483 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
484 file delete "[file rootname [file tail $file1]].o"
485 set runtests $hold_runtests
486 } elseif { [string match \
487 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
488 $test_line] } {
489 set hold_runtests $runtests
490 set runtests "go-test.exp"
491 set dg-do-what-default "assemble"
492 regsub "\\.go$" $test ".dir/bug0.go" file1
493 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
494 regsub "\\.go$" $test ".dir/bug1.go" file2
495 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
496 regsub "\\.go$" $test ".dir/bug2.go" file3
497 setup_xfail "*-*-*"
498 dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
499 file delete "[file rootname [file tail $file1]].o"
500 file delete "[file rootname [file tail $file2]].o"
501 set runtests $hold_runtests
502 } elseif { [string match \
503 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
504 $test_line] } {
505 set hold_runtests $runtests
506 set runtests "go-test.exp"
507 set dg-do-what-default "assemble"
508 regsub "\\.go$" $test ".dir/bug0.go" file1
509 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
510 regsub "\\.go$" $test ".dir/bug1.go" file2
511 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
512 regsub "\\.go$" $test ".dir/bug2.go" file3
513 errchk $file3 ""
514 file delete "[file rootname [file tail $file1]].o"
515 file delete "[file rootname [file tail $file2]].o"
516 set runtests $hold_runtests
517 } elseif { [string match \
518 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
519 $test_line] } {
520 set hold_runtests $runtests
521 set runtests "go-test.exp"
522 set dg-do-what-default "assemble"
523 regsub "\\.go$" $test ".dir/x.go" file1
524 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
525 set ofile1 "[file rootname [file tail $file1]].o"
526 regsub "\\.go$" $test ".dir/y.go" file2
527 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
528 set ofile2 "[file rootname [file tail $file2]].o"
529 set dg-do-what-default "link"
530 set output_file "./[file rootname [file tail $test]].exe"
531 set comp_output [go_target_compile "$ofile1 $ofile2" \
532 $output_file "executable" "$DEFAULT_GOCFLAGS"]
533 set comp_output [go-dg-prune $target_triplet $comp_output]
534 verbose -log $comp_output
535 set result [go_load "$output_file" "" ""]
536 set status [lindex $result 0]
537 $status $name
538 file delete $ofile1 $ofile2 $output_file
539 set runtests $hold_runtests
540 } elseif { [string match \
541 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
542 $test_line] } {
543 set hold_runtests $runtests
544 set runtests "go-test.exp"
545 set dg-do-what-default "assemble"
546 regsub "\\.go$" $test ".dir/a.go" file1
547 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
548 set ofile1 "[file rootname [file tail $file1]].o"
549 regsub "\\.go$" $test ".dir/b.go" file2
550 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
551 set ofile2 "[file rootname [file tail $file2]].o"
552 dg-test -keep-output "$test" "-O" "-w $DEFAULT_GOCFLAGS"
553 set ofile3 "[file rootname [file tail $test]].o"
554 set dg-do-what-default "link"
555 set output_file "./[file rootname [file tail $test]].exe"
556 set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
557 $output_file "executable" "$DEFAULT_GOCFLAGS"]
558 set comp_output [go-dg-prune $target_triplet $comp_output]
559 if [string match "" $comp_output] {
560 pass $name
561 } else {
562 verbose -log $comp_output
563 fail $name
565 file delete $ofile1 $ofile2 $ofile3 $output_file
566 set runtests $hold_runtests
567 } elseif { [string match \
568 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
569 $test_line ] } {
570 set hold_runtests $runtests
571 set runtests "go-test.exp"
572 set dg-do-what-default "assemble"
573 regsub "/\[^/\]*$" $test "/embed0.go" file1
574 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
575 set ofile1 "[file rootname [file tail $file1]].o"
576 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
577 set ofile2 "[file rootname [file tail $test]].o"
578 set output_file "./[file rootname [file tail $test]].exe"
579 set comp_output [go_target_compile "$ofile1 $ofile2" \
580 $output_file "executable" "$DEFAULT_GOCFLAGS"]
581 set comp_output [go-dg-prune $target_triplet $comp_output]
582 if [string match "" $comp_output] {
583 set result [go_load "$output_file" "" ""]
584 set status [lindex $result 0]
585 $status $name
586 } else {
587 verbose -log $comp_output
588 fail $name
590 file delete $ofile1 $ofile2 $output_file
591 set runtests $hold_runtests
592 } elseif { [string match \
593 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
594 $test_line ] } {
595 set hold_runtests $runtests
596 set runtests "go-test.exp"
597 set dg-do-what-default "assemble"
598 regsub "\\.go$" $test ".dir/lib.go" file1
599 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
600 set ofile1 "[file rootname [file tail $file1]].o"
601 regsub "\\.go$" $test ".dir/main.go" file2
602 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
603 set ofile2 "[file rootname [file tail $file2]].o"
604 set dg-do-what-default "link"
605 set output_file "./[file rootname [file tail $file2]].exe"
606 set comp_output [go_target_compile "$ofile1 $ofile2" \
607 $output_file "executable" "$DEFAULT_GOCFLAGS"]
608 set comp_output [go-dg-prune $target_triplet $comp_output]
609 if [string match "" $comp_output] {
610 set result [go_load "$output_file" "" ""]
611 set status [lindex $result 0]
612 $status $name
613 } else {
614 verbose -log $comp_output
615 fail $name
617 file delete $ofile1 $ofile2 $output_file
618 set runtests $hold_runtests
619 } elseif { [string match \
620 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
621 $test_line] } {
622 set hold_runtests $runtests
623 set runtests "go-test.exp"
624 set dg-do-what-default "assemble"
625 regsub "\\.go$" $test ".dir/chanbug.go" file1
626 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
627 regsub "\\.go$" $test ".dir/chanbug2.go" file2
628 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
629 file delete "[file rootname [file tail $file1]].o"
630 set runtests $hold_runtests
631 } elseif { [string match \
632 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
633 $test_line] } {
634 set dg-do-what-default "assemble"
635 setup_xfail "*-*-*"
636 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
637 } elseif { [string match \
638 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
639 $test_line] } {
640 set hold_runtests $runtests
641 set runtests "go-test.exp"
642 set dg-do-what-default "assemble"
643 regsub "\\.go$" $test ".dir/x.go" file1
644 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
645 regsub "\\.go$" $test ".dir/y.go" file2
646 errchk $file2 ""
647 file delete "[file rootname [file tail $file1]].o"
648 set runtests $hold_runtests
649 } elseif { [string match "// true*" $test_line] } {
650 # Not a real test, just ignore.
651 } elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
652 && $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
653 && $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
654 && $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
655 && $test_line5 == "// \$L bug2.\$A &&" \
656 && [string match "// ./\$A.out || echo BUG*" $test_line6] } {
657 set hold_runtests $runtests
658 set runtests "go-test.exp"
659 set dg-do-what-default "assemble"
660 regsub "\\.go$" $test ".dir/bug0.go" file0
661 dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
662 set ofile0 "[file rootname [file tail $file0]].o"
663 regsub "\\.go$" $test ".dir/bug1.go" file1
664 dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
665 set ofile1 "[file rootname [file tail $file1]].o"
666 regsub "\\.go$" $test ".dir/bug2.go" file2
667 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
668 set ofile2 "[file rootname [file tail $file2]].o"
669 regsub "\\.go$" $test ".dir/bug3.go" file3
670 errchk $file3 ""
671 set output_file "./[file rootname [file tail $test]].exe"
672 set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
673 $output_file "executable" "$DEFAULT_GOCFLAGS"]
674 set comp-output [go-dg-prune $target_triplet $comp_output]
675 if [string match "" $comp_output] {
676 set result [go_load "$output_file" "" ""]
677 set status [lindex $result 0]
678 $status $name
679 } else {
680 verbose -log $comp_output
681 fail $name
683 file delete $ofile0 $ofile1 $ofile2 $output_file
684 set runtests $hold_runtests
685 } elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
686 set hold_runtests $runtests
687 set runtests "go-test.exp"
688 set dg-do-what-default "assemble"
689 regsub "/\[^/\]*$" $test "/import2.go" file1
690 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
691 set ofile1 "[file rootname [file tail $file1]].o"
692 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
693 file delete $ofile1
694 set runtests $hold_runtests
695 } elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
696 set hold_runtests $runtests
697 set runtests "go-test.exp"
698 set dg-do-what-default "assemble"
699 regsub "/\[^/\]*$" $test "/ddd2.go" file1
700 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
701 set ofile1 "[file rootname [file tail $file1]].o"
702 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
703 set ofile2 "[file rootname [file tail $test]].o"
704 set output_file "./[file rootname [file tail $test]].exe"
705 set comp_output [go_target_compile "$ofile1 $ofile2" \
706 $output_file "executable" "$DEFAULT_GOCFLAGS"]
707 set comp_output [go-dg-prune $target_triplet $comp_output]
708 if [string match "" $comp_output] {
709 set result [go_load "$output_file" "" ""]
710 set status [lindex $result 0]
711 $status $name
712 } else {
713 verbose -log $comp_output
714 fail $name
716 file delete $ofile1 $ofile2 $output_file
717 set runtests $hold_runtests
718 } elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
719 regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
720 set output_file "./[file rootname [file tail $test]].o"
721 set comp_output [go_target_compile "$test $test2" \
722 $output_file "executable" "$DEFAULT_GOCFLAGS"]
723 set comp_output [go-dg-prune $target_triplet $comp_output]
724 if [string match "" $comp_output] {
725 set result [go_load "$output_file" "" ""]
726 set status [lindex $result 0]
727 $status $name
728 } else {
729 verbose -log $comp_output
730 fail $name
732 file delete $output_file
733 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
734 && $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
735 && $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
736 && $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
737 set go_execute_args ""
738 set hold_runtests $runtests
739 set runtests "go-test.exp"
740 set dg-do-what-default "link"
741 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
742 set output_file "./[file rootname [file tail $test]].exe"
743 if [isnative] {
744 if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
745 fail "$name execution 0"
746 } else {
747 pass "$name execution 0"
748 file delete tmp.x
749 go-torture-execute "./tmp.go"
751 if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
752 fail "$name execution 1"
753 } else {
754 pass "$name execution 1"
755 errchk tmp.go ""
757 if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
758 fail "$name execution 2"
759 } else {
760 pass "$name execution 2"
761 errchk tmp.go ""
763 file delete tmp.go
765 file delete $output_file
766 set runtests $hold_runtests
767 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
768 && $test_line2 == "// errchk \$G -e tmp.go" } {
769 set go_execute_args ""
770 set hold_runtests $runtests
771 set runtests "go-test.exp"
772 set dg-do-what-default "link"
773 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
774 set output_file "./[file rootname [file tail $test]].exe"
775 if [isnative] {
776 if { [catch "exec $output_file >tmp.go"] != 0 } {
777 fail "$name execution"
778 } else {
779 pass "$name execution"
780 file delete tmp.x
781 errchk tmp.go ""
784 file delete $output_file
785 set runtests $hold_runtests
786 } elseif { [string match \
787 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
788 $test_line] } {
789 set hold_runtests $runtests
790 set runtests "go-test.exp"
791 set dg-do-what-default "assemble"
792 regsub "\\.go$" $test ".dir/p.go" file1
793 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
794 set ofile1 "[file rootname [file tail $file1]].o"
795 regsub "\\.go$" $test ".dir/main.go" file2
796 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
797 set ofile2 "[file rootname [file tail $file2]].o"
798 set output_file "./[file rootname [file tail $test]].exe"
799 set comp_output [go_target_compile "$ofile1 $ofile2" \
800 $output_file "executable" "$DEFAULT_GOCFLAGS"]
801 set comp_output [go-dg-prune $target_triplet $comp_output]
802 if [string match "" $comp_output] {
803 setup_xfail "*-*-*"
804 set result [go_load "$output_file" "" ""]
805 set status [lindex $result 0]
806 $status $name
807 } else {
808 verbose -log $comp_output
809 fali $name
811 file delete $ofile1 $ofile2 $output_file
812 set runtests $hold_runtests
813 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
814 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
815 set go_execute_args ""
816 set hold_runtests $runtests
817 set runtests "go-test.exp"
818 set dg-do-what-default "link"
819 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
820 set output_file "./[file rootname [file tail $test]].exe"
821 set base "[file rootname [file tail $test]]"
822 if [isnative] {
823 if { [catch "exec $output_file > $base-out.go"] != 0 } {
824 fail "$name execution"
825 } else {
826 pass "$name execution"
827 file delete $base-out.x
828 go-torture-execute "./$base-out.go"
830 # file delete $base-out.go
832 file delete $output_file
833 set runtests $hold_runtests
834 } elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
835 regsub "\\.go$" $test ".dir/a.go" file1
836 regsub "\\.go$" $test ".dir/b.go" file2
837 errchk "$file1" "$file2"
838 } elseif { $test_line == "// # generated by cmplxdivide.c" } {
839 # Ignore.
840 } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
841 || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
842 # These tests import the same package under two different
843 # names, which gccgo does not support.
844 } elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo FAIL || true" } {
845 # This tests whether initializers are written out
846 # statically. gccgo does not provide a way to test that,
847 # as an initializer will be generated for any code which
848 # has global variables which need to be registered as GC
849 # roots.
850 } else {
851 clone_output "$name: unrecognized test line: $test_line"
852 unsupported $name
855 set go_execute_args ""
858 set dg-do-what-default ${saved-dg-do-what-default}
859 set TORTURE_OPTIONS $saved_torture_options
862 go-gc-tests