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
36 load_lib target-supports.exp
39 proc filecmp { file1 file2 testname } {
40 set f1 [open $file1 r]
41 set f2 [open $file2 r]
43 while { [gets $f1 line1] >= 0 } {
44 if { [gets $f2 line2] < 0 } {
45 verbose -log "output mismatch: $file2 shorter than $file1"
49 if { $line1 != $line2 } {
50 verbose -log "output mismatch comparing $file1 and $file2"
51 verbose -log "expected \"$line1\""
52 verbose -log "got \"$line2\""
57 if { [gets $f2 line2] >= 0 } {
58 verbose -log "output mismatch: $file1 shorter than $file2"
71 proc errchk { test opts } {
72 global dg-do-what-default
73 global DEFAULT_GOCFLAGS
76 set saved-dg-do-what-default ${dg-do-what-default}
77 set dg-do-what-default compile
78 set filename [file tail $test]
79 if { "$filename" == "$test" } {
80 set filename "errchk-$filename"
82 set fdin [open $test r]
83 fconfigure $fdin -encoding binary
84 set fdout [open $filename w]
85 fconfigure $fdout -encoding binary
86 while { [gets $fdin copy_line] >= 0 } {
87 if [string match "*////*" $copy_line] {
88 puts $fdout $copy_line
91 regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
92 if [string match "*dg-error*\\\[*" $out_line] {
93 set index [string first "dg-error" $out_line]
94 regsub -start $index -all "\\\\\\\[" $out_line "\\\\\\\\\\\[" out_line
96 if [string match "*dg-error*\\\]*" $out_line] {
97 set index [string first "dg-error" $out_line]
98 regsub -start $index -all "\\\\\\\]" $out_line "\\\\\\\\\\\]" out_line
100 if [string match "*dg-error*.\**" $out_line] {
101 # I worked out the right number of backslashes by
102 # experimentation, not analysis.
103 regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
105 if [string match "*dg-error*\\\[?\\\]*" $out_line] {
106 set index [string first "dg-error" $out_line]
107 regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
109 if [string match "*dg-error*\{*" $out_line] {
110 set index [string first "dg-error" $out_line]
111 regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
113 if [string match "*dg-error*\}*\}" $out_line] {
114 set index [string first "dg-error" $out_line]
115 regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
117 if [string match "*dg-error*\(*" $out_line] {
118 set index [string first "dg-error" $out_line]
119 regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
121 if [string match "*dg-error*\)*\}" $out_line] {
122 set index [string first "dg-error" $out_line]
123 regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
125 # Special case for bug332, in which the error message wants to
126 # match the file name, which is not what dg-error expects.
127 if [string match "*dg-error*bug332*" $out_line] {
128 set index [string first "dg-error" $out_line]
129 regsub -start $index "bug332" $out_line "undefined type" out_line
131 puts $fdout $out_line
136 set hold_runtests $runtests
137 set runtests "go-test.exp"
138 go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
139 set runtests $hold_runtests
141 file delete $filename
142 set dg-do-what-default ${saved-dg-do-what-default}
145 # This is an execution test which should fail.
146 proc go-execute-xfail { test } {
147 global DEFAULT_GOCFLAGS
150 set filename [file tail $test]
151 set fdin [open $test r]
152 set fdout [open $filename w]
153 puts $fdout "// { dg-do run { xfail *-*-* } }"
154 while { [gets $fdin copy_line] >= 0 } {
155 puts $fdout $copy_line
160 set hold_runtests $runtests
161 set runtests "go-test.exp"
162 go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
163 set runtests $hold_runtests
165 file delete $filename
168 # N.B. Keep in sync with libgo/configure.ac.
169 proc go-set-goarch { } {
170 global target_triplet
172 switch -glob $target_triplet {
184 if [check_effective_target_ia32] {
191 if [check_no_compiler_messages mipso32 assembly {
192 #if _MIPS_SIM != _ABIO32
197 } elseif [check_no_compiler_messages mipsn32 assembly {
198 #if _MIPS_SIM != _ABIN32
203 } elseif [check_no_compiler_messages mipsn64 assembly {
204 #if _MIPS_SIM != _ABI64
209 } elseif [check_no_compiler_messages mipso64 assembly {
210 #if _MIPS_SIM != _ABIO64
216 perror "$target_triplet: unrecognized MIPS ABI"
221 if [check_effective_target_ilp32] {
228 if [check_effective_target_ilp32] {
235 perror "$target_triplet: unhandled architecture"
239 verbose -log "Setting GOARCH=$goarch" 1
240 setenv GOARCH $goarch
243 proc go-gc-tests { } {
246 global GCC_UNDER_TEST
248 global TORTURE_OPTIONS
249 global dg-do-what-default
250 global go_compile_args
251 global go_execute_args
252 global target_triplet
254 # If a testcase doesn't have special options, use these.
255 global DEFAULT_GOCFLAGS
256 if ![info exists DEFAULT_GOCFLAGS] {
257 set DEFAULT_GOCFLAGS " -pedantic-errors"
261 lappend options "additional_flags=$DEFAULT_GOCFLAGS"
263 # Set GOARCH for tests that need it.
266 # Running all the torture options takes too long and, since the
267 # frontend ignores the standard options, it doesn't significantly
269 set saved_torture_options $TORTURE_OPTIONS
270 set TORTURE_OPTIONS [ list { -O2 -g }]
272 set saved-dg-do-what-default ${dg-do-what-default}
276 set tests [lsort [find $srcdir/$subdir *.go]]
277 foreach test $tests {
278 if ![runtest_file_p $runtests $test] {
282 # Skip the files in bench; they are not tests.
283 if [string match "*go.test/test/bench/*" $test] {
287 # Skip files in sub-subdirectories: they are components of
289 if [string match "*go.test/test/*/*/*" $test] {
293 set name [dg-trim-dirname $srcdir $test]
295 # Skip certain tests if target is RTEMS OS.
296 if [istarget "*-*-rtems*"] {
297 if { [string match "*go.test/test/args.go" $test] \
298 || [string match "*go.test/test/env.go" $test] } {
299 untested "$name: uses the command-line or environment variables"
303 if { [string match "*go.test/test/stack.go" $test] \
304 || [string match "*go.test/test/peano.go" $test] \
305 || [string match "*go.test/test/chan/goroutines.go" $test] } {
306 untested "$name: has very high memory requirement"
311 # Handle certain tests in a target-dependant way.
312 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] } {
313 if { [string match "*go.test/test/nilptr.go" $test] } {
319 if { [string match "*bug347*" $test] \
320 || [string match "*bug348*" $test] } {
321 # These bugs rely on runtime.Caller which currently fails.
326 if { [file tail $test] == "init1.go" } {
327 # This tests whether GC runs during init, which for gccgo
328 # it currently does not.
333 if { [file tail $test] == "closure.go" } {
334 # This tests whether function closures do any memory
335 # allocation, which for gccgo they currently do.
340 if { ( [file tail $test] == "select2.go" \
341 || [file tail $test] == "stack.go" ) \
342 && ! [check_effective_target_split_stack] } {
343 # chan/select2.go fails on targets without split stack,
344 # because they allocate a large stack segment that blows
345 # out the memory calculations.
350 set fd [open $test r]
355 if { [gets $fd test_line] < 0 } {
357 clone_output "$test: could not read first line"
363 if { [ string match "*nacl*exit 0*" $test_line ] \
364 || [ string match "*exit 0*nacl*" $test_line ] \
365 || [ string match "*Android*exit 0*" $test_line ] \
366 || [ string match "*exit 0*Android*" $test_line ] \
367 || [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
374 if { $lines_ok == 0 } {
379 set test_line1 $test_line
381 while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
382 set lineno [expr $lineno + 1]
383 if { [eval "gets \$fd test_line$lineno"] < 0 } {
385 clone_output "$test: could not read line $lineno"
391 if { $lines_ok == 0 } {
397 set go_compile_args ""
398 set go_execute_args ""
399 if { [regexp ".*\\\$A.out (\[^|&>2\].*)\$" $test_line match progargs] } {
400 set go_execute_args $progargs
401 verbose -log "$test: go_execute_args is $go_execute_args"
402 set index [string last " $progargs" $test_line]
403 set test_line [string replace $test_line $index end]
404 } elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
405 && [getenv GCCGO_RUN_ALL_TESTS] == "" } {
406 # goroutines.go spawns by default 10000 threads, which is too much
408 if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
409 set go_execute_args 64
410 } elseif { ![is_remote host] && ![is_remote target] } {
411 # When using low ulimit -u limit, use maximum of
412 # a quarter of that limit and 10000 even when running expensive
413 # tests, otherwise parallel tests might fail after fork failures.
414 set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
415 if { [string is integer -strict $nproc] } {
416 set nproc [expr $nproc / 4]
417 if { $nproc > 10000 } { set nproc 10000 }
418 if { $nproc < 16 } { set nproc 16 }
419 set go_execute_args $nproc
422 if { "$go_execute_args" != "" } {
423 verbose -log "$test: go_execute_args is $go_execute_args"
427 if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
428 && $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
429 # 64bit.go is a special case.
430 set go_execute_args ""
431 set hold_runtests $runtests
432 set runtests "go-test.exp"
433 set dg-do-what-default "link"
434 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
435 set output_file "./[file rootname [file tail $test]].exe"
436 set base "[file rootname [file tail $test]]"
438 if { [catch "exec $output_file >$base-out.go"] != 0 } {
439 fail "$name execution"
441 pass "$name execution"
442 file delete $base-out.x
443 # Disable optimizations as this test takes a long time
445 set hold $TORTURE_OPTIONS
446 set TORTURE_OPTIONS [ list { -O0 -g }]
447 go-torture-execute "./$base-out.go"
448 set TORTURE_OPTIONS $hold
450 file delete $base-out.go
452 file delete $output_file
453 set runtests $hold_runtests
454 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
455 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
456 || $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
457 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
459 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
462 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
465 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
468 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
471 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
473 # This is a vanilla execution test.
474 go-torture-execute $test
475 file delete core [glob -nocomplain core.*]
476 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
477 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
478 || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
479 # This is an execution test for which we need to check the
481 set hold_runtests $runtests
482 set runtests "go-test.exp"
483 set dg-do-what-default "link"
484 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
485 set output_file "./[file rootname [file tail $test]].exe"
486 set base "[file rootname [file tail $test]]"
488 verbose -log "$output_file >$base.p 2>&1"
489 if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } {
490 verbose -log $catcherr
491 fail "$name execution"
492 untested "$name compare"
494 pass "$name execution"
495 regsub "\\.go$" $test ".out" expect
496 filecmp $expect $base.p "$name compare"
500 untested "$name execution"
501 untested "$name compare"
503 set runtests $hold_runtests
504 } elseif { [string match \
505 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
507 || [string match "// \$G \$F.go && \$L \$F.\$A #*" \
509 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
510 # This is a vanilla compile and link test.
511 set dg-do-what-default "link"
512 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
513 } elseif { [string match "// \$G \$D/\$F.go" $test_line] \
514 || [string match "// \$G \$D/\$F.go || echo BUG*" \
516 || [string match "// \$G \$D/\$F.go || echo \"Bug*" \
518 || [string match "// \$G \$D/\$F.go || echo \"Issue*" \
520 || [string match "// \$G \$F.go || echo BUG*" \
522 || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
524 || $test_line == "// echo bug395 is broken # takes 90+ seconds to break" } {
525 # This is a vanilla compile test.
526 set dg-do-what-default "assemble"
527 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
528 } elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
530 || $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
531 || $test_line == "// ! \$G \$D/\$F.go" \
532 || $test_line == "// ! \$G \$F.go" \
533 || [string match "// ! \$G \$D/\$F.go || echo BUG*" \
535 # This is a compile test which should fail.
536 set dg-do-what-default "assemble"
538 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
539 } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
541 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
543 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
545 || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
546 && $test_line2 == "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
547 go-execute-xfail $test
548 } elseif { [string match "// errchk \$G \$F.go" $test_line] \
549 || [string match "// errchk \$G -e \$F.go" $test_line] \
550 || [string match "// errchk \$G \$D/\$F.go" $test_line] \
551 || [string match "//errchk \$G \$D/\$F.go" $test_line] \
552 || [string match "// errchk \$G -e \$D/\$F.go" \
554 || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
555 || [string match "// ! errchk \$G -e \$D/\$F.go" \
557 || [string match "// errchk \$G \$F.go || true" \
559 || [string match "// errchk \$G \$D/\$F.go || true" \
561 || [string match "// errchk \$G -e \$D/\$F.go || true" \
563 || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
566 } elseif { [string match \
567 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
570 "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
573 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
577 } elseif { [string match \
578 "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
583 set hold_runtests $runtests
584 set runtests "go-test.exp"
585 set dg-do-what-default "assemble"
586 regsub "\\.go$" $test ".dir/$name1" file1
587 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
588 regsub "\\.go$" $test ".dir/$name2" file2
589 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
590 file delete "[file rootname [file tail $file1]].o"
591 set runtests $hold_runtests
592 } elseif { [string match \
593 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
596 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
599 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
602 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
605 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
609 } elseif { [string match \
610 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
614 } elseif { [string match \
615 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
619 } elseif { [string match \
620 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
625 set hold_runtests $runtests
626 set runtests "go-test.exp"
627 set dg-do-what-default "assemble"
628 regsub "\\.go$" $test ".dir/$name1" file1
629 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
630 regsub "\\.go$" $test ".dir/$name2" file2
632 file delete "[file rootname [file tail $file1]].o"
633 set runtests $hold_runtests
634 } elseif { [string match \
635 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
637 set hold_runtests $runtests
638 set runtests "go-test.exp"
639 set dg-do-what-default "assemble"
640 regsub "\\.go$" $test "1.go" file1
641 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
643 file delete "[file rootname [file tail $file1]].o"
644 set runtests $hold_runtests
645 } elseif { [string match \
646 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
648 set hold_runtests $runtests
649 set runtests "go-test.exp"
650 set dg-do-what-default "assemble"
651 regsub "\\.go$" $test ".dir/bug0.go" file1
652 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
653 regsub "\\.go$" $test ".dir/bug1.go" file2
655 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
656 file delete "[file rootname [file tail $file1]].o"
657 set runtests $hold_runtests
658 } elseif { [string match \
659 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
661 set hold_runtests $runtests
662 set runtests "go-test.exp"
663 set dg-do-what-default "assemble"
664 regsub "\\.go$" $test ".dir/bug0.go" file1
665 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
666 regsub "\\.go$" $test ".dir/bug1.go" file2
667 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
668 regsub "\\.go$" $test ".dir/bug2.go" file3
670 dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
671 file delete "[file rootname [file tail $file1]].o"
672 file delete "[file rootname [file tail $file2]].o"
673 set runtests $hold_runtests
674 } elseif { [string match \
675 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
677 set hold_runtests $runtests
678 set runtests "go-test.exp"
679 set dg-do-what-default "assemble"
680 regsub "\\.go$" $test ".dir/bug0.go" file1
681 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
682 regsub "\\.go$" $test ".dir/bug1.go" file2
683 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
684 regsub "\\.go$" $test ".dir/bug2.go" file3
686 file delete "[file rootname [file tail $file1]].o"
687 file delete "[file rootname [file tail $file2]].o"
688 set runtests $hold_runtests
689 } elseif { [string match \
690 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
693 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
696 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
700 } elseif { [string match \
701 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
706 set hold_runtests $runtests
707 set runtests "go-test.exp"
708 set dg-do-what-default "assemble"
709 regsub "\\.go$" $test ".dir/$name1" 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/$name2" file2
713 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
714 set ofile2 "[file rootname [file tail $file2]].o"
715 set dg-do-what-default "link"
716 set output_file "./[file rootname [file tail $test]].exe"
717 set comp_output [go_target_compile "$ofile1 $ofile2" \
718 $output_file "executable" "$options"]
719 set comp_output [go-dg-prune $target_triplet $comp_output]
720 verbose -log $comp_output
721 set result [go_load "$output_file" "" ""]
722 set status [lindex $result 0]
724 file delete $ofile1 $ofile2 $output_file
725 set runtests $hold_runtests
726 } elseif { [string match \
727 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
729 set hold_runtests $runtests
730 set runtests "go-test.exp"
731 set dg-do-what-default "assemble"
732 regsub "\\.go$" $test ".dir/a.go" file1
733 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
734 set ofile1 "[file rootname [file tail $file1]].o"
735 regsub "\\.go$" $test ".dir/b.go" file2
736 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
737 set ofile2 "[file rootname [file tail $file2]].o"
738 dg-test -keep-output "$test" "-O" "-w $DEFAULT_GOCFLAGS"
739 set ofile3 "[file rootname [file tail $test]].o"
740 set dg-do-what-default "link"
741 set output_file "./[file rootname [file tail $test]].exe"
742 set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
743 $output_file "executable" "$options"]
744 set comp_output [go-dg-prune $target_triplet $comp_output]
745 if [string match "" $comp_output] {
748 verbose -log $comp_output
751 file delete $ofile1 $ofile2 $ofile3 $output_file
752 set runtests $hold_runtests
753 } elseif { [string match \
754 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
756 set hold_runtests $runtests
757 set runtests "go-test.exp"
758 set dg-do-what-default "assemble"
759 regsub "/\[^/\]*$" $test "/embed0.go" file1
760 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
761 set ofile1 "[file rootname [file tail $file1]].o"
762 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
763 set ofile2 "[file rootname [file tail $test]].o"
764 set output_file "./[file rootname [file tail $test]].exe"
765 set comp_output [go_target_compile "$ofile1 $ofile2" \
766 $output_file "executable" "$options"]
767 set comp_output [go-dg-prune $target_triplet $comp_output]
768 if [string match "" $comp_output] {
769 set result [go_load "$output_file" "" ""]
770 set status [lindex $result 0]
773 verbose -log $comp_output
776 file delete $ofile1 $ofile2 $output_file
777 set runtests $hold_runtests
778 } elseif { [string match \
779 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
782 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
785 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
789 } elseif { [string match \
790 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
795 set hold_runtests $runtests
796 set runtests "go-test.exp"
797 set dg-do-what-default "assemble"
798 regsub "\\.go$" $test ".dir/$name1" file1
799 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
800 set ofile1 "[file rootname [file tail $file1]].o"
801 regsub "\\.go$" $test ".dir/$name2" file2
802 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
803 set ofile2 "[file rootname [file tail $file2]].o"
804 set dg-do-what-default "link"
805 set output_file "./[file rootname [file tail $file2]].exe"
806 set comp_output [go_target_compile "$ofile1 $ofile2" \
807 $output_file "executable" "$options"]
808 set comp_output [go-dg-prune $target_triplet $comp_output]
809 if [string match "" $comp_output] {
810 set result [go_load "$output_file" "" ""]
811 set status [lindex $result 0]
814 verbose -log $comp_output
817 file delete $ofile1 $ofile2 $output_file
818 set runtests $hold_runtests
819 } elseif { [string match \
820 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
822 set hold_runtests $runtests
823 set runtests "go-test.exp"
824 set dg-do-what-default "assemble"
825 regsub "\\.go$" $test ".dir/chanbug.go" file1
826 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
827 regsub "\\.go$" $test ".dir/chanbug2.go" file2
828 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
829 file delete "[file rootname [file tail $file1]].o"
830 set runtests $hold_runtests
831 } elseif { [string match \
832 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
834 set dg-do-what-default "assemble"
836 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
837 } elseif { [string match \
838 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
840 set hold_runtests $runtests
841 set runtests "go-test.exp"
842 set dg-do-what-default "assemble"
843 regsub "\\.go$" $test ".dir/x.go" file1
844 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
845 regsub "\\.go$" $test ".dir/y.go" file2
847 file delete "[file rootname [file tail $file1]].o"
848 set runtests $hold_runtests
849 } elseif { "$test_line" == "" || [string match "// true*" $test_line] } {
850 # Not a real test, just ignore.
851 } elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
852 && $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
853 && $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
854 && $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
855 && $test_line5 == "// \$L bug2.\$A &&" \
856 && [string match "// ./\$A.out || echo BUG*" $test_line6] } {
857 set hold_runtests $runtests
858 set runtests "go-test.exp"
859 set dg-do-what-default "assemble"
860 regsub "\\.go$" $test ".dir/bug0.go" file0
861 dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
862 set ofile0 "[file rootname [file tail $file0]].o"
863 regsub "\\.go$" $test ".dir/bug1.go" file1
864 dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
865 set ofile1 "[file rootname [file tail $file1]].o"
866 regsub "\\.go$" $test ".dir/bug2.go" file2
867 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
868 set ofile2 "[file rootname [file tail $file2]].o"
869 regsub "\\.go$" $test ".dir/bug3.go" file3
871 set output_file "./[file rootname [file tail $test]].exe"
872 set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
873 $output_file "executable" "$options"]
874 set comp-output [go-dg-prune $target_triplet $comp_output]
875 if [string match "" $comp_output] {
876 set result [go_load "$output_file" "" ""]
877 set status [lindex $result 0]
880 verbose -log $comp_output
883 file delete $ofile0 $ofile1 $ofile2 $output_file
884 set runtests $hold_runtests
885 } elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
886 || $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
887 if { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
888 set name1 "import2.go"
889 } elseif { $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
890 set name1 "recursive1.go"
892 set hold_runtests $runtests
893 set runtests "go-test.exp"
894 set dg-do-what-default "assemble"
895 regsub "/\[^/\]*$" $test "/${name1}" file1
896 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
897 set ofile1 "[file rootname [file tail $file1]].o"
898 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
900 set runtests $hold_runtests
901 } elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
902 set hold_runtests $runtests
903 set runtests "go-test.exp"
904 set dg-do-what-default "assemble"
905 regsub "/\[^/\]*$" $test "/ddd2.go" file1
906 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
907 set ofile1 "[file rootname [file tail $file1]].o"
908 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
909 set ofile2 "[file rootname [file tail $test]].o"
910 set output_file "./[file rootname [file tail $test]].exe"
911 set comp_output [go_target_compile "$ofile1 $ofile2" \
912 $output_file "executable" "$options"]
913 set comp_output [go-dg-prune $target_triplet $comp_output]
914 if [string match "" $comp_output] {
915 set result [go_load "$output_file" "" ""]
916 set status [lindex $result 0]
919 verbose -log $comp_output
922 file delete $ofile1 $ofile2 $output_file
923 set runtests $hold_runtests
924 } elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
925 regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
926 set output_file "./[file rootname [file tail $test]].o"
927 set comp_output [go_target_compile "$test $test2" \
928 $output_file "executable" "$options"]
929 set comp_output [go-dg-prune $target_triplet $comp_output]
930 if [string match "" $comp_output] {
931 set result [go_load "$output_file" "" ""]
932 set status [lindex $result 0]
935 verbose -log $comp_output
938 file delete $output_file
939 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
940 && $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
941 && $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
942 && $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
943 set go_execute_args ""
944 set hold_runtests $runtests
945 set runtests "go-test.exp"
946 set dg-do-what-default "link"
947 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
948 set output_file "./[file rootname [file tail $test]].exe"
950 if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
951 fail "$name execution 0"
953 pass "$name execution 0"
955 # Disable optimizations as this test takes a long time
957 set hold $TORTURE_OPTIONS
958 set TORTURE_OPTIONS [ list { -O0 -g }]
959 go-torture-execute "./tmp.go"
960 set TORTURE_OPTIONS $hold
962 if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
963 fail "$name execution 1"
965 pass "$name execution 1"
968 if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
969 fail "$name execution 2"
971 pass "$name execution 2"
976 file delete $output_file
977 set runtests $hold_runtests
978 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
979 && $test_line2 == "// errchk \$G -e tmp.go" } {
980 set go_execute_args ""
981 set hold_runtests $runtests
982 set runtests "go-test.exp"
983 set dg-do-what-default "link"
984 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
985 set output_file "./[file rootname [file tail $test]].exe"
987 if { [catch "exec $output_file >tmp.go"] != 0 } {
988 fail "$name execution"
990 pass "$name execution"
995 file delete $output_file
996 set runtests $hold_runtests
997 } elseif { [string match \
998 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
1000 set hold_runtests $runtests
1001 set runtests "go-test.exp"
1002 set dg-do-what-default "assemble"
1003 regsub "\\.go$" $test ".dir/p.go" file1
1004 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
1005 set ofile1 "[file rootname [file tail $file1]].o"
1006 regsub "\\.go$" $test ".dir/main.go" file2
1007 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
1008 set ofile2 "[file rootname [file tail $file2]].o"
1009 set output_file "./[file rootname [file tail $test]].exe"
1010 set comp_output [go_target_compile "$ofile1 $ofile2" \
1011 $output_file "executable" "$options"]
1012 set comp_output [go-dg-prune $target_triplet $comp_output]
1013 if [string match "" $comp_output] {
1015 set result [go_load "$output_file" "" ""]
1016 set status [lindex $result 0]
1019 verbose -log $comp_output
1022 file delete $ofile1 $ofile2 $output_file
1023 set runtests $hold_runtests
1024 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
1025 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
1026 set go_execute_args ""
1027 set hold_runtests $runtests
1028 set runtests "go-test.exp"
1029 set dg-do-what-default "link"
1030 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1031 set output_file "./[file rootname [file tail $test]].exe"
1032 set base "[file rootname [file tail $test]]"
1034 if { [catch "exec $output_file > $base-out.go"] != 0 } {
1035 fail "$name execution"
1037 pass "$name execution"
1038 file delete $base-out.x
1039 # Disable optimizations as this test takes a long time
1041 set hold $TORTURE_OPTIONS
1042 set TORTURE_OPTIONS [ list { -O0 -g }]
1043 go-torture-execute "./$base-out.go"
1044 set TORTURE_OPTIONS $hold
1046 file delete $base-out.go
1048 file delete $output_file
1049 set runtests $hold_runtests
1050 } elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1051 regsub "\\.go$" $test ".dir/a.go" file1
1052 regsub "\\.go$" $test ".dir/b.go" file2
1053 errchk "$file1" "$file2"
1054 } elseif { $test_line == "// \$G \$D/\$F.go \$D/z*.go && \$L \$F.\$A && ./\$A.out" } {
1055 set dir [file dirname $test]
1056 set go_compile_args [glob $dir/z*.go]
1057 go-torture-execute $test
1058 } elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1059 && $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1060 && $test_line3 == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1061 set hold_runtests $runtests
1062 set runtests "go-test.exp"
1063 set dg-do-what-default "assemble"
1064 regsub "\\.go$" $test ".dir/pkg.go" file1
1065 dg-test -keep-output $file1 "" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1066 set ofile1 "[file rootname [file tail $file1]].o"
1067 file rename -force $ofile1 slow.o
1068 dg-test -keep-output $file1 "-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1069 file rename -force $ofile1 fast.o
1070 set ofile2 "[file rootname [file tail $test]].o"
1071 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1072 set output_file "./[file rootname [file tail $test]].exe"
1073 set comp_output [go_target_compile "$ofile2 slow.o fast.o" \
1074 $output_file "executable" "$options"]
1075 set comp_output [go-dg-prune $target_triplet $comp_output]
1076 if [string match "" $comp_output] {
1077 set result [go_load "$output_file" "" ""]
1078 set status [lindex $result 0]
1081 verbose -log $comp_output
1084 file delete slow.o fast.o $ofile2 $output_file
1085 set runtests $hold_runtests
1086 } elseif { [string match \
1087 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1089 set hold_runtests $runtests
1090 set runtests "go-test.exp"
1091 set dg-do-what-default "assemble"
1092 regsub "\\.go$" $test ".dir/pkg.go" file1
1093 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
1094 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
1095 file delete "[file rootname [file tail $file1]].o"
1096 set runtests $hold_runtests
1097 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
1098 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out" } {
1099 set go_execute_args ""
1100 set hold_runtests $runtests
1101 set runtests "go-test.exp"
1102 set dg-do-what-default "link"
1103 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1104 set output_file "./[file rootname [file tail $test]].exe"
1105 set base "[file rootname [file tail $test]]"
1107 if { [catch "exec $output_file >$base-out.go"] != 0 } {
1108 fail "$name execution"
1110 pass "$name execution"
1111 file delete $base-out.x
1112 go-torture-execute "./$base-out.go"
1114 file delete $base-out.go
1116 file delete $output_file
1117 set runtests $hold_runtests
1118 } elseif { $test_line == "// # generated by cmplxdivide.c" } {
1120 } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1121 || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1122 # These tests import the same package under two different
1123 # names, which gccgo does not support.
1124 } elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1125 # This tests whether initializers are written out
1126 # statically. gccgo does not provide a way to test that,
1127 # as an initializer will be generated for any code which
1128 # has global variables which need to be registered as GC
1130 } elseif { $test_line == "// errchk -0 \$G -m -l \$D/\$F.go" } {
1131 # This tests debug output of the gc compiler, which is
1132 # meaningless for gccgo.
1133 } elseif { $test_line == "// \[ \$O == 6 \] || errchk \$G -e \$D/\$F.go" \
1134 || $test_line == "// \[ \$O != 6 \] || errchk \$G -e \$D/\$F.go" } {
1135 # This tests specific handling of the gc compiler on types
1136 # that are too large. It is target specific in a way I
1137 # haven't bothered to check for here.
1139 clone_output "$name: unrecognized test line: $test_line"
1143 set go_compile_args ""
1144 set go_execute_args ""
1147 set dg-do-what-default ${saved-dg-do-what-default}
1148 set TORTURE_OPTIONS $saved_torture_options