1 # Copyright
(C
) 2009-2020 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
:
31 #
// $G $D
/$F.go
&& $L $F.$A
&& .
/$A.out
32 #
// $G $D
/$F.go
&& $L $F.$A || echo BUG
: known to fail incorrectly
33 #
// $G $D
/$F.go
&& echo BUG
: compilation succeeds incorrectly
34 #
// $G $D
/$F.go || echo BUG
: compilation should succeed
37 load_lib go
-torture.exp
38 load_lib target
-supports.exp
41 proc filecmp
{ file1 file2 testname
} {
42 set f1
[open $file1 r
]
43 set f2
[open $file2 r
]
45 while { [gets $f1 line1
] >= 0 } {
46 if { [gets $f2 line2
] < 0 } {
47 verbose
-log "output mismatch: $file2 shorter than $file1"
51 if { $line1
!= $line2
} {
52 verbose
-log "output mismatch comparing $file1 and $file2"
53 verbose
-log "expected \"$line1\""
54 verbose
-log "got \"$line2\""
59 if { [gets $f2 line2
] >= 0 } {
60 verbose
-log "output mismatch: $file1 shorter than $file2"
73 proc errchk
{ test opts
} {
74 global dg
-do-what
-default
75 global DEFAULT_GOCFLAGS
78 set saved
-dg
-do-what
-default $
{dg
-do-what
-default
}
79 set dg
-do-what
-default
compile
80 set filename
[file tail $test
]
81 if { "$filename" == "$test" } {
82 set filename
"errchk-$filename"
84 set fdin
[open $test r
]
85 fconfigure $fdin
-encoding binary
86 set fdout
[open $filename w
]
87 fconfigure $fdout
-encoding binary
88 while { [gets $fdin copy_line
] >= 0 } {
89 if [string match
"*////*" $copy_line] {
90 puts $fdout $copy_line
94 # Combine quoted strings in comments
, so that
95 #
// ERROR
"first error" "second error"
97 #
// ERROR
"first error|second error"
98 # This format is used by the master testsuite to recognize
99 # multiple errors
on a single line. We don
't require that all
100 # the errors be present, but we do want to accept any of them.
102 while { $changed != $copy_line } {
103 set changed $copy_line
104 regsub {(// [^"]*"[^"]*)" "} $copy_line {\1|} out_line
105 set copy_line $out_line
108 set index [string first // $copy_line]
109 set eindex [string first ERROR $copy_line]
110 if { $index >= 0 && $eindex > $index } {
111 # We're putting the regexp in curly braces
, so replace
any
112 # curly braces in the regexp with hex escapes.
113 regsub
-start $index
-all
"\{" $copy_line {\x7b} copy_line
114 regsub
-start $index
-all
"\}" $copy_line {\x7d} copy_line
116 # Replace .
* with
[ -~
]* because .
* will eat newlines.
117 # We can
't easily use (?n) because this regexp will appear
118 # in the middle of a large regexp.
119 regsub -all {\.\*} $copy_line {[ -~]*} copy_line
125 # // { dg-error {string} }
126 # The latter is what go-dg-runtest expects.
127 regsub {// (GCCGO_)?ERROR "([^"]*)"([^"]*)$} $copy_line "// \{ dg-error \{\\2\} \}\\3" out_line
129 puts $fdout $out_line
134 set hold_runtests $runtests
135 set runtests "go-test.exp"
136 go-dg-runtest $filename "" "-fno-show-column $DEFAULT_GOCFLAGS $opts"
137 set runtests $hold_runtests
139 file delete $filename
140 set dg-do-what-default ${saved-dg-do-what-default}
143 # This is an execution test which should fail.
144 proc go-execute-xfail { test } {
145 global DEFAULT_GOCFLAGS
148 set filename [file tail $test]
149 set fdin [open $test r]
150 set fdout [open $filename w]
151 puts $fdout "// { dg-do run { xfail *-*-* } }"
152 while { [gets $fdin copy_line] >= 0 } {
153 puts $fdout $copy_line
158 set hold_runtests $runtests
159 set runtests "go-test.exp"
160 go-dg-runtest $filename "" "-w $DEFAULT_GOCFLAGS"
161 set runtests $hold_runtests
163 file delete $filename
166 # N.B. Keep in sync with libgo/configure.ac.
167 proc go-set-goarch { } {
168 global target_triplet
170 switch -glob $target_triplet {
185 if [check_effective_target_ia32] {
187 } elseif [check_effective_target_x32] {
188 set goarch "amd64p32"
194 if [check_no_compiler_messages mipso32 assembly {
195 #if _MIPS_SIM != _ABIO32
200 } elseif [check_no_compiler_messages mipsn32 assembly {
201 #if _MIPS_SIM != _ABIN32
205 set goarch "mips64p32"
206 } elseif [check_no_compiler_messages mipsn64 assembly {
207 #if _MIPS_SIM != _ABI64
213 perror "$target_triplet: unrecognized MIPS ABI"
217 if [istarget "mips*el-*-*"] {
222 if [check_effective_target_ilp32] {
225 if [istarget "powerpc64le-*-*"] {
236 if [check_effective_target_ilp32] {
243 if [check_effective_target_ilp32] {
250 perror "$target_triplet: unhandled architecture"
254 verbose -log "Setting GOARCH=$goarch" 1
255 setenv GOARCH $goarch
258 # Take a list of files and return a lists of lists, where each list is
259 # the set of files in the same package.
260 proc go-find-packages { test name files } {
265 if { [gets $fd line] < 0 } {
267 clone_output "$test: could not read $f"
272 if { [regexp "^package (\\w+)" $line match package] } {
273 set len [llength $packages]
274 for { set i 0 } { $i < $len } { incr i } {
275 set p [lindex $packages $i]
276 if { [lindex $p 0] == $package } {
283 lappend packages [list $package $f]
294 proc go-gc-tests { } {
297 global GCC_UNDER_TEST
299 global TORTURE_OPTIONS
300 global dg-do-what-default
301 global go_compile_args
302 global go_execute_args
303 global target_triplet
305 # If a testcase doesn't have special options
, use these.
306 global DEFAULT_GOCFLAGS
307 if ![info exists DEFAULT_GOCFLAGS
] {
308 set DEFAULT_GOCFLAGS
" -pedantic-errors"
312 lappend options
"additional_flags=$DEFAULT_GOCFLAGS"
314 #
Set GOARCH
for tests that need it.
317 # Running all the torture options takes too long and
, since the
318 # frontend ignores the standard options
, it doesn
't significantly
320 set saved_torture_options $TORTURE_OPTIONS
321 set TORTURE_OPTIONS [list { -O2 -g }]
323 set saved-dg-do-what-default ${dg-do-what-default}
327 set tests [lsort [find $srcdir/$subdir *.go]]
328 foreach test $tests {
329 if ![runtest_file_p $runtests $test] {
333 # Skip the files in bench; they are not tests.
334 if [string match "*go.test/test/bench/*" $test] {
338 # Skip the files in stress; they are not tests.
339 if [string match "*go.test/test/stress/*" $test] {
343 # Skip the files in safe; gccgo does not support safe mode.
344 if [string match "*go.test/test/safe/*" $test] {
348 # Skip files in sub-subdirectories: they are components of
350 if [string match "*go.test/test/*/*/*" $test] {
354 # Skip files in *.dir subdirectories: they are components of
356 if [string match "*go.test/test/*.dir/*" $test] {
360 set name [dg-trim-dirname $srcdir $test]
362 # Skip certain tests if target is RTEMS OS.
363 if [istarget "*-*-rtems*"] {
364 if { [string match "*go.test/test/args.go" $test] \
365 || [string match "*go.test/test/env.go" $test] } {
366 untested "$name: uses the command-line or environment variables"
370 if { [string match "*go.test/test/stack.go" $test] \
371 || [string match "*go.test/test/peano.go" $test] \
372 || [string match "*go.test/test/chan/goroutines.go" $test] } {
373 untested "$name: has very high memory requirement"
378 # Handle certain tests in a target-dependant way.
379 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] || [istarget "s390*-*-*"] } {
380 if { [string match "*go.test/test/nilptr.go" $test] } {
386 if [check_effective_target_pie_enabled] {
391 if { [file tail $test] == "init1.go" } {
392 # This tests whether GC runs during init, which for gccgo
393 # it currently does not.
398 if { [file tail $test] == "closure.go" } {
399 # This tests whether function closures do any memory
400 # allocation, which for gccgo they currently do.
405 if { ( [file tail $test] == "select2.go" \
406 || [file tail $test] == "stack.go" \
407 || [file tail $test] == "peano.go" \
408 || [file tail $test] == "nilptr2.go" ) \
409 && ! [check_effective_target_split_stack] } {
410 # These tests fails on targets without split stack.
415 if [string match "*go.test/test/rotate\[0123\].go" $test] {
416 # These tests produces a temporary file that takes too long
417 # to compile--5 minutes on my laptop without optimization.
418 # When compiling without optimization it tests nothing
419 # useful, since the point of the test is to see whether
420 # the compiler generates rotate instructions.
425 if { [file tail $test] == "bug347.go" \
426 || [file tail $test] == "bug348.go" } {
427 # These tests don't work
if the functions are inlined.
428 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
431 set fd
[open $test r
]
436 if { [gets $fd test_line
] < 0 } {
438 clone_output
"$test: could not read first line"
444 if { [ string match
"*nacl*exit 0*" $test_line ] \
445 ||
[ string match
"*exit 0*nacl*" $test_line ] \
446 ||
[ string match
"*Android*exit 0*" $test_line ] \
447 ||
[ string match
"*exit 0*Android*" $test_line ] \
448 ||
[ string match
"*\"\$GOOS\" == windows*" $test_line ] } {
452 if { [ string match
"// +build *" $test_line ] } {
455 if { [ regexp
-line
"\[ \][getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
457 } elseif
{ [ regexp
-line
"\[ \]\![getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
459 } elseif
{ [ regexp
-line
"\[ \]linux\(\[ \]\|\$\)" $test_line ] } {
461 } elseif
{ [ regexp
-line
"\[ \]\!linux\(\[ \]\|\$\)" $test_line ] } {
463 } elseif
{ [ regexp
-line
"\[ \]\!windows\(\[ \]\|\$\)" $test_line ] } {
465 } elseif
{ [ regexp
-line
"\[ \]windows\(\[ \]\|\$\)" $test_line ] } {
468 if { $matches_pos
== 1 && $matches_neg
== 0 } {
479 if { $lines_ok
== 0 } {
484 set test_line1 $test_line
486 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
487 set lineno
[expr $lineno
+ 1]
488 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
490 clone_output
"$test: could not read line $lineno"
496 if { $lines_ok
== 0 } {
502 # runtest_file_p is already run above
, and the code below can run
503 # runtest_file_p again
, make sure everything
for this test is
504 # performed
if the above runtest_file_p decided this runtest
505 # instance should
execute the test
506 gcc_parallel_test_enable
0
508 set go_compile_args
""
509 set go_execute_args
""
510 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
511 && ! [string match
"*.go*" "$progargs"] } {
512 set go_execute_args $progargs
513 verbose
-log "$test: go_execute_args is $go_execute_args"
514 set index
[string last
" $progargs" $test_line]
515 set test_line
[string replace $test_line $index end
]
516 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
517 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
518 # goroutines.go spawns by default
10000 threads
, which is too much
520 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
521 set go_execute_args
64
522 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
523 # When using low ulimit
-u
limit, use maximum of
524 # a quarter of that
limit and
10000 even when running expensive
525 # tests
, otherwise parallel tests might fail after fork failures.
526 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
527 if { [string is
integer -strict $nproc
] } {
528 set nproc
[expr $nproc
/ 4]
529 if { $nproc
> 10000 } { set nproc
10000 }
530 if { $nproc
< 16 } { set nproc
16 }
531 set go_execute_args $nproc
534 if { "$go_execute_args" != "" } {
535 verbose
-log "$test: go_execute_args is $go_execute_args"
539 if { $test_line
== "// compile"
540 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
541 # This is a vanilla
compile test.
542 set dg
-do-what
-default
"assemble"
543 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
544 } elseif
{ $test_line
== "// run"
545 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
546 # This is a vanilla execution test.
547 go
-torture
-execute $test
548 file
delete core
[glob
-nocomplain core.
*]
549 } elseif
{ $test_line
== "// build" } {
550 # This is a vanilla
compile and link test.
551 set dg
-do-what
-default
"link"
552 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
553 } elseif
{ [string match
"// runoutput*" $test_line] \
554 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
555 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
556 # Run the test to
get a .go
program to run.
557 set go_execute_args
""
558 set hold_runtests $runtests
559 set runtests
"go-test.exp"
561 if { [string match
"// runoutput*" $test_line] } {
563 regsub
"// runoutput\(.*\)" $test_line "\\1" args
565 lappend files
"[file dirname $test]/$f"
568 set dg
-do-what
-default
"link"
569 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
570 set output_file
"./[file rootname [file tail $test]].exe"
571 set base
"[file rootname [file tail $test]]"
573 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
574 fail
"$name execution"
576 pass
"$name execution"
577 file
delete $base
-out.x
578 # Disable optimizations as some of these tests
579 # take a long time to
compile.
580 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
581 go
-torture
-execute "./$base-out.go"
583 file
delete $base
-out.go
585 file
delete $output_file
586 set runtests $hold_runtests
587 } elseif
{ $test_line
== "// cmpout" \
588 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
589 # This is an execution test
for which we need to check the
591 set hold_runtests $runtests
592 set runtests
"go-test.exp"
593 set dg
-do-what
-default
"link"
594 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
595 set output_file
"./[file rootname [file tail $test]].exe"
596 set base
"[file rootname [file tail $test]]"
598 verbose
-log "$output_file >$base.p 2>&1"
599 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
600 verbose
-log $catcherr
601 fail
"$name execution"
602 untested
"$name compare"
604 pass
"$name execution"
605 regsub
"\\.go$" $test ".out" expect
606 filecmp $expect $base.p
"$name compare"
607 file
delete $output_file
611 untested
"$name execution"
612 untested
"$name compare"
614 set runtests $hold_runtests
615 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
617 go
-execute-xfail $test
618 } elseif
{ $test_line
== "// errorcheck" } {
620 } elseif
{ $test_line
== "// errorcheckdir" || $test_line == "// errorcheckdir -n" } {
621 set hold_runtests $runtests
622 set runtests
"go-test.exp"
623 set dir "[file rootname $test].dir"
624 set files
[lsort
[glob
"$dir/*.go"]]
625 set packages
[go
-find
-packages $test $
name $files
]
626 if { [llength $packages
] > 0 } {
627 set dg
-do-what
-default
"assemble"
629 set last
[lindex $packages end
]
630 set packages
[lreplace $packages end end
]
631 foreach p $packages
{
632 dg
-test
-keep
-output
[lrange $p
1 end
] "-O -I." "-w $DEFAULT_GOCFLAGS"
633 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
635 errchk
[lindex $last
1] "[lrange $last 2 end]"
640 set runtests $hold_runtests
641 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
642 # Run the test to
get a .go
program to error check.
643 set go_execute_args
""
644 set hold_runtests $runtests
645 set runtests
"go-test.exp"
647 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
649 lappend files
"[file dirname $test]/$f"
651 set dg
-do-what
-default
"link"
652 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
653 set output_file
"./[file rootname [file tail $test]].exe"
654 set base
"[file rootname [file tail $test]]"
656 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
657 fail
"$name execution"
659 pass
"$name execution"
660 errchk
"$base-out.go" ""
662 file
delete $base
-out.go
664 file
delete $output_file
665 set runtests $hold_runtests
666 } elseif
{ $test_line
== "// compiledir" } {
667 set hold_runtests $runtests
668 set runtests
"go-test.exp"
669 set dg
-do-what
-default
"assemble"
670 set dir "[file rootname $test].dir"
671 set files
[lsort
[glob
"$dir/*.go"]]
672 set packages
[go
-find
-packages $test $
name $files
]
673 if { [llength $packages
] > 0 } {
675 foreach p $packages
{
676 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O -I." "-w $DEFAULT_GOCFLAGS"
677 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
683 set runtests $hold_runtests
684 } elseif
{ $test_line
== "// rundir" } {
685 set hold_runtests $runtests
686 set runtests
"go-test.exp"
687 set dir "[file rootname $test].dir"
688 set files
[lsort
[glob
"$dir/*.go"]]
689 set packages
[go
-find
-packages $test $
name $files
]
690 if { [llength $packages
] > 0 } {
691 set dg
-do-what
-default
"assemble"
693 set last
[lindex $packages end
]
694 set packages
[lreplace $packages end end
]
695 foreach p $packages
{
696 dg
-test
-keep
-output
[lrange $p
1 end
] "-O -I." "-w $DEFAULT_GOCFLAGS"
697 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
699 set dg
-do-what
-default
"link"
700 set go_compile_args
""
701 append go_compile_args
[lrange $last
2 end
]
702 append go_compile_args $del
703 go
-torture
-execute [lindex $last
1]
708 set runtests $hold_runtests
709 } elseif
{ $test_line
== "// rundircmpout" } {
710 set hold_runtests $runtests
711 set runtests
"go-test.exp"
712 set dir "[file rootname $test].dir"
713 set files
[lsort
[glob
"$dir/*.go"]]
714 set packages
[go
-find
-packages $test $
name $files
]
715 if { [llength $packages
] > 0 } {
716 set dg
-do-what
-default
"assemble"
718 set last
[lindex $packages end
]
719 set packages
[lreplace $packages end end
]
720 foreach p $packages
{
721 dg
-test
-keep
-output
[lrange $p
1 end
] "-O -I." "-w $DEFAULT_GOCFLAGS"
722 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
724 set dg
-do-what
-default
"link"
725 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O -I." "-w $DEFAULT_GOCFLAGS"
726 set base
"[file rootname [file tail [lindex $last 1]]]"
727 set output_file
"./$base.exe"
728 lappend del $output_file
730 verbose
-log "$output_file >$base.p 2>&1"
731 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
732 verbose
-log $catcherr
733 fail
"$name execution"
734 untested
"$name compare"
736 pass
"$name execution"
737 regsub
"\\.go$" "$test" ".out" expect
738 filecmp $expect $base.p
"$name compare"
746 set runtests $hold_runtests
747 } elseif
{ "$test_line" == ""
748 ||
[string match
"// true*" $test_line]
749 ||
[string match
"// skip*" $test_line] } {
750 # Not a real test
, just ignore.
751 } elseif
{ [string match \
752 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
755 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
758 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
762 } elseif
{ [string match \
763 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
768 set hold_runtests $runtests
769 set runtests
"go-test.exp"
770 set dg
-do-what
-default
"assemble"
771 regsub
"\\.go$" $test ".dir/$name1" file1
772 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
773 regsub
"\\.go$" $test ".dir/$name2" file2
775 file
delete "[file rootname [file tail $file1]].o"
776 set runtests $hold_runtests
777 } elseif
{ [string match \
778 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
780 set hold_runtests $runtests
781 set runtests
"go-test.exp"
782 set dg
-do-what
-default
"assemble"
783 regsub
"\\.go$" $test "1.go" file1
784 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
786 file
delete "[file rootname [file tail $file1]].o"
787 set runtests $hold_runtests
788 } elseif
{ [string match \
789 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
791 set hold_runtests $runtests
792 set runtests
"go-test.exp"
793 set dg
-do-what
-default
"assemble"
794 regsub
"\\.go$" $test ".dir/bug0.go" file1
795 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
796 regsub
"\\.go$" $test ".dir/bug1.go" file2
797 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
798 regsub
"\\.go$" $test ".dir/bug2.go" file3
800 file
delete "[file rootname [file tail $file1]].o"
801 file
delete "[file rootname [file tail $file2]].o"
802 set runtests $hold_runtests
803 } elseif
{ [string match \
804 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
807 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
809 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
810 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
811 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
813 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
817 } elseif
{ [string match \
818 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
822 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
825 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
828 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
829 set name1
"method4a.go"
832 set hold_runtests $runtests
833 set runtests
"go-test.exp"
834 set dg
-do-what
-default
"assemble"
835 regsub
"\\.go$" $test ".dir/$name1" file1
836 if { $name1
== "method4a.go" } {
837 set file1
"[file dirname $test]/method4a.go"
839 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
840 set ofile1
"[file rootname [file tail $file1]].o"
841 regsub
"\\.go$" $test ".dir/$name2" file2
842 if { $name2
== "" } {
845 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
846 set ofile2
"[file rootname [file tail $file2]].o"
847 set dg
-do-what
-default
"link"
848 set output_file
"./[file rootname [file tail $test]].exe"
849 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
850 $output_file
"executable" "$options"]
851 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
852 verbose
-log $comp_output
853 set result
[go_load
"$output_file" "" ""]
854 set status [lindex $result
0]
856 file
delete $ofile1 $ofile2 $output_file
857 set runtests $hold_runtests
858 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
859 set hold_runtests $runtests
860 set runtests
"go-test.exp"
861 set dg
-do-what
-default
"assemble"
862 regsub
"\\.go$" $test ".dir/one.go" file1
863 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
864 set ofile1
"[file rootname [file tail $file1]].o"
865 regsub
"\\.go$" $test ".dir/two.go" file2
866 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
867 set ofile2
"[file rootname [file tail $file2]].o"
868 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
869 set ofile3
"[file rootname [file tail $test]].o"
870 set dg
-do-what
-default
"link"
871 set output_file
"./[file rootname [file tail $test]].exe"
872 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
873 $output_file
"executable" "$options"]
874 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
875 verbose
-log $comp_output
876 set result
[go_load
"$output_file" "" ""]
877 set status [lindex $result
0]
879 file
delete $ofile1 $ofile2 $ofile3 $output_file
880 set runtests $hold_runtests
881 } elseif
{ [string match \
882 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
884 set hold_runtests $runtests
885 set runtests
"go-test.exp"
886 set dg
-do-what
-default
"assemble"
887 regsub
"/\[^/\]*$" $test "/embed0.go" file1
888 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
889 set ofile1
"[file rootname [file tail $file1]].o"
890 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
891 set ofile2
"[file rootname [file tail $test]].o"
892 set output_file
"./[file rootname [file tail $test]].exe"
893 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
894 $output_file
"executable" "$options"]
895 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
896 if [string match
"" $comp_output] {
897 set result
[go_load
"$output_file" "" ""]
898 set status [lindex $result
0]
901 verbose
-log $comp_output
904 file
delete $ofile1 $ofile2 $output_file
905 set runtests $hold_runtests
906 } elseif
{ [string match \
907 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
910 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
913 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
917 } elseif
{ [string match \
918 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
923 set hold_runtests $runtests
924 set runtests
"go-test.exp"
925 set dg
-do-what
-default
"assemble"
926 regsub
"\\.go$" $test ".dir/$name1" file1
927 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
928 set ofile1
"[file rootname [file tail $file1]].o"
929 regsub
"\\.go$" $test ".dir/$name2" file2
930 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
931 set ofile2
"[file rootname [file tail $file2]].o"
932 set dg
-do-what
-default
"link"
933 set output_file
"./[file rootname [file tail $file2]].exe"
934 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
935 $output_file
"executable" "$options"]
936 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
937 if [string match
"" $comp_output] {
938 set result
[go_load
"$output_file" "" ""]
939 set status [lindex $result
0]
942 verbose
-log $comp_output
945 file
delete $ofile1 $ofile2 $output_file
946 set runtests $hold_runtests
947 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
948 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
949 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
950 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
951 && $test_line5
== "// \$L bug2.\$A &&" \
952 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
953 set hold_runtests $runtests
954 set runtests
"go-test.exp"
955 set dg
-do-what
-default
"assemble"
956 regsub
"\\.go$" $test ".dir/bug0.go" file0
957 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
958 set ofile0
"[file rootname [file tail $file0]].o"
959 regsub
"\\.go$" $test ".dir/bug1.go" file1
960 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
961 set ofile1
"[file rootname [file tail $file1]].o"
962 regsub
"\\.go$" $test ".dir/bug2.go" file2
963 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
964 set ofile2
"[file rootname [file tail $file2]].o"
965 regsub
"\\.go$" $test ".dir/bug3.go" file3
967 set output_file
"./[file rootname [file tail $test]].exe"
968 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
969 $output_file
"executable" "$options"]
970 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
971 if [string match
"" $comp_output] {
972 set result
[go_load
"$output_file" "" ""]
973 set status [lindex $result
0]
976 verbose
-log $comp_output
979 file
delete $ofile0 $ofile1 $ofile2 $output_file
980 set runtests $hold_runtests
981 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
982 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
983 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
984 set name1
"import2.go"
985 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
986 set name1
"recursive1.go"
988 set hold_runtests $runtests
989 set runtests
"go-test.exp"
990 set dg
-do-what
-default
"assemble"
991 regsub
"/\[^/\]*$" $test "/${name1}" file1
992 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
993 set ofile1
"[file rootname [file tail $file1]].o"
994 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
996 set runtests $hold_runtests
997 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
998 set hold_runtests $runtests
999 set runtests
"go-test.exp"
1000 set dg
-do-what
-default
"assemble"
1001 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
1002 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1003 set ofile1
"[file rootname [file tail $file1]].o"
1004 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1005 set ofile2
"[file rootname [file tail $test]].o"
1006 set output_file
"./[file rootname [file tail $test]].exe"
1007 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
1008 $output_file
"executable" "$options"]
1009 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1010 if [string match
"" $comp_output] {
1011 set result
[go_load
"$output_file" "" ""]
1012 set status [lindex $result
0]
1015 verbose
-log $comp_output
1018 file
delete $ofile1 $ofile2 $output_file
1019 set runtests $hold_runtests
1020 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1021 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1022 set output_file
"./[file rootname [file tail $test]].o"
1023 set comp_output
[go_target_compile
"$test $test2" \
1024 $output_file
"executable" "$options"]
1025 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1026 if [string match
"" $comp_output] {
1027 set result
[go_load
"$output_file" "" ""]
1028 set status [lindex $result
0]
1031 verbose
-log $comp_output
1034 file
delete $output_file
1035 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1036 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1037 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1038 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1039 set go_execute_args
""
1040 set hold_runtests $runtests
1041 set runtests
"go-test.exp"
1042 set dg
-do-what
-default
"link"
1043 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1044 set output_file
"./[file rootname [file tail $test]].exe"
1046 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1047 fail
"$name execution 0"
1049 pass
"$name execution 0"
1051 # Disable optimizations as this test takes a long time
1053 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1054 go
-torture
-execute "./tmp.go"
1056 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1057 fail
"$name execution 1"
1059 pass
"$name execution 1"
1062 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1063 fail
"$name execution 2"
1065 pass
"$name execution 2"
1070 file
delete $output_file
1071 set runtests $hold_runtests
1072 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1073 && $test_line2
== "// errchk \$G -e tmp.go" } {
1074 set go_execute_args
""
1075 set hold_runtests $runtests
1076 set runtests
"go-test.exp"
1077 set dg
-do-what
-default
"link"
1078 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1079 set output_file
"./[file rootname [file tail $test]].exe"
1081 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1082 fail
"$name execution"
1084 pass
"$name execution"
1089 file
delete $output_file
1090 set runtests $hold_runtests
1091 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1092 regsub
"\\.go$" $test ".dir/a.go" file1
1093 regsub
"\\.go$" $test ".dir/b.go" file2
1094 errchk
"$file1" "$file2"
1095 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1096 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1097 && $test_line3
== "// run" } {
1098 set hold_runtests $runtests
1099 set runtests
"go-test.exp"
1100 set dg
-do-what
-default
"assemble"
1101 regsub
"\\.go$" $test ".dir/pkg.go" file1
1102 dg
-test
-keep
-output $file1
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1103 set ofile1
"[file rootname [file tail $file1]].o"
1104 file
rename -force $ofile1 slow.o
1105 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1106 file
rename -force $ofile1 fast.o
1107 set ofile2
"[file rootname [file tail $test]].o"
1108 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1109 set output_file
"./[file rootname [file tail $test]].exe"
1110 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1111 $output_file
"executable" "$options"]
1112 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1113 if [string match
"" $comp_output] {
1114 set result
[go_load
"$output_file" "" ""]
1115 set status [lindex $result
0]
1118 verbose
-log $comp_output
1121 file
delete slow.o fast.o $ofile2 $output_file
1122 set runtests $hold_runtests
1123 } elseif
{ [string match \
1124 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1126 set hold_runtests $runtests
1127 set runtests
"go-test.exp"
1128 set dg
-do-what
-default
"assemble"
1129 regsub
"\\.go$" $test ".dir/pkg.go" file1
1130 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1131 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1132 file
delete "[file rootname [file tail $file1]].o"
1133 set runtests $hold_runtests
1134 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1136 set hold_runtests $runtests
1137 set runtests
"go-test.exp"
1138 set dg
-do-what
-default
"assemble"
1139 regsub
"\\.go$" $test ".dir/one.go" file1
1140 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1141 set ofile1
"[file rootname [file tail $file1]].o"
1142 regsub
"\\.go$" $test ".dir/two.go" file2
1143 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1145 set runtests $hold_runtests
1146 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1147 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1148 # These tests
import the same package under two different
1149 # names
, which gccgo does not support.
1150 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1151 # This tests whether initializers are written out
1152 # statically. gccgo does not provide a way to test that
,
1153 # as an initializer will be generated
for any code which
1154 # has global variables which need to be registered as GC
1156 } elseif
{ $test_line
== "// errorcheck -0 -m"
1157 || $test_line
== "// errorcheck -0 -m -l" } {
1158 # This tests debug output of the gc compiler
, which is
1159 # meaningless
for gccgo.
1160 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1161 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1162 # This tests specific handling of the gc compiler
on types
1163 # that are too large. It is target specific in a way I
1164 # haven
't bothered to check for here.
1165 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1166 # This tests the gc ld -X option, which gccgo does not
1168 } elseif { $test_line == "// \$G \$D/pkg.go && pack grc pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && errchk \$G -I. -u \$D/main.go"
1169 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1170 # This tests the gc -u option, which gccgo does not
1172 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1173 || $test_line == "// errorcheck -0 -d=nil" } {
1174 # This tests gc nil pointer checks using -d=nil, which
1175 # gccgo does not support.
1177 clone_output "$name: unrecognized test line: $test_line"
1181 set go_compile_args ""
1182 set go_execute_args ""
1183 set TORTURE_OPTIONS [list { -O2 -g }]
1184 gcc_parallel_test_enable 1
1187 set dg-do-what-default ${saved-dg-do-what-default}
1188 set TORTURE_OPTIONS $saved_torture_options