1 # Copyright
(C
) 2009-2014 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 regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" 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 "\\\\\\\\\\\[" 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 "\\\\\\\\\\\]" out_line
117 if [string match "*dg-error*.\**" $out_line] {
118 # I worked out the right number of backslashes by
119 # experimentation, not analysis.
120 regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
122 if [string match "*dg-error*\\\[?\\\]*" $out_line] {
123 set index [string first "dg-error" $out_line]
124 regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
126 if [string match "*dg-error*\{*" $out_line] {
127 set index [string first "dg-error" $out_line]
128 regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
130 if [string match "*dg-error*\}*\}" $out_line] {
131 set index [string first "dg-error" $out_line]
132 regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
134 if [string match "*dg-error*\(*" $out_line] {
135 set index [string first "dg-error" $out_line]
136 regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
138 if [string match "*dg-error*\)*\}" $out_line] {
139 set index [string first "dg-error" $out_line]
140 regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
142 # Special case for bug332, in which the error message wants to
143 # match the file name, which is not what dg-error expects.
144 if [string match "*dg-error*bug332*" $out_line] {
145 set index [string first "dg-error" $out_line]
146 regsub -start $index "bug332" $out_line "undefined type" out_line
148 puts $fdout $out_line
153 set hold_runtests $runtests
154 set runtests "go-test.exp"
155 go-dg-runtest $filename "" "-fno-show-column $DEFAULT_GOCFLAGS $opts"
156 set runtests $hold_runtests
158 file delete $filename
159 set dg-do-what-default ${saved-dg-do-what-default}
162 # This is an execution test which should fail.
163 proc go-execute-xfail { test } {
164 global DEFAULT_GOCFLAGS
167 set filename [file tail $test]
168 set fdin [open $test r]
169 set fdout [open $filename w]
170 puts $fdout "// { dg-do run { xfail *-*-* } }"
171 while { [gets $fdin copy_line] >= 0 } {
172 puts $fdout $copy_line
177 set hold_runtests $runtests
178 set runtests "go-test.exp"
179 go-dg-runtest $filename "" "-w $DEFAULT_GOCFLAGS"
180 set runtests $hold_runtests
182 file delete $filename
185 # N.B. Keep in sync with libgo/configure.ac.
186 proc go-set-goarch { } {
187 global target_triplet
189 switch -glob $target_triplet {
204 if [check_effective_target_ia32] {
211 if [check_no_compiler_messages mipso32 assembly {
212 #if _MIPS_SIM != _ABIO32
217 } elseif [check_no_compiler_messages mipsn32 assembly {
218 #if _MIPS_SIM != _ABIN32
223 } elseif [check_no_compiler_messages mipsn64 assembly {
224 #if _MIPS_SIM != _ABI64
229 } elseif [check_no_compiler_messages mipso64 assembly {
230 #if _MIPS_SIM != _ABIO64
236 perror "$target_triplet: unrecognized MIPS ABI"
241 if [check_effective_target_ilp32] {
244 if [istarget "powerpc64le-*-*"] {
258 if [check_effective_target_ilp32] {
265 perror "$target_triplet: unhandled architecture"
269 verbose -log "Setting GOARCH=$goarch" 1
270 setenv GOARCH $goarch
273 # Take a list of files and return a lists of lists, where each list is
274 # the set of files in the same package.
275 proc go-find-packages { test name files } {
280 if { [gets $fd line] < 0 } {
282 clone_output "$test: could not read $f"
287 if { [regexp "^package (\\w+)" $line match package] } {
288 set len [llength $packages]
289 for { set i 0 } { $i < $len } { incr i } {
290 set p [lindex $packages $i]
291 if { [lindex $p 0] == $package } {
298 lappend packages [list $package $f]
309 proc go-gc-tests { } {
312 global GCC_UNDER_TEST
314 global TORTURE_OPTIONS
315 global dg-do-what-default
316 global go_compile_args
317 global go_execute_args
318 global target_triplet
320 # If a testcase doesn't have special options
, use these.
321 global DEFAULT_GOCFLAGS
322 if ![info exists DEFAULT_GOCFLAGS
] {
323 set DEFAULT_GOCFLAGS
" -pedantic-errors"
327 lappend options
"additional_flags=$DEFAULT_GOCFLAGS"
329 #
Set GOARCH
for tests that need it.
332 # Running all the torture options takes too long and
, since the
333 # frontend ignores the standard options
, it doesn
't significantly
335 set saved_torture_options $TORTURE_OPTIONS
336 set TORTURE_OPTIONS [list { -O2 -g }]
338 set saved-dg-do-what-default ${dg-do-what-default}
342 set tests [lsort [find $srcdir/$subdir *.go]]
343 foreach test $tests {
344 if ![runtest_file_p $runtests $test] {
348 # Skip the files in bench; they are not tests.
349 if [string match "*go.test/test/bench/*" $test] {
353 # Skip the files in stress; they are not tests.
354 if [string match "*go.test/test/stress/*" $test] {
358 # Skip the files in safe; gccgo does not support safe mode.
359 if [string match "*go.test/test/safe/*" $test] {
363 # Skip files in sub-subdirectories: they are components of
365 if [string match "*go.test/test/*/*/*" $test] {
369 # Skip files in *.dir subdirectories: they are components of
371 if [string match "*go.test/test/*.dir/*" $test] {
375 set name [dg-trim-dirname $srcdir $test]
377 # Skip certain tests if target is RTEMS OS.
378 if [istarget "*-*-rtems*"] {
379 if { [string match "*go.test/test/args.go" $test] \
380 || [string match "*go.test/test/env.go" $test] } {
381 untested "$name: uses the command-line or environment variables"
385 if { [string match "*go.test/test/stack.go" $test] \
386 || [string match "*go.test/test/peano.go" $test] \
387 || [string match "*go.test/test/chan/goroutines.go" $test] } {
388 untested "$name: has very high memory requirement"
393 # Handle certain tests in a target-dependant way.
394 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] } {
395 if { [string match "*go.test/test/nilptr.go" $test] } {
401 if { [file tail $test] == "init1.go" } {
402 # This tests whether GC runs during init, which for gccgo
403 # it currently does not.
408 if { [file tail $test] == "closure.go" } {
409 # This tests whether function closures do any memory
410 # allocation, which for gccgo they currently do.
415 if { ( [file tail $test] == "select2.go" \
416 || [file tail $test] == "stack.go" \
417 || [file tail $test] == "peano.go" ) \
418 && ! [check_effective_target_split_stack] } {
419 # These tests fails on targets without split stack.
424 if [string match "*go.test/test/rotate\[0123\].go" $test] {
425 # These tests produces a temporary file that takes too long
426 # to compile--5 minutes on my laptop without optimization.
427 # When compiling without optimization it tests nothing
428 # useful, since the point of the test is to see whether
429 # the compiler generates rotate instructions.
434 if { [file tail $test] == "bug347.go" \
435 || [file tail $test] == "bug348.go" } {
436 # These tests don't work
if the functions are inlined.
437 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
440 set fd
[open $test r
]
445 if { [gets $fd test_line
] < 0 } {
447 clone_output
"$test: could not read first line"
453 if { [ string match
"*nacl*exit 0*" $test_line ] \
454 ||
[ string match
"*exit 0*nacl*" $test_line ] \
455 ||
[ string match
"*Android*exit 0*" $test_line ] \
456 ||
[ string match
"*exit 0*Android*" $test_line ] \
457 ||
[ string match
"*\"\$GOOS\" == windows*" $test_line ] } {
461 if { [ string match
"// +build *" $test_line ] } {
464 if { [ regexp
-line
"\[ \][getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
466 } elseif
{ [ regexp
-line
"\[ \]\![getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
468 } elseif
{ [ regexp
-line
"\[ \]linux\(\[ \]\|\$\)" $test_line ] } {
470 } elseif
{ [ regexp
-line
"\[ \]\!linux\(\[ \]\|\$\)" $test_line ] } {
472 } elseif
{ [ regexp
-line
"\[ \]\!windows\(\[ \]\|\$\)" $test_line ] } {
474 } elseif
{ [ regexp
-line
"\[ \]windows\(\[ \]\|\$\)" $test_line ] } {
477 if { $matches_pos
== 1 && $matches_neg
== 0 } {
488 if { $lines_ok
== 0 } {
493 set test_line1 $test_line
495 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
496 set lineno
[expr $lineno
+ 1]
497 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
499 clone_output
"$test: could not read line $lineno"
505 if { $lines_ok
== 0 } {
511 # runtest_file_p is already run above
, and the code below can run
512 # runtest_file_p again
, make sure everything
for this test is
513 # performed
if the above runtest_file_p decided this runtest
514 # instance should
execute the test
515 gcc_parallel_test_enable
0
517 set go_compile_args
""
518 set go_execute_args
""
519 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
520 && ! [string match
"*.go*" "$progargs"] } {
521 set go_execute_args $progargs
522 verbose
-log "$test: go_execute_args is $go_execute_args"
523 set index
[string last
" $progargs" $test_line]
524 set test_line
[string replace $test_line $index end
]
525 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
526 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
527 # goroutines.go spawns by default
10000 threads
, which is too much
529 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
530 set go_execute_args
64
531 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
532 # When using low ulimit
-u
limit, use maximum of
533 # a quarter of that
limit and
10000 even when running expensive
534 # tests
, otherwise parallel tests might fail after fork failures.
535 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
536 if { [string is
integer -strict $nproc
] } {
537 set nproc
[expr $nproc
/ 4]
538 if { $nproc
> 10000 } { set nproc
10000 }
539 if { $nproc
< 16 } { set nproc
16 }
540 set go_execute_args $nproc
543 if { "$go_execute_args" != "" } {
544 verbose
-log "$test: go_execute_args is $go_execute_args"
548 if { $test_line
== "// compile"
549 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
550 # This is a vanilla
compile test.
551 set dg
-do-what
-default
"assemble"
552 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
553 } elseif
{ $test_line
== "// run"
554 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
555 # This is a vanilla execution test.
556 go
-torture
-execute $test
557 file
delete core
[glob
-nocomplain core.
*]
558 } elseif
{ $test_line
== "// build" } {
559 # This is a vanilla
compile and link test.
560 set dg
-do-what
-default
"link"
561 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
562 } elseif
{ [string match
"// runoutput*" $test_line] \
563 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
564 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
565 # Run the test to
get a .go
program to run.
566 set go_execute_args
""
567 set hold_runtests $runtests
568 set runtests
"go-test.exp"
570 if { [string match
"// runoutput*" $test_line] } {
572 regsub
"// runoutput\(.*\)" $test_line "\\1" args
574 lappend files
"[file dirname $test]/$f"
577 set dg
-do-what
-default
"link"
578 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
579 set output_file
"./[file rootname [file tail $test]].exe"
580 set base
"[file rootname [file tail $test]]"
582 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
583 fail
"$name execution"
585 pass
"$name execution"
586 file
delete $base
-out.x
587 # Disable optimizations as some of these tests
588 # take a long time to
compile.
589 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
590 go
-torture
-execute "./$base-out.go"
592 file
delete $base
-out.go
594 file
delete $output_file
595 set runtests $hold_runtests
596 } elseif
{ $test_line
== "// cmpout" \
597 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
598 # This is an execution test
for which we need to check the
600 set hold_runtests $runtests
601 set runtests
"go-test.exp"
602 set dg
-do-what
-default
"link"
603 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
604 set output_file
"./[file rootname [file tail $test]].exe"
605 set base
"[file rootname [file tail $test]]"
607 verbose
-log "$output_file >$base.p 2>&1"
608 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
609 verbose
-log $catcherr
610 fail
"$name execution"
611 untested
"$name compare"
613 pass
"$name execution"
614 regsub
"\\.go$" $test ".out" expect
615 filecmp $expect $base.p
"$name compare"
619 untested
"$name execution"
620 untested
"$name compare"
622 set runtests $hold_runtests
623 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
625 go
-execute-xfail $test
626 } elseif
{ $test_line
== "// errorcheck" } {
628 } elseif
{ $test_line
== "// errorcheckdir" } {
629 set hold_runtests $runtests
630 set runtests
"go-test.exp"
631 set dir "[file rootname $test].dir"
632 set files
[lsort
[glob
"$dir/*.go"]]
633 set packages
[go
-find
-packages $test $
name $files
]
634 if { [llength $packages
] > 0 } {
635 set dg
-do-what
-default
"assemble"
637 set last
[lindex $packages end
]
638 set packages
[lreplace $packages end end
]
639 foreach p $packages
{
640 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
641 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
643 errchk
[lindex $last
1] "[lrange $last 2 end]"
648 set runtests $hold_runtests
649 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
650 # Run the test to
get a .go
program to error check.
651 set go_execute_args
""
652 set hold_runtests $runtests
653 set runtests
"go-test.exp"
655 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
657 lappend files
"[file dirname $test]/$f"
659 set dg
-do-what
-default
"link"
660 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
661 set output_file
"./[file rootname [file tail $test]].exe"
662 set base
"[file rootname [file tail $test]]"
664 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
665 fail
"$name execution"
667 pass
"$name execution"
668 errchk
"$base-out.go" ""
670 file
delete $base
-out.go
672 file
delete $output_file
673 set runtests $hold_runtests
674 } elseif
{ $test_line
== "// compiledir" } {
675 set hold_runtests $runtests
676 set runtests
"go-test.exp"
677 set dg
-do-what
-default
"assemble"
678 set dir "[file rootname $test].dir"
679 set files
[lsort
[glob
"$dir/*.go"]]
680 set packages
[go
-find
-packages $test $
name $files
]
681 if { [llength $packages
] > 0 } {
683 foreach p $packages
{
684 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O" "-w $DEFAULT_GOCFLAGS"
685 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
691 set runtests $hold_runtests
692 } elseif
{ $test_line
== "// rundir" } {
693 set hold_runtests $runtests
694 set runtests
"go-test.exp"
695 set dir "[file rootname $test].dir"
696 set files
[lsort
[glob
"$dir/*.go"]]
697 set packages
[go
-find
-packages $test $
name $files
]
698 if { [llength $packages
] > 0 } {
699 set dg
-do-what
-default
"assemble"
701 set last
[lindex $packages end
]
702 set packages
[lreplace $packages end end
]
703 foreach p $packages
{
704 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
705 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
707 set dg
-do-what
-default
"link"
708 set go_compile_args
""
709 append go_compile_args
[lrange $last
2 end
]
710 append go_compile_args $del
711 go
-torture
-execute [lindex $last
1]
716 set runtests $hold_runtests
717 } elseif
{ $test_line
== "// rundircmpout" } {
718 set hold_runtests $runtests
719 set runtests
"go-test.exp"
720 set dir "[file rootname $test].dir"
721 set files
[lsort
[glob
"$dir/*.go"]]
722 set packages
[go
-find
-packages $test $
name $files
]
723 if { [llength $packages
] > 0 } {
724 set dg
-do-what
-default
"assemble"
726 set last
[lindex $packages end
]
727 set packages
[lreplace $packages end end
]
728 foreach p $packages
{
729 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
730 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
732 set dg
-do-what
-default
"link"
733 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O" "-w $DEFAULT_GOCFLAGS"
734 set base
"[file rootname [file tail [lindex $last 1]]]"
735 set output_file
"./$base.exe"
736 lappend del $output_file
738 verbose
-log "$output_file >$base.p 2>&1"
739 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
740 verbose
-log $catcherr
741 fail
"$name execution"
742 untested
"$name compare"
744 pass
"$name execution"
745 regsub
"\\.go$" "$test" ".out" expect
746 filecmp $expect $base.p
"$name compare"
754 set runtests $hold_runtests
755 } elseif
{ "$test_line" == ""
756 ||
[string match
"// true*" $test_line]
757 ||
[string match
"// skip*" $test_line] } {
758 # Not a real test
, just ignore.
759 } elseif
{ [string match \
760 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
763 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
766 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
770 } elseif
{ [string match \
771 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
776 set hold_runtests $runtests
777 set runtests
"go-test.exp"
778 set dg
-do-what
-default
"assemble"
779 regsub
"\\.go$" $test ".dir/$name1" file1
780 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
781 regsub
"\\.go$" $test ".dir/$name2" file2
783 file
delete "[file rootname [file tail $file1]].o"
784 set runtests $hold_runtests
785 } elseif
{ [string match \
786 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
788 set hold_runtests $runtests
789 set runtests
"go-test.exp"
790 set dg
-do-what
-default
"assemble"
791 regsub
"\\.go$" $test "1.go" file1
792 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
794 file
delete "[file rootname [file tail $file1]].o"
795 set runtests $hold_runtests
796 } elseif
{ [string match \
797 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
799 set hold_runtests $runtests
800 set runtests
"go-test.exp"
801 set dg
-do-what
-default
"assemble"
802 regsub
"\\.go$" $test ".dir/bug0.go" file1
803 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
804 regsub
"\\.go$" $test ".dir/bug1.go" file2
805 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
806 regsub
"\\.go$" $test ".dir/bug2.go" file3
808 file
delete "[file rootname [file tail $file1]].o"
809 file
delete "[file rootname [file tail $file2]].o"
810 set runtests $hold_runtests
811 } elseif
{ [string match \
812 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
815 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
817 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
818 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
819 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
821 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
825 } elseif
{ [string match \
826 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
830 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
833 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
836 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
837 set name1
"method4a.go"
840 set hold_runtests $runtests
841 set runtests
"go-test.exp"
842 set dg
-do-what
-default
"assemble"
843 regsub
"\\.go$" $test ".dir/$name1" file1
844 if { $name1
== "method4a.go" } {
845 set file1
"[file dirname $test]/method4a.go"
847 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
848 set ofile1
"[file rootname [file tail $file1]].o"
849 regsub
"\\.go$" $test ".dir/$name2" file2
850 if { $name2
== "" } {
853 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
854 set ofile2
"[file rootname [file tail $file2]].o"
855 set dg
-do-what
-default
"link"
856 set output_file
"./[file rootname [file tail $test]].exe"
857 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
858 $output_file
"executable" "$options"]
859 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
860 verbose
-log $comp_output
861 set result
[go_load
"$output_file" "" ""]
862 set status [lindex $result
0]
864 file
delete $ofile1 $ofile2 $output_file
865 set runtests $hold_runtests
866 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
867 set hold_runtests $runtests
868 set runtests
"go-test.exp"
869 set dg
-do-what
-default
"assemble"
870 regsub
"\\.go$" $test ".dir/one.go" file1
871 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
872 set ofile1
"[file rootname [file tail $file1]].o"
873 regsub
"\\.go$" $test ".dir/two.go" file2
874 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
875 set ofile2
"[file rootname [file tail $file2]].o"
876 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
877 set ofile3
"[file rootname [file tail $test]].o"
878 set dg
-do-what
-default
"link"
879 set output_file
"./[file rootname [file tail $test]].exe"
880 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
881 $output_file
"executable" "$options"]
882 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
883 verbose
-log $comp_output
884 set result
[go_load
"$output_file" "" ""]
885 set status [lindex $result
0]
887 file
delete $ofile1 $ofile2 $ofile3 $output_file
888 set runtests $hold_runtests
889 } elseif
{ [string match \
890 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
892 set hold_runtests $runtests
893 set runtests
"go-test.exp"
894 set dg
-do-what
-default
"assemble"
895 regsub
"/\[^/\]*$" $test "/embed0.go" file1
896 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
897 set ofile1
"[file rootname [file tail $file1]].o"
898 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
899 set ofile2
"[file rootname [file tail $test]].o"
900 set output_file
"./[file rootname [file tail $test]].exe"
901 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
902 $output_file
"executable" "$options"]
903 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
904 if [string match
"" $comp_output] {
905 set result
[go_load
"$output_file" "" ""]
906 set status [lindex $result
0]
909 verbose
-log $comp_output
912 file
delete $ofile1 $ofile2 $output_file
913 set runtests $hold_runtests
914 } elseif
{ [string match \
915 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
918 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
921 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
925 } elseif
{ [string match \
926 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
931 set hold_runtests $runtests
932 set runtests
"go-test.exp"
933 set dg
-do-what
-default
"assemble"
934 regsub
"\\.go$" $test ".dir/$name1" file1
935 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
936 set ofile1
"[file rootname [file tail $file1]].o"
937 regsub
"\\.go$" $test ".dir/$name2" file2
938 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
939 set ofile2
"[file rootname [file tail $file2]].o"
940 set dg
-do-what
-default
"link"
941 set output_file
"./[file rootname [file tail $file2]].exe"
942 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
943 $output_file
"executable" "$options"]
944 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
945 if [string match
"" $comp_output] {
946 set result
[go_load
"$output_file" "" ""]
947 set status [lindex $result
0]
950 verbose
-log $comp_output
953 file
delete $ofile1 $ofile2 $output_file
954 set runtests $hold_runtests
955 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
956 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
957 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
958 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
959 && $test_line5
== "// \$L bug2.\$A &&" \
960 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
961 set hold_runtests $runtests
962 set runtests
"go-test.exp"
963 set dg
-do-what
-default
"assemble"
964 regsub
"\\.go$" $test ".dir/bug0.go" file0
965 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
966 set ofile0
"[file rootname [file tail $file0]].o"
967 regsub
"\\.go$" $test ".dir/bug1.go" file1
968 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
969 set ofile1
"[file rootname [file tail $file1]].o"
970 regsub
"\\.go$" $test ".dir/bug2.go" file2
971 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
972 set ofile2
"[file rootname [file tail $file2]].o"
973 regsub
"\\.go$" $test ".dir/bug3.go" file3
975 set output_file
"./[file rootname [file tail $test]].exe"
976 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
977 $output_file
"executable" "$options"]
978 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
979 if [string match
"" $comp_output] {
980 set result
[go_load
"$output_file" "" ""]
981 set status [lindex $result
0]
984 verbose
-log $comp_output
987 file
delete $ofile0 $ofile1 $ofile2 $output_file
988 set runtests $hold_runtests
989 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
990 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
991 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
992 set name1
"import2.go"
993 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
994 set name1
"recursive1.go"
996 set hold_runtests $runtests
997 set runtests
"go-test.exp"
998 set dg
-do-what
-default
"assemble"
999 regsub
"/\[^/\]*$" $test "/${name1}" file1
1000 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1001 set ofile1
"[file rootname [file tail $file1]].o"
1002 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1004 set runtests $hold_runtests
1005 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1006 set hold_runtests $runtests
1007 set runtests
"go-test.exp"
1008 set dg
-do-what
-default
"assemble"
1009 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
1010 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1011 set ofile1
"[file rootname [file tail $file1]].o"
1012 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1013 set ofile2
"[file rootname [file tail $test]].o"
1014 set output_file
"./[file rootname [file tail $test]].exe"
1015 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
1016 $output_file
"executable" "$options"]
1017 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1018 if [string match
"" $comp_output] {
1019 set result
[go_load
"$output_file" "" ""]
1020 set status [lindex $result
0]
1023 verbose
-log $comp_output
1026 file
delete $ofile1 $ofile2 $output_file
1027 set runtests $hold_runtests
1028 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1029 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1030 set output_file
"./[file rootname [file tail $test]].o"
1031 set comp_output
[go_target_compile
"$test $test2" \
1032 $output_file
"executable" "$options"]
1033 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1034 if [string match
"" $comp_output] {
1035 set result
[go_load
"$output_file" "" ""]
1036 set status [lindex $result
0]
1039 verbose
-log $comp_output
1042 file
delete $output_file
1043 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1044 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1045 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1046 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1047 set go_execute_args
""
1048 set hold_runtests $runtests
1049 set runtests
"go-test.exp"
1050 set dg
-do-what
-default
"link"
1051 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1052 set output_file
"./[file rootname [file tail $test]].exe"
1054 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1055 fail
"$name execution 0"
1057 pass
"$name execution 0"
1059 # Disable optimizations as this test takes a long time
1061 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1062 go
-torture
-execute "./tmp.go"
1064 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1065 fail
"$name execution 1"
1067 pass
"$name execution 1"
1070 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1071 fail
"$name execution 2"
1073 pass
"$name execution 2"
1078 file
delete $output_file
1079 set runtests $hold_runtests
1080 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1081 && $test_line2
== "// errchk \$G -e tmp.go" } {
1082 set go_execute_args
""
1083 set hold_runtests $runtests
1084 set runtests
"go-test.exp"
1085 set dg
-do-what
-default
"link"
1086 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1087 set output_file
"./[file rootname [file tail $test]].exe"
1089 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1090 fail
"$name execution"
1092 pass
"$name execution"
1097 file
delete $output_file
1098 set runtests $hold_runtests
1099 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1100 regsub
"\\.go$" $test ".dir/a.go" file1
1101 regsub
"\\.go$" $test ".dir/b.go" file2
1102 errchk
"$file1" "$file2"
1103 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1104 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1105 && $test_line3
== "// run" } {
1106 set hold_runtests $runtests
1107 set runtests
"go-test.exp"
1108 set dg
-do-what
-default
"assemble"
1109 regsub
"\\.go$" $test ".dir/pkg.go" file1
1110 dg
-test
-keep
-output $file1
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1111 set ofile1
"[file rootname [file tail $file1]].o"
1112 file
rename -force $ofile1 slow.o
1113 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1114 file
rename -force $ofile1 fast.o
1115 set ofile2
"[file rootname [file tail $test]].o"
1116 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1117 set output_file
"./[file rootname [file tail $test]].exe"
1118 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1119 $output_file
"executable" "$options"]
1120 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1121 if [string match
"" $comp_output] {
1122 set result
[go_load
"$output_file" "" ""]
1123 set status [lindex $result
0]
1126 verbose
-log $comp_output
1129 file
delete slow.o fast.o $ofile2 $output_file
1130 set runtests $hold_runtests
1131 } elseif
{ [string match \
1132 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1134 set hold_runtests $runtests
1135 set runtests
"go-test.exp"
1136 set dg
-do-what
-default
"assemble"
1137 regsub
"\\.go$" $test ".dir/pkg.go" file1
1138 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1139 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1140 file
delete "[file rootname [file tail $file1]].o"
1141 set runtests $hold_runtests
1142 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1144 set hold_runtests $runtests
1145 set runtests
"go-test.exp"
1146 set dg
-do-what
-default
"assemble"
1147 regsub
"\\.go$" $test ".dir/one.go" file1
1148 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1149 set ofile1
"[file rootname [file tail $file1]].o"
1150 regsub
"\\.go$" $test ".dir/two.go" file2
1151 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1153 set runtests $hold_runtests
1154 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1155 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1156 # These tests
import the same package under two different
1157 # names
, which gccgo does not support.
1158 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1159 # This tests whether initializers are written out
1160 # statically. gccgo does not provide a way to test that
,
1161 # as an initializer will be generated
for any code which
1162 # has global variables which need to be registered as GC
1164 } elseif
{ $test_line
== "// errorcheck -0 -m"
1165 || $test_line
== "// errorcheck -0 -m -l" } {
1166 # This tests debug output of the gc compiler
, which is
1167 # meaningless
for gccgo.
1168 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1169 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1170 # This tests specific handling of the gc compiler
on types
1171 # that are too large. It is target specific in a way I
1172 # haven
't bothered to check for here.
1173 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1174 # This tests the gc ld -X option, which gccgo does not
1176 } 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"
1177 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1178 # This tests the gc -u option, which gccgo does not
1180 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1181 || $test_line == "// errorcheck -0 -d=nil" } {
1182 # This tests gc nil pointer checks using -d=nil, which
1183 # gccgo does not support.
1185 clone_output "$name: unrecognized test line: $test_line"
1189 set go_compile_args ""
1190 set go_execute_args ""
1191 set TORTURE_OPTIONS [list { -O2 -g }]
1192 gcc_parallel_test_enable 1
1195 set dg-do-what-default ${saved-dg-do-what-default}
1196 set TORTURE_OPTIONS $saved_torture_options