1 # Copyright (C) 2009, 2010, 2011, 2012 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 filecmp { file1 file2 testname } {
39 set f1 [open $file1 r]
40 set f2 [open $file2 r]
42 while { [gets $f1 line1] >= 0 } {
43 if { [gets $f2 line2] < 0 } {
44 verbose -log "output mismatch: $file2 shorter than $file1"
48 if { $line1 != $line2 } {
49 verbose -log "output mismatch comparing $file1 and $file2"
50 verbose -log "expected \"$line1\""
51 verbose -log "got \"$line2\""
56 if { [gets $f2 line2] >= 0 } {
57 verbose -log "output mismatch: $file1 shorter than $file2"
70 proc errchk { test opts } {
71 global dg-do-what-default
72 global DEFAULT_GOCFLAGS
75 set saved-dg-do-what-default ${dg-do-what-default}
76 set dg-do-what-default compile
77 set filename [file tail $test]
78 if { "$filename" == "$test" } {
79 set filename "errchk-$filename"
81 set fdin [open $test r]
82 fconfigure $fdin -encoding binary
83 set fdout [open $filename w]
84 fconfigure $fdout -encoding binary
85 while { [gets $fdin copy_line] >= 0 } {
86 if [string match "*////*" $copy_line] {
87 puts $fdout $copy_line
90 regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
91 if [string match "*dg-error*\\\[*" $out_line] {
92 set index [string first "dg-error" $out_line]
93 regsub -start $index -all "\\\\\\\[" $out_line "\\\\\\\\\\\[" out_line
95 if [string match "*dg-error*\\\]*" $out_line] {
96 set index [string first "dg-error" $out_line]
97 regsub -start $index -all "\\\\\\\]" $out_line "\\\\\\\\\\\]" out_line
99 if [string match "*dg-error*.\**" $out_line] {
100 # I worked out the right number of backslashes by
101 # experimentation, not analysis.
102 regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
104 if [string match "*dg-error*\\\[?\\\]*" $out_line] {
105 set index [string first "dg-error" $out_line]
106 regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
108 if [string match "*dg-error*\{*" $out_line] {
109 set index [string first "dg-error" $out_line]
110 regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
112 if [string match "*dg-error*\}*\}" $out_line] {
113 set index [string first "dg-error" $out_line]
114 regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
116 if [string match "*dg-error*\(*" $out_line] {
117 set index [string first "dg-error" $out_line]
118 regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
120 if [string match "*dg-error*\)*\}" $out_line] {
121 set index [string first "dg-error" $out_line]
122 regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
124 # Special case for bug332, in which the error message wants to
125 # match the file name, which is not what dg-error expects.
126 if [string match "*dg-error*bug332*" $out_line] {
127 set index [string first "dg-error" $out_line]
128 regsub -start $index "bug332" $out_line "undefined type" out_line
130 puts $fdout $out_line
135 set hold_runtests $runtests
136 set runtests "go-test.exp"
137 go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
138 set runtests $hold_runtests
140 file delete $filename
141 set dg-do-what-default ${saved-dg-do-what-default}
144 # This is an execution test which should fail.
145 proc go-execute-xfail { test } {
146 global DEFAULT_GOCFLAGS
149 set filename [file tail $test]
150 set fdin [open $test r]
151 set fdout [open $filename w]
152 puts $fdout "// { dg-do run { xfail *-*-* } }"
153 while { [gets $fdin copy_line] >= 0 } {
154 puts $fdout $copy_line
159 set hold_runtests $runtests
160 set runtests "go-test.exp"
161 go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
162 set runtests $hold_runtests
164 file delete $filename
167 # N.B. Keep in sync with libgo/configure.ac.
168 proc go-set-goarch { } {
169 global target_triplet
171 switch -glob $target_triplet {
183 if [check_effective_target_ia32] {
190 if [check_no_compiler_messages mipso32 assembly {
191 #if _MIPS_SIM != _ABIO32
196 } elseif [check_no_compiler_messages mipsn32 assembly {
197 #if _MIPS_SIM != _ABIN32
202 } elseif [check_no_compiler_messages mipsn64 assembly {
203 #if _MIPS_SIM != _ABI64
208 } elseif [check_no_compiler_messages mipso64 assembly {
209 #if _MIPS_SIM != _ABIO64
215 perror "$target_triplet: unrecognized MIPS ABI"
220 if [check_effective_target_ilp32] {
227 perror "$target_triplet: unhandled architecture"
231 verbose -log "Setting GOARCH=$goarch" 1
232 setenv GOARCH $goarch
235 proc go-gc-tests { } {
238 global GCC_UNDER_TEST
240 global TORTURE_OPTIONS
241 global dg-do-what-default
242 global go_compile_args
243 global go_execute_args
244 global target_triplet
246 # If a testcase doesn't have special options, use these.
247 global DEFAULT_GOCFLAGS
248 if ![info exists DEFAULT_GOCFLAGS] {
249 set DEFAULT_GOCFLAGS " -pedantic-errors"
253 lappend options "additional_flags=$DEFAULT_GOCFLAGS"
255 # Set GOARCH for tests that need it.
258 # Running all the torture options takes too long and, since the
259 # frontend ignores the standard options, it doesn't significantly
261 set saved_torture_options $TORTURE_OPTIONS
262 set TORTURE_OPTIONS [ list { -O2 -g }]
264 set saved-dg-do-what-default ${dg-do-what-default}
268 set tests [lsort [find $srcdir/$subdir *.go]]
269 foreach test $tests {
270 if ![runtest_file_p $runtests $test] {
274 # Skip the files in bench; they are not tests.
275 if [string match "*go.test/test/bench/*" $test] {
279 # Skip files in sub-subdirectories: they are components of
281 if [string match "*go.test/test/*/*/*" $test] {
285 set name [dg-trim-dirname $srcdir $test]
287 # Skip certain tests if target is RTEMS OS.
288 if [istarget "*-*-rtems*"] {
289 if { [string match "*go.test/test/args.go" $test] \
290 || [string match "*go.test/test/env.go" $test] } {
291 untested "$name: uses the command-line or environment variables"
295 if { [string match "*go.test/test/stack.go" $test] \
296 || [string match "*go.test/test/peano.go" $test] \
297 || [string match "*go.test/test/chan/goroutines.go" $test] } {
298 untested "$name: has very high memory requirement"
303 # Handle certain tests in a target-dependant way.
304 if [istarget "alpha*-*-*"] {
305 if { [string match "*go.test/test/nilptr.go" $test] } {
306 go-execute-xfail $test
311 if { [string match "*bug347*" $test] \
312 || [string match "*bug348*" $test] } {
313 # These bugs rely on runtime.Caller which currently fails.
318 if { [file tail $test] == "init1.go" } {
319 # This tests whether GC runs during init, which for gccgo
320 # it currently does not.
325 if { [file tail $test] == "closure.go" } {
326 # This tests whether function closures do any memory
327 # allocation, which for gccgo they currently do.
332 set fd [open $test r]
337 if { [gets $fd test_line] < 0 } {
339 clone_output "$test: could not read first line"
345 if { [ string match "*nacl*exit 0*" $test_line ] \
346 || [ string match "*exit 0*nacl*" $test_line ] \
347 || [ string match "*Android*exit 0*" $test_line ] \
348 || [ string match "*exit 0*Android*" $test_line ] \
349 || [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
356 if { $lines_ok == 0 } {
361 set test_line1 $test_line
363 while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
364 set lineno [expr $lineno + 1]
365 if { [eval "gets \$fd test_line$lineno"] < 0 } {
367 clone_output "$test: could not read line $lineno"
373 if { $lines_ok == 0 } {
379 set go_compile_args ""
380 set go_execute_args ""
381 if { [regexp ".*\\\$A.out (\[^|&>2\].*)\$" $test_line match progargs] } {
382 set go_execute_args $progargs
383 verbose -log "$test: go_execute_args is $go_execute_args"
384 set index [string last " $progargs" $test_line]
385 set test_line [string replace $test_line $index end]
386 } elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
387 && [getenv GCCGO_RUN_ALL_TESTS] == "" } {
388 # goroutines.go spawns by default 10000 threads, which is too much
390 if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
391 set go_execute_args 64
392 } elseif { ![is_remote host] && ![is_remote target] } {
393 # When using low ulimit -u limit, use maximum of
394 # a quarter of that limit and 10000 even when running expensive
395 # tests, otherwise parallel tests might fail after fork failures.
396 set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
397 if { [string is integer -strict $nproc] } {
398 set nproc [expr $nproc / 4]
399 if { $nproc > 10000 } { set nproc 10000 }
400 if { $nproc < 16 } { set nproc 16 }
401 set go_execute_args $nproc
404 if { "$go_execute_args" != "" } {
405 verbose -log "$test: go_execute_args is $go_execute_args"
409 if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
410 && $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
411 # 64bit.go is a special case.
412 set go_execute_args ""
413 set hold_runtests $runtests
414 set runtests "go-test.exp"
415 set dg-do-what-default "link"
416 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
417 set output_file "./[file rootname [file tail $test]].exe"
418 set base "[file rootname [file tail $test]]"
420 if { [catch "exec $output_file >$base-out.go"] != 0 } {
421 fail "$name execution"
423 pass "$name execution"
424 file delete $base-out.x
425 go-torture-execute "./$base-out.go"
427 file delete $base-out.go
429 file delete $output_file
430 set runtests $hold_runtests
431 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
432 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
433 || $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
434 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
436 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
439 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
442 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
445 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
448 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
450 # This is a vanilla execution test.
451 go-torture-execute $test
452 file delete core [glob -nocomplain core.*]
453 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
454 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
455 || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
456 # This is an execution test for which we need to check the
458 set hold_runtests $runtests
459 set runtests "go-test.exp"
460 set dg-do-what-default "link"
461 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
462 set output_file "./[file rootname [file tail $test]].exe"
463 set base "[file rootname [file tail $test]]"
465 verbose -log "$output_file >$base.p 2>&1"
466 if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } {
467 verbose -log $catcherr
468 fail "$name execution"
469 untested "$name compare"
471 pass "$name execution"
472 regsub "\\.go$" $test ".out" expect
473 filecmp $expect $base.p "$name compare"
477 untested "$name execution"
478 untested "$name compare"
480 set runtests $hold_runtests
481 } elseif { [string match \
482 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
484 || [string match "// \$G \$F.go && \$L \$F.\$A #*" \
486 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
487 # This is a vanilla compile and link test.
488 set dg-do-what-default "link"
489 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
490 } elseif { [string match "// \$G \$D/\$F.go" $test_line] \
491 || [string match "// \$G \$D/\$F.go || echo BUG*" \
493 || [string match "// \$G \$D/\$F.go || echo \"Bug*" \
495 || [string match "// \$G \$D/\$F.go || echo \"Issue*" \
497 || [string match "// \$G \$F.go || echo BUG*" \
499 || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
501 || $test_line == "// echo bug395 is broken # takes 90+ seconds to break" } {
502 # This is a vanilla compile test.
503 set dg-do-what-default "assemble"
504 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
505 } elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
507 || $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
508 || $test_line == "// ! \$G \$D/\$F.go" \
509 || $test_line == "// ! \$G \$F.go" \
510 || [string match "// ! \$G \$D/\$F.go || echo BUG*" \
512 # This is a compile test which should fail.
513 set dg-do-what-default "assemble"
515 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
516 } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
518 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
520 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
522 || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
523 && $test_line2 == "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
524 go-execute-xfail $test
525 } elseif { [string match "// errchk \$G \$F.go" $test_line] \
526 || [string match "// errchk \$G -e \$F.go" $test_line] \
527 || [string match "// errchk \$G \$D/\$F.go" $test_line] \
528 || [string match "//errchk \$G \$D/\$F.go" $test_line] \
529 || [string match "// errchk \$G -e \$D/\$F.go" \
531 || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
532 || [string match "// ! errchk \$G -e \$D/\$F.go" \
534 || [string match "// errchk \$G \$F.go || true" \
536 || [string match "// errchk \$G \$D/\$F.go || true" \
538 || [string match "// errchk \$G -e \$D/\$F.go || true" \
540 || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
543 } elseif { [string match \
544 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
547 "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
550 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
554 } elseif { [string match \
555 "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
560 set hold_runtests $runtests
561 set runtests "go-test.exp"
562 set dg-do-what-default "assemble"
563 regsub "\\.go$" $test ".dir/$name1" file1
564 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
565 regsub "\\.go$" $test ".dir/$name2" file2
566 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
567 file delete "[file rootname [file tail $file1]].o"
568 set runtests $hold_runtests
569 } elseif { [string match \
570 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
573 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
576 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
579 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
582 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
586 } elseif { [string match \
587 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
591 } elseif { [string match \
592 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
596 } elseif { [string match \
597 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
602 set hold_runtests $runtests
603 set runtests "go-test.exp"
604 set dg-do-what-default "assemble"
605 regsub "\\.go$" $test ".dir/$name1" file1
606 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
607 regsub "\\.go$" $test ".dir/$name2" file2
609 file delete "[file rootname [file tail $file1]].o"
610 set runtests $hold_runtests
611 } elseif { [string match \
612 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
614 set hold_runtests $runtests
615 set runtests "go-test.exp"
616 set dg-do-what-default "assemble"
617 regsub "\\.go$" $test "1.go" file1
618 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
620 file delete "[file rootname [file tail $file1]].o"
621 set runtests $hold_runtests
622 } elseif { [string match \
623 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
625 set hold_runtests $runtests
626 set runtests "go-test.exp"
627 set dg-do-what-default "assemble"
628 regsub "\\.go$" $test ".dir/bug0.go" file1
629 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
630 regsub "\\.go$" $test ".dir/bug1.go" file2
632 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
633 file delete "[file rootname [file tail $file1]].o"
634 set runtests $hold_runtests
635 } elseif { [string match \
636 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
638 set hold_runtests $runtests
639 set runtests "go-test.exp"
640 set dg-do-what-default "assemble"
641 regsub "\\.go$" $test ".dir/bug0.go" file1
642 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
643 regsub "\\.go$" $test ".dir/bug1.go" file2
644 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
645 regsub "\\.go$" $test ".dir/bug2.go" file3
647 dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
648 file delete "[file rootname [file tail $file1]].o"
649 file delete "[file rootname [file tail $file2]].o"
650 set runtests $hold_runtests
651 } elseif { [string match \
652 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
654 set hold_runtests $runtests
655 set runtests "go-test.exp"
656 set dg-do-what-default "assemble"
657 regsub "\\.go$" $test ".dir/bug0.go" file1
658 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
659 regsub "\\.go$" $test ".dir/bug1.go" file2
660 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
661 regsub "\\.go$" $test ".dir/bug2.go" file3
663 file delete "[file rootname [file tail $file1]].o"
664 file delete "[file rootname [file tail $file2]].o"
665 set runtests $hold_runtests
666 } elseif { [string match \
667 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
670 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
673 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
677 } elseif { [string match \
678 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
683 set hold_runtests $runtests
684 set runtests "go-test.exp"
685 set dg-do-what-default "assemble"
686 regsub "\\.go$" $test ".dir/$name1" file1
687 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
688 set ofile1 "[file rootname [file tail $file1]].o"
689 regsub "\\.go$" $test ".dir/$name2" file2
690 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
691 set ofile2 "[file rootname [file tail $file2]].o"
692 set dg-do-what-default "link"
693 set output_file "./[file rootname [file tail $test]].exe"
694 set comp_output [go_target_compile "$ofile1 $ofile2" \
695 $output_file "executable" "$options"]
696 set comp_output [go-dg-prune $target_triplet $comp_output]
697 verbose -log $comp_output
698 set result [go_load "$output_file" "" ""]
699 set status [lindex $result 0]
701 file delete $ofile1 $ofile2 $output_file
702 set runtests $hold_runtests
703 } elseif { [string match \
704 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
706 set hold_runtests $runtests
707 set runtests "go-test.exp"
708 set dg-do-what-default "assemble"
709 regsub "\\.go$" $test ".dir/a.go" file1
710 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
711 set ofile1 "[file rootname [file tail $file1]].o"
712 regsub "\\.go$" $test ".dir/b.go" file2
713 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
714 set ofile2 "[file rootname [file tail $file2]].o"
715 dg-test -keep-output "$test" "-O" "-w $DEFAULT_GOCFLAGS"
716 set ofile3 "[file rootname [file tail $test]].o"
717 set dg-do-what-default "link"
718 set output_file "./[file rootname [file tail $test]].exe"
719 set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
720 $output_file "executable" "$options"]
721 set comp_output [go-dg-prune $target_triplet $comp_output]
722 if [string match "" $comp_output] {
725 verbose -log $comp_output
728 file delete $ofile1 $ofile2 $ofile3 $output_file
729 set runtests $hold_runtests
730 } elseif { [string match \
731 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
733 set hold_runtests $runtests
734 set runtests "go-test.exp"
735 set dg-do-what-default "assemble"
736 regsub "/\[^/\]*$" $test "/embed0.go" file1
737 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
738 set ofile1 "[file rootname [file tail $file1]].o"
739 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
740 set ofile2 "[file rootname [file tail $test]].o"
741 set output_file "./[file rootname [file tail $test]].exe"
742 set comp_output [go_target_compile "$ofile1 $ofile2" \
743 $output_file "executable" "$options"]
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 $ofile1 $ofile2 $output_file
754 set runtests $hold_runtests
755 } elseif { [string match \
756 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
759 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
762 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
766 } elseif { [string match \
767 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
772 set hold_runtests $runtests
773 set runtests "go-test.exp"
774 set dg-do-what-default "assemble"
775 regsub "\\.go$" $test ".dir/$name1" file1
776 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
777 set ofile1 "[file rootname [file tail $file1]].o"
778 regsub "\\.go$" $test ".dir/$name2" file2
779 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
780 set ofile2 "[file rootname [file tail $file2]].o"
781 set dg-do-what-default "link"
782 set output_file "./[file rootname [file tail $file2]].exe"
783 set comp_output [go_target_compile "$ofile1 $ofile2" \
784 $output_file "executable" "$options"]
785 set comp_output [go-dg-prune $target_triplet $comp_output]
786 if [string match "" $comp_output] {
787 set result [go_load "$output_file" "" ""]
788 set status [lindex $result 0]
791 verbose -log $comp_output
794 file delete $ofile1 $ofile2 $output_file
795 set runtests $hold_runtests
796 } elseif { [string match \
797 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
799 set hold_runtests $runtests
800 set runtests "go-test.exp"
801 set dg-do-what-default "assemble"
802 regsub "\\.go$" $test ".dir/chanbug.go" file1
803 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
804 regsub "\\.go$" $test ".dir/chanbug2.go" file2
805 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
806 file delete "[file rootname [file tail $file1]].o"
807 set runtests $hold_runtests
808 } elseif { [string match \
809 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
811 set dg-do-what-default "assemble"
813 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
814 } elseif { [string match \
815 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
817 set hold_runtests $runtests
818 set runtests "go-test.exp"
819 set dg-do-what-default "assemble"
820 regsub "\\.go$" $test ".dir/x.go" file1
821 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
822 regsub "\\.go$" $test ".dir/y.go" file2
824 file delete "[file rootname [file tail $file1]].o"
825 set runtests $hold_runtests
826 } elseif { "$test_line" == "" || [string match "// true*" $test_line] } {
827 # Not a real test, just ignore.
828 } elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
829 && $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
830 && $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
831 && $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
832 && $test_line5 == "// \$L bug2.\$A &&" \
833 && [string match "// ./\$A.out || echo BUG*" $test_line6] } {
834 set hold_runtests $runtests
835 set runtests "go-test.exp"
836 set dg-do-what-default "assemble"
837 regsub "\\.go$" $test ".dir/bug0.go" file0
838 dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
839 set ofile0 "[file rootname [file tail $file0]].o"
840 regsub "\\.go$" $test ".dir/bug1.go" file1
841 dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
842 set ofile1 "[file rootname [file tail $file1]].o"
843 regsub "\\.go$" $test ".dir/bug2.go" file2
844 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
845 set ofile2 "[file rootname [file tail $file2]].o"
846 regsub "\\.go$" $test ".dir/bug3.go" file3
848 set output_file "./[file rootname [file tail $test]].exe"
849 set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
850 $output_file "executable" "$options"]
851 set comp-output [go-dg-prune $target_triplet $comp_output]
852 if [string match "" $comp_output] {
853 set result [go_load "$output_file" "" ""]
854 set status [lindex $result 0]
857 verbose -log $comp_output
860 file delete $ofile0 $ofile1 $ofile2 $output_file
861 set runtests $hold_runtests
862 } elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
863 || $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
864 if { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
865 set name1 "import2.go"
866 } elseif { $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
867 set name1 "recursive1.go"
869 set hold_runtests $runtests
870 set runtests "go-test.exp"
871 set dg-do-what-default "assemble"
872 regsub "/\[^/\]*$" $test "/${name1}" file1
873 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
874 set ofile1 "[file rootname [file tail $file1]].o"
875 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
877 set runtests $hold_runtests
878 } elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
879 set hold_runtests $runtests
880 set runtests "go-test.exp"
881 set dg-do-what-default "assemble"
882 regsub "/\[^/\]*$" $test "/ddd2.go" file1
883 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
884 set ofile1 "[file rootname [file tail $file1]].o"
885 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
886 set ofile2 "[file rootname [file tail $test]].o"
887 set output_file "./[file rootname [file tail $test]].exe"
888 set comp_output [go_target_compile "$ofile1 $ofile2" \
889 $output_file "executable" "$options"]
890 set comp_output [go-dg-prune $target_triplet $comp_output]
891 if [string match "" $comp_output] {
892 set result [go_load "$output_file" "" ""]
893 set status [lindex $result 0]
896 verbose -log $comp_output
899 file delete $ofile1 $ofile2 $output_file
900 set runtests $hold_runtests
901 } elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
902 regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
903 set output_file "./[file rootname [file tail $test]].o"
904 set comp_output [go_target_compile "$test $test2" \
905 $output_file "executable" "$options"]
906 set comp_output [go-dg-prune $target_triplet $comp_output]
907 if [string match "" $comp_output] {
908 set result [go_load "$output_file" "" ""]
909 set status [lindex $result 0]
912 verbose -log $comp_output
915 file delete $output_file
916 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
917 && $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
918 && $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
919 && $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
920 set go_execute_args ""
921 set hold_runtests $runtests
922 set runtests "go-test.exp"
923 set dg-do-what-default "link"
924 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
925 set output_file "./[file rootname [file tail $test]].exe"
927 if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
928 fail "$name execution 0"
930 pass "$name execution 0"
932 go-torture-execute "./tmp.go"
934 if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
935 fail "$name execution 1"
937 pass "$name execution 1"
940 if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
941 fail "$name execution 2"
943 pass "$name execution 2"
948 file delete $output_file
949 set runtests $hold_runtests
950 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
951 && $test_line2 == "// errchk \$G -e tmp.go" } {
952 set go_execute_args ""
953 set hold_runtests $runtests
954 set runtests "go-test.exp"
955 set dg-do-what-default "link"
956 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
957 set output_file "./[file rootname [file tail $test]].exe"
959 if { [catch "exec $output_file >tmp.go"] != 0 } {
960 fail "$name execution"
962 pass "$name execution"
967 file delete $output_file
968 set runtests $hold_runtests
969 } elseif { [string match \
970 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
972 set hold_runtests $runtests
973 set runtests "go-test.exp"
974 set dg-do-what-default "assemble"
975 regsub "\\.go$" $test ".dir/p.go" file1
976 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
977 set ofile1 "[file rootname [file tail $file1]].o"
978 regsub "\\.go$" $test ".dir/main.go" file2
979 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
980 set ofile2 "[file rootname [file tail $file2]].o"
981 set output_file "./[file rootname [file tail $test]].exe"
982 set comp_output [go_target_compile "$ofile1 $ofile2" \
983 $output_file "executable" "$options"]
984 set comp_output [go-dg-prune $target_triplet $comp_output]
985 if [string match "" $comp_output] {
987 set result [go_load "$output_file" "" ""]
988 set status [lindex $result 0]
991 verbose -log $comp_output
994 file delete $ofile1 $ofile2 $output_file
995 set runtests $hold_runtests
996 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
997 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
998 set go_execute_args ""
999 set hold_runtests $runtests
1000 set runtests "go-test.exp"
1001 set dg-do-what-default "link"
1002 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1003 set output_file "./[file rootname [file tail $test]].exe"
1004 set base "[file rootname [file tail $test]]"
1006 if { [catch "exec $output_file > $base-out.go"] != 0 } {
1007 fail "$name execution"
1009 pass "$name execution"
1010 file delete $base-out.x
1011 # This testcase takes long time to compile.
1012 dg-timeout-factor list 4 { target alpha*-*-* }
1013 go-torture-execute "./$base-out.go"
1016 file delete $base-out.go
1018 file delete $output_file
1019 set runtests $hold_runtests
1020 } elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1021 regsub "\\.go$" $test ".dir/a.go" file1
1022 regsub "\\.go$" $test ".dir/b.go" file2
1023 errchk "$file1" "$file2"
1024 } elseif { $test_line == "// \$G \$D/\$F.go \$D/z*.go && \$L \$F.\$A && ./\$A.out" } {
1025 set dir [file dirname $test]
1026 set go_compile_args [glob $dir/z*.go]
1027 go-torture-execute $test
1028 } elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1029 && $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1030 && $test_line3 == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1031 set hold_runtests $runtests
1032 set runtests "go-test.exp"
1033 set dg-do-what-default "assemble"
1034 regsub "\\.go$" $test ".dir/pkg.go" file1
1035 dg-test -keep-output $file1 "" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1036 set ofile1 "[file rootname [file tail $file1]].o"
1037 file rename -force $ofile1 slow.o
1038 dg-test -keep-output $file1 "-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1039 file rename -force $ofile1 fast.o
1040 set ofile2 "[file rootname [file tail $test]].o"
1041 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1042 set output_file "./[file rootname [file tail $test]].exe"
1043 set comp_output [go_target_compile "$ofile2 slow.o fast.o" \
1044 $output_file "executable" "$options"]
1045 set comp_output [go-dg-prune $target_triplet $comp_output]
1046 if [string match "" $comp_output] {
1047 set result [go_load "$output_file" "" ""]
1048 set status [lindex $result 0]
1051 verbose -log $comp_output
1054 file delete slow.o fast.o $ofile2 $output_file
1055 set runtests $hold_runtests
1056 } elseif { [string match \
1057 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1059 set hold_runtests $runtests
1060 set runtests "go-test.exp"
1061 set dg-do-what-default "assemble"
1062 regsub "\\.go$" $test ".dir/pkg.go" file1
1063 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
1064 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
1065 file delete "[file rootname [file tail $file1]].o"
1066 set runtests $hold_runtests
1067 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
1068 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out" } {
1069 set go_execute_args ""
1070 set hold_runtests $runtests
1071 set runtests "go-test.exp"
1072 set dg-do-what-default "link"
1073 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1074 set output_file "./[file rootname [file tail $test]].exe"
1075 set base "[file rootname [file tail $test]]"
1077 if { [catch "exec $output_file >$base-out.go"] != 0 } {
1078 fail "$name execution"
1080 pass "$name execution"
1081 file delete $base-out.x
1082 go-torture-execute "./$base-out.go"
1084 file delete $base-out.go
1086 file delete $output_file
1087 set runtests $hold_runtests
1088 } elseif { $test_line == "// # generated by cmplxdivide.c" } {
1090 } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1091 || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1092 # These tests import the same package under two different
1093 # names, which gccgo does not support.
1094 } elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1095 # This tests whether initializers are written out
1096 # statically. gccgo does not provide a way to test that,
1097 # as an initializer will be generated for any code which
1098 # has global variables which need to be registered as GC
1100 } elseif { $test_line == "// errchk -0 \$G -m -l \$D/\$F.go" } {
1101 # This tests debug output of the gc compiler, which is
1102 # meaningless for gccgo.
1103 } elseif { $test_line == "// \[ \$O == 6 \] || errchk \$G -e \$D/\$F.go" \
1104 || $test_line == "// \[ \$O != 6 \] || errchk \$G -e \$D/\$F.go" } {
1105 # This tests specific handling of the gc compiler on types
1106 # that are too large. It is target specific in a way I
1107 # haven't bothered to check for here.
1109 clone_output "$name: unrecognized test line: $test_line"
1113 set go_compile_args ""
1114 set go_execute_args ""
1117 set dg-do-what-default ${saved-dg-do-what-default}
1118 set TORTURE_OPTIONS $saved_torture_options