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
35 load_lib go-torture.exp
38 proc errchk { test opts } {
39 global dg-do-what-default
40 global DEFAULT_GOCFLAGS
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
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 # Special case for bug332, in which the error message wants to
85 # match the file name, which is not what dg-error expects.
86 if [string match "*dg-error*bug332*" $out_line] {
87 set index [string first "dg-error" $out_line]
88 regsub -start $index "bug332" $out_line "undefined type" out_line
95 set hold_runtests $runtests
96 set runtests "go-test.exp"
97 go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
98 set runtests $hold_runtests
100 file delete $filename
101 set dg-do-what-default ${saved-dg-do-what-default}
104 # This is an execution test which should fail.
105 proc go-execute-xfail { test } {
106 global DEFAULT_GOCFLAGS
109 set filename [file tail $test]
110 set fdin [open $test r]
111 set fdout [open $filename w]
112 puts $fdout "// { dg-do run { xfail *-*-* } }"
113 while { [gets $fdin copy_line] >= 0 } {
114 puts $fdout $copy_line
119 set hold_runtests $runtests
120 set runtests "go-test.exp"
121 go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
122 set runtests $hold_runtests
124 file delete $filename
127 # N.B. Keep in sync with libgo/configure.ac.
128 proc go-set-goarch { } {
129 global target_triplet
131 switch -glob $target_triplet {
143 if [check_effective_target_ia32] {
150 if [check_no_compiler_messages mipso32 assembly {
151 #if _MIPS_SIM != _ABIO32
156 } elseif [check_no_compiler_messages mipsn32 assembly {
157 #if _MIPS_SIM != _ABIN32
162 } elseif [check_no_compiler_messages mipsn64 assembly {
163 #if _MIPS_SIM != _ABI64
168 } elseif [check_no_compiler_messages mipso64 assembly {
169 #if _MIPS_SIM != _ABIO64
175 perror "$target_triplet: unrecognized MIPS ABI"
180 if [check_effective_target_ilp32] {
187 perror "$target_triplet: unhandled architecture"
191 verbose -log "Setting GOARCH=$goarch" 1
192 setenv GOARCH $goarch
195 proc go-gc-tests { } {
198 global GCC_UNDER_TEST
200 global TORTURE_OPTIONS
201 global dg-do-what-default
202 global go_execute_args
203 global target_triplet
205 # If a testcase doesn't have special options, use these.
206 global DEFAULT_GOCFLAGS
207 if ![info exists DEFAULT_GOCFLAGS] {
208 set DEFAULT_GOCFLAGS " -pedantic-errors"
211 # Set GOARCH for tests that need it.
214 # Running all the torture options takes too long and, since the
215 # frontend ignores the standard options, it doesn't significantly
217 set saved_torture_options $TORTURE_OPTIONS
218 set TORTURE_OPTIONS [ list { -O2 -g }]
220 set saved-dg-do-what-default ${dg-do-what-default}
224 set tests [lsort [find $srcdir/$subdir *.go]]
225 foreach test $tests {
226 if ![runtest_file_p $runtests $test] {
230 # Skip the files in bench and garbage; they are not tests.
231 if [string match "*go.test/test/bench/*" $test] {
234 if [string match "*go.test/test/garbage/*" $test] {
238 # Skip files in sub-subdirectories: they are components of
240 if [string match "*go.test/test/*/*/*" $test] {
244 set name [dg-trim-dirname $srcdir $test]
246 # Skip certain tests if target is RTEMS OS.
247 if [istarget "*-*-rtems*"] {
248 if { [string match "*go.test/test/args.go" \
250 || [string match "*go.test/test/env.go" \
252 untested "$name: uses the command-line or environment variables"
256 if { [string match "*go.test/test/stack.go" \
258 || [string match "*go.test/test/peano.go" \
260 || [string match "*go.test/test/chan/goroutines.go" \
262 untested "$name: has very high memory requirement"
267 if { [string match "*bug347*" $test] \
268 || [string match "*bug348*" $test] } {
269 # These bugs rely on runtime.Caller which currently fails.
274 set fd [open $test r]
279 if { [gets $fd test_line] < 0 } {
281 clone_output "$test: could not read first line"
287 if { [ string match "*nacl*exit 0*" $test_line ] \
288 || [ string match "*exit 0*nacl*" $test_line ] \
289 || [ string match "*Android*exit 0*" $test_line ] \
290 || [ string match "*exit 0*Android*" $test_line ] } {
297 if { $lines_ok == 0 } {
302 set test_line1 $test_line
304 while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
305 set lineno [expr $lineno + 1]
306 if { [eval "gets \$fd test_line$lineno"] < 0 } {
308 clone_output "$test: could not read line $lineno"
314 if { $lines_ok == 0 } {
320 set go_execute_args ""
321 if { [regexp ".*\\\$A.out (\[^|&>\].*)\$" $test_line match progargs] } {
322 set go_execute_args $progargs
323 verbose -log "$test: go_execute_args is $go_execute_args"
324 set index [string last " $progargs" $test_line]
325 set test_line [string replace $test_line $index end]
326 } elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
327 && [getenv GCCGO_RUN_ALL_TESTS] == "" } {
328 # goroutines.go spawns by default 10000 threads, which is too much
330 if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
331 set go_execute_args 64
332 } elseif { ![is_remote host] && ![is_remote target] } {
333 # When using low ulimit -u limit, use maximum of
334 # a quarter of that limit and 10000 even when running expensive
335 # tests, otherwise parallel tests might fail after fork failures.
336 set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
337 if { [string is integer -strict $nproc] } {
338 set nproc [expr $nproc / 4]
339 if { $nproc > 10000 } { set nproc 10000 }
340 if { $nproc < 16 } { set nproc 16 }
341 set go_execute_args $nproc
344 if { "$go_execute_args" != "" } {
345 verbose -log "$test: go_execute_args is $go_execute_args"
349 if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
350 && $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
351 # 64bit.go is a special case.
352 set go_execute_args ""
353 set hold_runtests $runtests
354 set runtests "go-test.exp"
355 set dg-do-what-default "link"
356 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
357 set output_file "./[file rootname [file tail $test]].exe"
358 set base "[file rootname [file tail $test]]"
360 if { [catch "exec $output_file >$base-out.go"] != 0 } {
361 fail "$name execution"
363 pass "$name execution"
364 file delete $base-out.x
365 go-torture-execute "./$base-out.go"
367 file delete $base-out.go
369 file delete $output_file
370 set runtests $hold_runtests
371 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
372 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
373 || $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
374 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
376 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
379 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
382 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
385 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
388 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
390 # This is a vanilla execution test.
391 go-torture-execute $test
392 file delete core [glob -nocomplain core.*]
393 } elseif { [string match \
394 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
396 || [string match "// \$G \$F.go && \$L \$F.\$A #*" \
398 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
399 # This is a vanilla compile and link test.
400 set dg-do-what-default "link"
401 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
402 } elseif { [string match "// \$G \$D/\$F.go" $test_line] \
403 || [string match "// \$G \$D/\$F.go || echo BUG*" \
405 || [string match "// \$G \$F.go || echo BUG*" \
407 || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
409 # This is a vanilla compile test.
410 set dg-do-what-default "assemble"
411 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
412 } elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
414 || $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
415 || $test_line == "// ! \$G \$D/\$F.go" \
416 || $test_line == "// ! \$G \$F.go" \
417 || [string match "// ! \$G \$D/\$F.go || echo BUG*" \
419 # This is a compile test which should fail.
420 set dg-do-what-default "assemble"
422 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
423 } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
425 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
427 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
429 || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
430 && $test_line2 == "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
431 go-execute-xfail $test
432 } elseif { [string match "// errchk \$G \$F.go" $test_line] \
433 || [string match "// errchk \$G -e \$F.go" $test_line] \
434 || [string match "// errchk \$G \$D/\$F.go" $test_line] \
435 || [string match "//errchk \$G \$D/\$F.go" $test_line] \
436 || [string match "// errchk \$G -e \$D/\$F.go" \
438 || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
439 || [string match "// ! errchk \$G -e \$D/\$F.go" \
441 || [string match "// errchk \$G \$F.go || true" \
443 || [string match "// errchk \$G \$D/\$F.go || true" \
445 || [string match "// errchk \$G -e \$D/\$F.go || true" \
447 || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
450 } elseif { [string match \
451 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
453 set hold_runtests $runtests
454 set runtests "go-test.exp"
455 set dg-do-what-default "assemble"
456 regsub "\\.go$" $test ".dir/bug0.go" file1
457 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
458 regsub "\\.go$" $test ".dir/bug1.go" file2
459 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
460 file delete "[file rootname [file tail $file1]].o"
461 set runtests $hold_runtests
462 } elseif { [string match \
463 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
466 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
469 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
472 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
476 } elseif { [string match \
477 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
485 set hold_runtests $runtests
486 set runtests "go-test.exp"
487 set dg-do-what-default "assemble"
488 regsub "\\.go$" $test ".dir/$name1" file1
489 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
490 regsub "\\.go$" $test ".dir/$name2" file2
492 file delete "[file rootname [file tail $file1]].o"
493 set runtests $hold_runtests
494 } elseif { [string match \
495 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
497 set hold_runtests $runtests
498 set runtests "go-test.exp"
499 set dg-do-what-default "assemble"
500 regsub "\\.go$" $test ".dir/bug0.go" file1
501 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
502 regsub "\\.go$" $test ".dir/bug1.go" file2
504 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
505 file delete "[file rootname [file tail $file1]].o"
506 set runtests $hold_runtests
507 } elseif { [string match \
508 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
510 set hold_runtests $runtests
511 set runtests "go-test.exp"
512 set dg-do-what-default "assemble"
513 regsub "\\.go$" $test ".dir/bug0.go" file1
514 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
515 regsub "\\.go$" $test ".dir/bug1.go" file2
516 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
517 regsub "\\.go$" $test ".dir/bug2.go" file3
519 dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
520 file delete "[file rootname [file tail $file1]].o"
521 file delete "[file rootname [file tail $file2]].o"
522 set runtests $hold_runtests
523 } elseif { [string match \
524 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
526 set hold_runtests $runtests
527 set runtests "go-test.exp"
528 set dg-do-what-default "assemble"
529 regsub "\\.go$" $test ".dir/bug0.go" file1
530 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
531 regsub "\\.go$" $test ".dir/bug1.go" file2
532 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
533 regsub "\\.go$" $test ".dir/bug2.go" file3
535 file delete "[file rootname [file tail $file1]].o"
536 file delete "[file rootname [file tail $file2]].o"
537 set runtests $hold_runtests
538 } elseif { [string match \
539 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
541 set hold_runtests $runtests
542 set runtests "go-test.exp"
543 set dg-do-what-default "assemble"
544 regsub "\\.go$" $test ".dir/x.go" file1
545 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
546 set ofile1 "[file rootname [file tail $file1]].o"
547 regsub "\\.go$" $test ".dir/y.go" file2
548 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
549 set ofile2 "[file rootname [file tail $file2]].o"
550 set dg-do-what-default "link"
551 set output_file "./[file rootname [file tail $test]].exe"
552 set comp_output [go_target_compile "$ofile1 $ofile2" \
553 $output_file "executable" "$DEFAULT_GOCFLAGS"]
554 set comp_output [go-dg-prune $target_triplet $comp_output]
555 verbose -log $comp_output
556 set result [go_load "$output_file" "" ""]
557 set status [lindex $result 0]
559 file delete $ofile1 $ofile2 $output_file
560 set runtests $hold_runtests
561 } elseif { [string match \
562 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
564 set hold_runtests $runtests
565 set runtests "go-test.exp"
566 set dg-do-what-default "assemble"
567 regsub "\\.go$" $test ".dir/a.go" file1
568 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
569 set ofile1 "[file rootname [file tail $file1]].o"
570 regsub "\\.go$" $test ".dir/b.go" file2
571 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
572 set ofile2 "[file rootname [file tail $file2]].o"
573 dg-test -keep-output "$test" "-O" "-w $DEFAULT_GOCFLAGS"
574 set ofile3 "[file rootname [file tail $test]].o"
575 set dg-do-what-default "link"
576 set output_file "./[file rootname [file tail $test]].exe"
577 set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
578 $output_file "executable" "$DEFAULT_GOCFLAGS"]
579 set comp_output [go-dg-prune $target_triplet $comp_output]
580 if [string match "" $comp_output] {
583 verbose -log $comp_output
586 file delete $ofile1 $ofile2 $ofile3 $output_file
587 set runtests $hold_runtests
588 } elseif { [string match \
589 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
591 set hold_runtests $runtests
592 set runtests "go-test.exp"
593 set dg-do-what-default "assemble"
594 regsub "/\[^/\]*$" $test "/embed0.go" file1
595 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
596 set ofile1 "[file rootname [file tail $file1]].o"
597 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
598 set ofile2 "[file rootname [file tail $test]].o"
599 set output_file "./[file rootname [file tail $test]].exe"
600 set comp_output [go_target_compile "$ofile1 $ofile2" \
601 $output_file "executable" "$DEFAULT_GOCFLAGS"]
602 set comp_output [go-dg-prune $target_triplet $comp_output]
603 if [string match "" $comp_output] {
604 set result [go_load "$output_file" "" ""]
605 set status [lindex $result 0]
608 verbose -log $comp_output
611 file delete $ofile1 $ofile2 $output_file
612 set runtests $hold_runtests
613 } elseif { [string match \
614 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
616 set hold_runtests $runtests
617 set runtests "go-test.exp"
618 set dg-do-what-default "assemble"
619 regsub "\\.go$" $test ".dir/lib.go" file1
620 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
621 set ofile1 "[file rootname [file tail $file1]].o"
622 regsub "\\.go$" $test ".dir/main.go" file2
623 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
624 set ofile2 "[file rootname [file tail $file2]].o"
625 set dg-do-what-default "link"
626 set output_file "./[file rootname [file tail $file2]].exe"
627 set comp_output [go_target_compile "$ofile1 $ofile2" \
628 $output_file "executable" "$DEFAULT_GOCFLAGS"]
629 set comp_output [go-dg-prune $target_triplet $comp_output]
630 if [string match "" $comp_output] {
631 set result [go_load "$output_file" "" ""]
632 set status [lindex $result 0]
635 verbose -log $comp_output
638 file delete $ofile1 $ofile2 $output_file
639 set runtests $hold_runtests
640 } elseif { [string match \
641 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
643 set hold_runtests $runtests
644 set runtests "go-test.exp"
645 set dg-do-what-default "assemble"
646 regsub "\\.go$" $test ".dir/chanbug.go" file1
647 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
648 regsub "\\.go$" $test ".dir/chanbug2.go" file2
649 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
650 file delete "[file rootname [file tail $file1]].o"
651 set runtests $hold_runtests
652 } elseif { [string match \
653 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
655 set dg-do-what-default "assemble"
657 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
658 } elseif { [string match \
659 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
661 set hold_runtests $runtests
662 set runtests "go-test.exp"
663 set dg-do-what-default "assemble"
664 regsub "\\.go$" $test ".dir/x.go" file1
665 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
666 regsub "\\.go$" $test ".dir/y.go" file2
668 file delete "[file rootname [file tail $file1]].o"
669 set runtests $hold_runtests
670 } elseif { [string match "// true*" $test_line] } {
671 # Not a real test, just ignore.
672 } elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
673 && $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
674 && $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
675 && $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
676 && $test_line5 == "// \$L bug2.\$A &&" \
677 && [string match "// ./\$A.out || echo BUG*" $test_line6] } {
678 set hold_runtests $runtests
679 set runtests "go-test.exp"
680 set dg-do-what-default "assemble"
681 regsub "\\.go$" $test ".dir/bug0.go" file0
682 dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
683 set ofile0 "[file rootname [file tail $file0]].o"
684 regsub "\\.go$" $test ".dir/bug1.go" file1
685 dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
686 set ofile1 "[file rootname [file tail $file1]].o"
687 regsub "\\.go$" $test ".dir/bug2.go" file2
688 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
689 set ofile2 "[file rootname [file tail $file2]].o"
690 regsub "\\.go$" $test ".dir/bug3.go" file3
692 set output_file "./[file rootname [file tail $test]].exe"
693 set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
694 $output_file "executable" "$DEFAULT_GOCFLAGS"]
695 set comp-output [go-dg-prune $target_triplet $comp_output]
696 if [string match "" $comp_output] {
697 set result [go_load "$output_file" "" ""]
698 set status [lindex $result 0]
701 verbose -log $comp_output
704 file delete $ofile0 $ofile1 $ofile2 $output_file
705 set runtests $hold_runtests
706 } elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
707 set hold_runtests $runtests
708 set runtests "go-test.exp"
709 set dg-do-what-default "assemble"
710 regsub "/\[^/\]*$" $test "/import2.go" file1
711 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
712 set ofile1 "[file rootname [file tail $file1]].o"
713 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
715 set runtests $hold_runtests
716 } elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
717 set hold_runtests $runtests
718 set runtests "go-test.exp"
719 set dg-do-what-default "assemble"
720 regsub "/\[^/\]*$" $test "/ddd2.go" file1
721 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
722 set ofile1 "[file rootname [file tail $file1]].o"
723 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
724 set ofile2 "[file rootname [file tail $test]].o"
725 set output_file "./[file rootname [file tail $test]].exe"
726 set comp_output [go_target_compile "$ofile1 $ofile2" \
727 $output_file "executable" "$DEFAULT_GOCFLAGS"]
728 set comp_output [go-dg-prune $target_triplet $comp_output]
729 if [string match "" $comp_output] {
730 set result [go_load "$output_file" "" ""]
731 set status [lindex $result 0]
734 verbose -log $comp_output
737 file delete $ofile1 $ofile2 $output_file
738 set runtests $hold_runtests
739 } elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
740 regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
741 set output_file "./[file rootname [file tail $test]].o"
742 set comp_output [go_target_compile "$test $test2" \
743 $output_file "executable" "$DEFAULT_GOCFLAGS"]
744 set comp_output [go-dg-prune $target_triplet $comp_output]
745 if [string match "" $comp_output] {
746 set result [go_load "$output_file" "" ""]
747 set status [lindex $result 0]
750 verbose -log $comp_output
753 file delete $output_file
754 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
755 && $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
756 && $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
757 && $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
758 set go_execute_args ""
759 set hold_runtests $runtests
760 set runtests "go-test.exp"
761 set dg-do-what-default "link"
762 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
763 set output_file "./[file rootname [file tail $test]].exe"
765 if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
766 fail "$name execution 0"
768 pass "$name execution 0"
770 go-torture-execute "./tmp.go"
772 if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
773 fail "$name execution 1"
775 pass "$name execution 1"
778 if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
779 fail "$name execution 2"
781 pass "$name execution 2"
786 file delete $output_file
787 set runtests $hold_runtests
788 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
789 && $test_line2 == "// errchk \$G -e tmp.go" } {
790 set go_execute_args ""
791 set hold_runtests $runtests
792 set runtests "go-test.exp"
793 set dg-do-what-default "link"
794 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
795 set output_file "./[file rootname [file tail $test]].exe"
797 if { [catch "exec $output_file >tmp.go"] != 0 } {
798 fail "$name execution"
800 pass "$name execution"
805 file delete $output_file
806 set runtests $hold_runtests
807 } elseif { [string match \
808 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
810 set hold_runtests $runtests
811 set runtests "go-test.exp"
812 set dg-do-what-default "assemble"
813 regsub "\\.go$" $test ".dir/p.go" file1
814 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
815 set ofile1 "[file rootname [file tail $file1]].o"
816 regsub "\\.go$" $test ".dir/main.go" file2
817 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
818 set ofile2 "[file rootname [file tail $file2]].o"
819 set output_file "./[file rootname [file tail $test]].exe"
820 set comp_output [go_target_compile "$ofile1 $ofile2" \
821 $output_file "executable" "$DEFAULT_GOCFLAGS"]
822 set comp_output [go-dg-prune $target_triplet $comp_output]
823 if [string match "" $comp_output] {
825 set result [go_load "$output_file" "" ""]
826 set status [lindex $result 0]
829 verbose -log $comp_output
832 file delete $ofile1 $ofile2 $output_file
833 set runtests $hold_runtests
834 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
835 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
836 set go_execute_args ""
837 set hold_runtests $runtests
838 set runtests "go-test.exp"
839 set dg-do-what-default "link"
840 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
841 set output_file "./[file rootname [file tail $test]].exe"
842 set base "[file rootname [file tail $test]]"
844 if { [catch "exec $output_file > $base-out.go"] != 0 } {
845 fail "$name execution"
847 pass "$name execution"
848 file delete $base-out.x
849 go-torture-execute "./$base-out.go"
851 # file delete $base-out.go
853 file delete $output_file
854 set runtests $hold_runtests
855 } elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
856 regsub "\\.go$" $test ".dir/a.go" file1
857 regsub "\\.go$" $test ".dir/b.go" file2
858 errchk "$file1" "$file2"
859 } elseif { $test_line == "// # generated by cmplxdivide.c" } {
861 } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
862 || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
863 # These tests import the same package under two different
864 # names, which gccgo does not support.
865 } elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo FAIL || true" } {
866 # This tests whether initializers are written out
867 # statically. gccgo does not provide a way to test that,
868 # as an initializer will be generated for any code which
869 # has global variables which need to be registered as GC
872 clone_output "$name: unrecognized test line: $test_line"
876 set go_execute_args ""
879 set dg-do-what-default ${saved-dg-do-what-default}
880 set TORTURE_OPTIONS $saved_torture_options