1 # Copyright
(C
) 2009-2024 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 set goarch "loongarch64"
239 if [check_effective_target_ilp32] {
246 if [check_effective_target_ilp32] {
253 perror "$target_triplet: unhandled architecture"
257 verbose -log "Setting GOARCH=$goarch" 1
258 setenv GOARCH $goarch
261 # This be kept in sync with libgo/configure.ac.
262 proc go-set-goos { } {
263 global target_triplet
265 switch -glob $target_triplet {
300 perror "$target_triplet: unhandled GOOS"
304 verbose -log "Setting GOOS=$goos" 1
308 # Take a list of files and return a lists of lists, where each list is
309 # the set of files in the same package.
310 proc go-find-packages { test name files } {
315 if { [gets $fd line] < 0 } {
317 clone_output "$test: could not read $f"
322 if { [regexp "^package (\\w+)" $line match package] } {
323 set len [llength $packages]
324 for { set i 0 } { $i < $len } { incr i } {
325 set p [lindex $packages $i]
326 if { [lindex $p 0] == $package } {
333 lappend packages [list $package $f]
344 proc go-gc-match { name } {
345 verbose -log "go-gc-match $name"
346 set idx [string first "," $name]
348 set left [string range $name 0 [expr $idx - 1]]
349 set right [string range $name [expr $idx + 1] end]
350 return [expr [go-gc-match $left] && [go-gc-match $right]]
352 if { [string index $name 0] == "!" && [string index $name 1] == "!" } {
355 if { [string index $name 0] == "!" } {
356 return [expr ! [go-gc-match [string range $name 1 end]]]
358 if { $name == [getenv GOARCH] || $name == [getenv GOOS] || $name == "gccgo" } {
365 proc go-gc-tests { } {
368 global GCC_UNDER_TEST
370 global TORTURE_OPTIONS
371 global dg-do-what-default
372 global go_compile_args
373 global go_execute_args
374 global target_triplet
376 # If a testcase doesn't have special options
, use these.
377 global DEFAULT_GOCFLAGS
378 if ![info exists DEFAULT_GOCFLAGS
] {
379 set DEFAULT_GOCFLAGS
" -pedantic-errors"
383 lappend options
"additional_flags=$DEFAULT_GOCFLAGS"
385 #
Set GOARCH and GOOS
for tests that need it.
389 # Running all the torture options takes too long and
, since the
390 # frontend ignores the standard options
, it doesn
't significantly
392 set saved_torture_options $TORTURE_OPTIONS
393 set TORTURE_OPTIONS [list { -O2 -g }]
395 set saved-dg-do-what-default ${dg-do-what-default}
399 set tests [lsort [find $srcdir/$subdir *.go]]
400 foreach test $tests {
401 if ![runtest_file_p $runtests $test] {
405 # Skip the files in bench; they are not tests.
406 if [string match "*go.test/test/bench/*" $test] {
410 # Skip the files in stress; they are not tests.
411 if [string match "*go.test/test/stress/*" $test] {
415 # Skip the files in safe; gccgo does not support safe mode.
416 if [string match "*go.test/test/safe/*" $test] {
420 # Skip files in sub-subdirectories: they are components of
422 if [string match "*go.test/test/*/*/*" $test] {
426 # Skip files in *.dir subdirectories: they are components of
428 if [string match "*go.test/test/*.dir/*" $test] {
432 set name [dg-trim-dirname $srcdir $test]
434 # Skip certain tests if target is RTEMS OS.
435 if [istarget "*-*-rtems*"] {
436 if { [string match "*go.test/test/args.go" $test] \
437 || [string match "*go.test/test/env.go" $test] } {
438 untested "$name: uses the command-line or environment variables"
442 if { [string match "*go.test/test/stack.go" $test] \
443 || [string match "*go.test/test/peano.go" $test] \
444 || [string match "*go.test/test/chan/goroutines.go" $test] } {
445 untested "$name: has very high memory requirement"
450 # Handle certain tests in a target-dependant way.
451 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] || [istarget "s390*-*-*"] } {
452 if { [string match "*go.test/test/nilptr.go" $test] } {
458 if [check_effective_target_pie_enabled] {
463 if { [file tail $test] == "init1.go" } {
464 # This tests whether GC runs during init, which for gccgo
465 # it currently does not.
470 if { [file tail $test] == "closure.go" } {
471 # This tests whether function closures do any memory
472 # allocation, which for gccgo they currently do.
477 if { ( [file tail $test] == "select2.go" \
478 || [file tail $test] == "stack.go" \
479 || [file tail $test] == "peano.go" \
480 || [file tail $test] == "nilptr2.go" \
481 || [file tail $test] == "index0.go" ) \
482 && ! [check_effective_target_split_stack] } {
483 # These tests fails on targets without split stack.
488 if [string match "*go.test/test/rotate\[0123\].go" $test] {
489 # These tests produces a temporary file that takes too long
490 # to compile--5 minutes on my laptop without optimization.
491 # When compiling without optimization it tests nothing
492 # useful, since the point of the test is to see whether
493 # the compiler generates rotate instructions.
498 if { [file tail $test] == "bug347.go" \
499 || [file tail $test] == "bug348.go" } {
500 # These tests don't work
if the functions are inlined.
501 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
504 set fd
[open $test r
]
510 if { [gets $fd file_line
] < 0 } {
514 clone_output
"$test: read failed"
520 if { [ string match
"*nacl*exit 0*" $file_line ] \
521 ||
[ string match
"*exit 0*nacl*" $file_line ] \
522 ||
[ string match
"*Android*exit 0*" $file_line ] \
523 ||
[ string match
"*exit 0*Android*" $file_line ] \
524 ||
[ string match
"*\"\$GOOS\" == windows*" $file_line ] } {
528 if ![string match
"// *" $file_line] {
529 if { $file_line
!= "" } {
535 if { [ string match
"// +build *" $file_line ] } {
536 set words
[split $file_line
]
538 for { set idx
2 } { $idx
< [llength $words
] } { incr idx
} {
539 if { [go
-gc
-match
[lindex $words $idx
]] } {
544 if { $matches
== 1 } {
552 if { $test_line
== "" } {
553 set test_line $file_line
559 if { $lines_ok
== 0 } {
563 # runtest_file_p is already run above
, and the code below can run
564 # runtest_file_p again
, make sure everything
for this test is
565 # performed
if the above runtest_file_p decided this runtest
566 # instance should
execute the test
567 gcc_parallel_test_enable
0
569 set go_compile_args
""
570 set go_execute_args
""
571 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
572 && ! [string match
"*.go*" "$progargs"] } {
573 set go_execute_args $progargs
574 verbose
-log "$test: go_execute_args is $go_execute_args"
575 set index
[string last
" $progargs" $test_line]
576 set test_line
[string replace $test_line $index end
]
577 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
578 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
579 # goroutines.go spawns by default
10000 threads
, which is too much
581 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
582 set go_execute_args
64
583 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
584 # When using low ulimit
-u
limit, use maximum of
585 # a quarter of that
limit and
10000 even when running expensive
586 # tests
, otherwise parallel tests might fail after fork failures.
587 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
588 if { [string is
integer -strict $nproc
] } {
589 set nproc
[expr $nproc
/ 4]
590 if { $nproc
> 10000 } { set nproc
10000 }
591 if { $nproc
< 16 } { set nproc
16 }
592 set go_execute_args $nproc
595 if { "$go_execute_args" != "" } {
596 verbose
-log "$test: go_execute_args is $go_execute_args"
600 if { $test_line
== "// compile"
601 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
602 # This is a vanilla
compile test.
603 set dg
-do-what
-default
"assemble"
604 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
605 } elseif
{ $test_line
== "// run"
606 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
607 # This is a vanilla execution test.
608 go
-torture
-execute $test
609 file
delete core
[glob
-nocomplain core.
*]
610 } elseif
{ $test_line
== "// build" } {
611 # This is a vanilla
compile and link test.
612 set dg
-do-what
-default
"link"
613 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
614 } elseif
{ [string match
"// runoutput*" $test_line] \
615 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
616 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
617 # Run the test to
get a .go
program to run.
618 set go_execute_args
""
619 set hold_runtests $runtests
620 set runtests
"go-test.exp"
622 if { [string match
"// runoutput*" $test_line] } {
624 regsub
"// runoutput\(.*\)" $test_line "\\1" args
626 lappend files
"[file dirname $test]/$f"
629 set dg
-do-what
-default
"link"
630 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
631 set output_file
"./[file rootname [file tail $test]].exe"
632 set base
"[file rootname [file tail $test]]"
634 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
635 fail
"$name execution"
637 pass
"$name execution"
638 file
delete $base
-out.x
639 # Disable optimizations as some of these tests
640 # take a long time to
compile.
641 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
642 go
-torture
-execute "./$base-out.go"
644 file
delete $base
-out.go
646 file
delete $output_file
647 set runtests $hold_runtests
648 } elseif
{ $test_line
== "// cmpout" \
649 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
650 # This is an execution test
for which we need to check the
652 set hold_runtests $runtests
653 set runtests
"go-test.exp"
654 set dg
-do-what
-default
"link"
655 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
656 set output_file
"./[file rootname [file tail $test]].exe"
657 set base
"[file rootname [file tail $test]]"
659 verbose
-log "$output_file >$base.p 2>&1"
660 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
661 verbose
-log $catcherr
662 fail
"$name execution"
663 untested
"$name compare"
665 pass
"$name execution"
666 regsub
"\\.go$" $test ".out" expect
667 filecmp $expect $base.p
"$name compare"
668 file
delete $output_file
672 untested
"$name execution"
673 untested
"$name compare"
675 set runtests $hold_runtests
676 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
678 go
-execute-xfail $test
679 } elseif
{ $test_line
== "// errorcheck" } {
681 } elseif
{ $test_line
== "// errorcheckdir" || $test_line == "// errorcheckdir -n" } {
682 set hold_runtests $runtests
683 set runtests
"go-test.exp"
684 set dir "[file rootname $test].dir"
685 set files
[lsort
[glob
"$dir/*.go"]]
686 set packages
[go
-find
-packages $test $
name $files
]
687 if { [llength $packages
] > 0 } {
688 set dg
-do-what
-default
"assemble"
690 set last
[lindex $packages end
]
691 set packages
[lreplace $packages end end
]
692 foreach p $packages
{
693 dg
-test
-keep
-output
[lrange $p
1 end
] "-O -I." "-w $DEFAULT_GOCFLAGS"
694 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
696 errchk
[lindex $last
1] "[lrange $last 2 end]"
701 set runtests $hold_runtests
702 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
703 # Run the test to
get a .go
program to error check.
704 set go_execute_args
""
705 set hold_runtests $runtests
706 set runtests
"go-test.exp"
708 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
710 lappend files
"[file dirname $test]/$f"
712 set dg
-do-what
-default
"link"
713 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
714 set output_file
"./[file rootname [file tail $test]].exe"
715 set base
"[file rootname [file tail $test]]"
717 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
718 fail
"$name execution"
720 pass
"$name execution"
721 errchk
"$base-out.go" ""
723 file
delete $base
-out.go
725 file
delete $output_file
726 set runtests $hold_runtests
727 } elseif
{ $test_line
== "// compiledir" } {
728 set hold_runtests $runtests
729 set runtests
"go-test.exp"
730 set dg
-do-what
-default
"assemble"
731 set dir "[file rootname $test].dir"
732 set files
[lsort
[glob
"$dir/*.go"]]
733 set packages
[go
-find
-packages $test $
name $files
]
734 if { [llength $packages
] > 0 } {
736 foreach p $packages
{
737 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O -I." "-w $DEFAULT_GOCFLAGS"
738 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
744 set runtests $hold_runtests
745 } elseif
{ $test_line
== "// rundir" } {
746 set hold_runtests $runtests
747 set runtests
"go-test.exp"
748 set dir "[file rootname $test].dir"
749 set files
[lsort
[glob
"$dir/*.go"]]
750 set packages
[go
-find
-packages $test $
name $files
]
751 if { [llength $packages
] > 0 } {
752 set dg
-do-what
-default
"assemble"
754 set last
[lindex $packages end
]
755 set packages
[lreplace $packages end end
]
756 foreach p $packages
{
757 dg
-test
-keep
-output
[lrange $p
1 end
] "-O -I." "-w $DEFAULT_GOCFLAGS"
758 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
760 set dg
-do-what
-default
"link"
761 set go_compile_args
""
762 append go_compile_args
[lrange $last
2 end
]
763 append go_compile_args $del
764 go
-torture
-execute [lindex $last
1]
769 set runtests $hold_runtests
770 } elseif
{ $test_line
== "// rundircmpout" } {
771 set hold_runtests $runtests
772 set runtests
"go-test.exp"
773 set dir "[file rootname $test].dir"
774 set files
[lsort
[glob
"$dir/*.go"]]
775 set packages
[go
-find
-packages $test $
name $files
]
776 if { [llength $packages
] > 0 } {
777 set dg
-do-what
-default
"assemble"
779 set last
[lindex $packages end
]
780 set packages
[lreplace $packages end end
]
781 foreach p $packages
{
782 dg
-test
-keep
-output
[lrange $p
1 end
] "-O -I." "-w $DEFAULT_GOCFLAGS"
783 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
785 set dg
-do-what
-default
"link"
786 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O -I." "-w $DEFAULT_GOCFLAGS"
787 set base
"[file rootname [file tail [lindex $last 1]]]"
788 set output_file
"./$base.exe"
789 lappend del $output_file
791 verbose
-log "$output_file >$base.p 2>&1"
792 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
793 verbose
-log $catcherr
794 fail
"$name execution"
795 untested
"$name compare"
797 pass
"$name execution"
798 regsub
"\\.go$" "$test" ".out" expect
799 filecmp $expect $base.p
"$name compare"
807 set runtests $hold_runtests
808 } elseif
{ "$test_line" == ""
809 ||
[string match
"// true*" $test_line]
810 ||
[string match
"// skip*" $test_line] } {
811 # Not a real test
, just ignore.
812 } elseif
{ [string match \
813 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
816 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
819 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
823 } elseif
{ [string match \
824 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
829 set hold_runtests $runtests
830 set runtests
"go-test.exp"
831 set dg
-do-what
-default
"assemble"
832 regsub
"\\.go$" $test ".dir/$name1" file1
833 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
834 regsub
"\\.go$" $test ".dir/$name2" file2
836 file
delete "[file rootname [file tail $file1]].o"
837 set runtests $hold_runtests
838 } elseif
{ [string match \
839 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
841 set hold_runtests $runtests
842 set runtests
"go-test.exp"
843 set dg
-do-what
-default
"assemble"
844 regsub
"\\.go$" $test "1.go" file1
845 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
847 file
delete "[file rootname [file tail $file1]].o"
848 set runtests $hold_runtests
849 } elseif
{ [string match \
850 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
852 set hold_runtests $runtests
853 set runtests
"go-test.exp"
854 set dg
-do-what
-default
"assemble"
855 regsub
"\\.go$" $test ".dir/bug0.go" file1
856 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
857 regsub
"\\.go$" $test ".dir/bug1.go" file2
858 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
859 regsub
"\\.go$" $test ".dir/bug2.go" file3
861 file
delete "[file rootname [file tail $file1]].o"
862 file
delete "[file rootname [file tail $file2]].o"
863 set runtests $hold_runtests
864 } elseif
{ [string match \
865 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
868 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
870 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
871 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
872 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
874 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
878 } elseif
{ [string match \
879 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
883 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
886 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
889 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
890 set name1
"method4a.go"
893 set hold_runtests $runtests
894 set runtests
"go-test.exp"
895 set dg
-do-what
-default
"assemble"
896 regsub
"\\.go$" $test ".dir/$name1" file1
897 if { $name1
== "method4a.go" } {
898 set file1
"[file dirname $test]/method4a.go"
900 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
901 set ofile1
"[file rootname [file tail $file1]].o"
902 regsub
"\\.go$" $test ".dir/$name2" file2
903 if { $name2
== "" } {
906 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
907 set ofile2
"[file rootname [file tail $file2]].o"
908 set dg
-do-what
-default
"link"
909 set output_file
"./[file rootname [file tail $test]].exe"
910 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
911 $output_file
"executable" "$options"]
912 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
913 verbose
-log $comp_output
914 set result
[go_load
"$output_file" "" ""]
915 set status [lindex $result
0]
917 file
delete $ofile1 $ofile2 $output_file
918 set runtests $hold_runtests
919 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
920 set hold_runtests $runtests
921 set runtests
"go-test.exp"
922 set dg
-do-what
-default
"assemble"
923 regsub
"\\.go$" $test ".dir/one.go" file1
924 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
925 set ofile1
"[file rootname [file tail $file1]].o"
926 regsub
"\\.go$" $test ".dir/two.go" file2
927 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
928 set ofile2
"[file rootname [file tail $file2]].o"
929 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
930 set ofile3
"[file rootname [file tail $test]].o"
931 set dg
-do-what
-default
"link"
932 set output_file
"./[file rootname [file tail $test]].exe"
933 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
934 $output_file
"executable" "$options"]
935 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
936 verbose
-log $comp_output
937 set result
[go_load
"$output_file" "" ""]
938 set status [lindex $result
0]
940 file
delete $ofile1 $ofile2 $ofile3 $output_file
941 set runtests $hold_runtests
942 } elseif
{ [string match \
943 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
945 set hold_runtests $runtests
946 set runtests
"go-test.exp"
947 set dg
-do-what
-default
"assemble"
948 regsub
"/\[^/\]*$" $test "/embed0.go" file1
949 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
950 set ofile1
"[file rootname [file tail $file1]].o"
951 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
952 set ofile2
"[file rootname [file tail $test]].o"
953 set output_file
"./[file rootname [file tail $test]].exe"
954 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
955 $output_file
"executable" "$options"]
956 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
957 if [string match
"" $comp_output] {
958 set result
[go_load
"$output_file" "" ""]
959 set status [lindex $result
0]
962 verbose
-log $comp_output
965 file
delete $ofile1 $ofile2 $output_file
966 set runtests $hold_runtests
967 } elseif
{ [string match \
968 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
971 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
974 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
978 } elseif
{ [string match \
979 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
984 set hold_runtests $runtests
985 set runtests
"go-test.exp"
986 set dg
-do-what
-default
"assemble"
987 regsub
"\\.go$" $test ".dir/$name1" file1
988 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
989 set ofile1
"[file rootname [file tail $file1]].o"
990 regsub
"\\.go$" $test ".dir/$name2" file2
991 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
992 set ofile2
"[file rootname [file tail $file2]].o"
993 set dg
-do-what
-default
"link"
994 set output_file
"./[file rootname [file tail $file2]].exe"
995 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
996 $output_file
"executable" "$options"]
997 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
998 if [string match
"" $comp_output] {
999 set result
[go_load
"$output_file" "" ""]
1000 set status [lindex $result
0]
1003 verbose
-log $comp_output
1006 file
delete $ofile1 $ofile2 $output_file
1007 set runtests $hold_runtests
1008 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
1009 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
1010 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
1011 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
1012 && $test_line5
== "// \$L bug2.\$A &&" \
1013 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
1014 set hold_runtests $runtests
1015 set runtests
"go-test.exp"
1016 set dg
-do-what
-default
"assemble"
1017 regsub
"\\.go$" $test ".dir/bug0.go" file0
1018 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
1019 set ofile0
"[file rootname [file tail $file0]].o"
1020 regsub
"\\.go$" $test ".dir/bug1.go" file1
1021 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
1022 set ofile1
"[file rootname [file tail $file1]].o"
1023 regsub
"\\.go$" $test ".dir/bug2.go" file2
1024 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1025 set ofile2
"[file rootname [file tail $file2]].o"
1026 regsub
"\\.go$" $test ".dir/bug3.go" file3
1028 set output_file
"./[file rootname [file tail $test]].exe"
1029 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
1030 $output_file
"executable" "$options"]
1031 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
1032 if [string match
"" $comp_output] {
1033 set result
[go_load
"$output_file" "" ""]
1034 set status [lindex $result
0]
1037 verbose
-log $comp_output
1040 file
delete $ofile0 $ofile1 $ofile2 $output_file
1041 set runtests $hold_runtests
1042 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
1043 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
1044 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
1045 set name1
"import2.go"
1046 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
1047 set name1
"recursive1.go"
1049 set hold_runtests $runtests
1050 set runtests
"go-test.exp"
1051 set dg
-do-what
-default
"assemble"
1052 regsub
"/\[^/\]*$" $test "/${name1}" file1
1053 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1054 set ofile1
"[file rootname [file tail $file1]].o"
1055 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1057 set runtests $hold_runtests
1058 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1059 set hold_runtests $runtests
1060 set runtests
"go-test.exp"
1061 set dg
-do-what
-default
"assemble"
1062 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
1063 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1064 set ofile1
"[file rootname [file tail $file1]].o"
1065 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1066 set ofile2
"[file rootname [file tail $test]].o"
1067 set output_file
"./[file rootname [file tail $test]].exe"
1068 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
1069 $output_file
"executable" "$options"]
1070 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1071 if [string match
"" $comp_output] {
1072 set result
[go_load
"$output_file" "" ""]
1073 set status [lindex $result
0]
1076 verbose
-log $comp_output
1079 file
delete $ofile1 $ofile2 $output_file
1080 set runtests $hold_runtests
1081 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1082 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1083 set output_file
"./[file rootname [file tail $test]].o"
1084 set comp_output
[go_target_compile
"$test $test2" \
1085 $output_file
"executable" "$options"]
1086 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1087 if [string match
"" $comp_output] {
1088 set result
[go_load
"$output_file" "" ""]
1089 set status [lindex $result
0]
1092 verbose
-log $comp_output
1095 file
delete $output_file
1096 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1097 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1098 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1099 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1100 set go_execute_args
""
1101 set hold_runtests $runtests
1102 set runtests
"go-test.exp"
1103 set dg
-do-what
-default
"link"
1104 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1105 set output_file
"./[file rootname [file tail $test]].exe"
1107 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1108 fail
"$name execution 0"
1110 pass
"$name execution 0"
1112 # Disable optimizations as this test takes a long time
1114 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1115 go
-torture
-execute "./tmp.go"
1117 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1118 fail
"$name execution 1"
1120 pass
"$name execution 1"
1123 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1124 fail
"$name execution 2"
1126 pass
"$name execution 2"
1131 file
delete $output_file
1132 set runtests $hold_runtests
1133 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1134 && $test_line2
== "// errchk \$G -e tmp.go" } {
1135 set go_execute_args
""
1136 set hold_runtests $runtests
1137 set runtests
"go-test.exp"
1138 set dg
-do-what
-default
"link"
1139 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1140 set output_file
"./[file rootname [file tail $test]].exe"
1142 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1143 fail
"$name execution"
1145 pass
"$name execution"
1150 file
delete $output_file
1151 set runtests $hold_runtests
1152 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1153 regsub
"\\.go$" $test ".dir/a.go" file1
1154 regsub
"\\.go$" $test ".dir/b.go" file2
1155 errchk
"$file1" "$file2"
1156 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1157 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1158 && $test_line3
== "// run" } {
1159 set hold_runtests $runtests
1160 set runtests
"go-test.exp"
1161 set dg
-do-what
-default
"assemble"
1162 regsub
"\\.go$" $test ".dir/pkg.go" file1
1163 dg
-test
-keep
-output $file1
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1164 set ofile1
"[file rootname [file tail $file1]].o"
1165 file
rename -force $ofile1 slow.o
1166 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1167 file
rename -force $ofile1 fast.o
1168 set ofile2
"[file rootname [file tail $test]].o"
1169 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1170 set output_file
"./[file rootname [file tail $test]].exe"
1171 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1172 $output_file
"executable" "$options"]
1173 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1174 if [string match
"" $comp_output] {
1175 set result
[go_load
"$output_file" "" ""]
1176 set status [lindex $result
0]
1179 verbose
-log $comp_output
1182 file
delete slow.o fast.o $ofile2 $output_file
1183 set runtests $hold_runtests
1184 } elseif
{ [string match \
1185 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1187 set hold_runtests $runtests
1188 set runtests
"go-test.exp"
1189 set dg
-do-what
-default
"assemble"
1190 regsub
"\\.go$" $test ".dir/pkg.go" file1
1191 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1192 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1193 file
delete "[file rootname [file tail $file1]].o"
1194 set runtests $hold_runtests
1195 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1197 set hold_runtests $runtests
1198 set runtests
"go-test.exp"
1199 set dg
-do-what
-default
"assemble"
1200 regsub
"\\.go$" $test ".dir/one.go" file1
1201 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1202 set ofile1
"[file rootname [file tail $file1]].o"
1203 regsub
"\\.go$" $test ".dir/two.go" file2
1204 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1206 set runtests $hold_runtests
1207 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1208 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1209 # These tests
import the same package under two different
1210 # names
, which gccgo does not support.
1211 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1212 # This tests whether initializers are written out
1213 # statically. gccgo does not provide a way to test that
,
1214 # as an initializer will be generated
for any code which
1215 # has global variables which need to be registered as GC
1217 } elseif
{ $test_line
== "// errorcheck -0 -m"
1218 || $test_line
== "// errorcheck -0 -m -l" } {
1219 # This tests debug output of the gc compiler
, which is
1220 # meaningless
for gccgo.
1221 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1222 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1223 # This tests specific handling of the gc compiler
on types
1224 # that are too large. It is target specific in a way I
1225 # haven
't bothered to check for here.
1226 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1227 # This tests the gc ld -X option, which gccgo does not
1229 } 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"
1230 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1231 # This tests the gc -u option, which gccgo does not
1233 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1234 || $test_line == "// errorcheck -0 -d=nil" } {
1235 # This tests gc nil pointer checks using -d=nil, which
1236 # gccgo does not support.
1238 clone_output "$name: unrecognized test line: $test_line"
1242 set go_compile_args ""
1243 set go_execute_args ""
1244 set TORTURE_OPTIONS [list { -O2 -g }]
1245 gcc_parallel_test_enable 1
1248 set dg-do-what-default ${saved-dg-do-what-default}
1249 set TORTURE_OPTIONS $saved_torture_options