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] {
254 if [check_effective_target_ilp32] {
261 perror "$target_triplet: unhandled architecture"
265 verbose -log "Setting GOARCH=$goarch" 1
266 setenv GOARCH $goarch
269 # Take a list of files and return a lists of lists, where each list is
270 # the set of files in the same package.
271 proc go-find-packages { test name files } {
276 if { [gets $fd line] < 0 } {
278 clone_output "$test: could not read $f"
283 if { [regexp "^package (\\w+)" $line match package] } {
284 set len [llength $packages]
285 for { set i 0 } { $i < $len } { incr i } {
286 set p [lindex $packages $i]
287 if { [lindex $p 0] == $package } {
294 lappend packages [list $package $f]
305 proc go-gc-tests { } {
308 global GCC_UNDER_TEST
310 global TORTURE_OPTIONS
311 global dg-do-what-default
312 global go_compile_args
313 global go_execute_args
314 global target_triplet
316 # If a testcase doesn't have special options
, use these.
317 global DEFAULT_GOCFLAGS
318 if ![info exists DEFAULT_GOCFLAGS
] {
319 set DEFAULT_GOCFLAGS
" -pedantic-errors"
323 lappend options
"additional_flags=$DEFAULT_GOCFLAGS"
325 #
Set GOARCH
for tests that need it.
328 # Running all the torture options takes too long and
, since the
329 # frontend ignores the standard options
, it doesn
't significantly
331 set saved_torture_options $TORTURE_OPTIONS
332 set TORTURE_OPTIONS [list { -O2 -g }]
334 set saved-dg-do-what-default ${dg-do-what-default}
338 set tests [lsort [find $srcdir/$subdir *.go]]
339 foreach test $tests {
340 if ![runtest_file_p $runtests $test] {
344 # Skip the files in bench; they are not tests.
345 if [string match "*go.test/test/bench/*" $test] {
349 # Skip the files in stress; they are not tests.
350 if [string match "*go.test/test/stress/*" $test] {
354 # Skip the files in safe; gccgo does not support safe mode.
355 if [string match "*go.test/test/safe/*" $test] {
359 # Skip files in sub-subdirectories: they are components of
361 if [string match "*go.test/test/*/*/*" $test] {
365 # Skip files in *.dir subdirectories: they are components of
367 if [string match "*go.test/test/*.dir/*" $test] {
371 set name [dg-trim-dirname $srcdir $test]
373 # Skip certain tests if target is RTEMS OS.
374 if [istarget "*-*-rtems*"] {
375 if { [string match "*go.test/test/args.go" $test] \
376 || [string match "*go.test/test/env.go" $test] } {
377 untested "$name: uses the command-line or environment variables"
381 if { [string match "*go.test/test/stack.go" $test] \
382 || [string match "*go.test/test/peano.go" $test] \
383 || [string match "*go.test/test/chan/goroutines.go" $test] } {
384 untested "$name: has very high memory requirement"
389 # Handle certain tests in a target-dependant way.
390 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] } {
391 if { [string match "*go.test/test/nilptr.go" $test] } {
397 if { [file tail $test] == "init1.go" } {
398 # This tests whether GC runs during init, which for gccgo
399 # it currently does not.
404 if { [file tail $test] == "closure.go" } {
405 # This tests whether function closures do any memory
406 # allocation, which for gccgo they currently do.
411 if { ( [file tail $test] == "select2.go" \
412 || [file tail $test] == "stack.go" \
413 || [file tail $test] == "peano.go" ) \
414 && ! [check_effective_target_split_stack] } {
415 # These tests fails on targets without split stack.
420 if [string match "*go.test/test/rotate\[0123\].go" $test] {
421 # These tests produces a temporary file that takes too long
422 # to compile--5 minutes on my laptop without optimization.
423 # When compiling without optimization it tests nothing
424 # useful, since the point of the test is to see whether
425 # the compiler generates rotate instructions.
430 if { [file tail $test] == "bug347.go" \
431 || [file tail $test] == "bug348.go" } {
432 # These tests don't work
if the functions are inlined.
433 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
436 set fd
[open $test r
]
441 if { [gets $fd test_line
] < 0 } {
443 clone_output
"$test: could not read first line"
449 if { [ string match
"*nacl*exit 0*" $test_line ] \
450 ||
[ string match
"*exit 0*nacl*" $test_line ] \
451 ||
[ string match
"*Android*exit 0*" $test_line ] \
452 ||
[ string match
"*exit 0*Android*" $test_line ] \
453 ||
[ string match
"*\"\$GOOS\" == windows*" $test_line ] } {
457 if { [ string match
"// +build *" $test_line ] } {
460 if { [ regexp
-line
"\[ \][getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
462 } elseif
{ [ regexp
-line
"\[ \]\![getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
464 } elseif
{ [ regexp
-line
"\[ \]linux\(\[ \]\|\$\)" $test_line ] } {
466 } elseif
{ [ regexp
-line
"\[ \]\!linux\(\[ \]\|\$\)" $test_line ] } {
468 } elseif
{ [ regexp
-line
"\[ \]\!windows\(\[ \]\|\$\)" $test_line ] } {
470 } elseif
{ [ regexp
-line
"\[ \]windows\(\[ \]\|\$\)" $test_line ] } {
473 if { $matches_pos
== 1 && $matches_neg
== 0 } {
484 if { $lines_ok
== 0 } {
489 set test_line1 $test_line
491 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
492 set lineno
[expr $lineno
+ 1]
493 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
495 clone_output
"$test: could not read line $lineno"
501 if { $lines_ok
== 0 } {
507 # runtest_file_p is already run above
, and the code below can run
508 # runtest_file_p again
, make sure everything
for this test is
509 # performed
if the above runtest_file_p decided this runtest
510 # instance should
execute the test
511 gcc_parallel_test_enable
0
513 set go_compile_args
""
514 set go_execute_args
""
515 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
516 && ! [string match
"*.go*" "$progargs"] } {
517 set go_execute_args $progargs
518 verbose
-log "$test: go_execute_args is $go_execute_args"
519 set index
[string last
" $progargs" $test_line]
520 set test_line
[string replace $test_line $index end
]
521 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
522 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
523 # goroutines.go spawns by default
10000 threads
, which is too much
525 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
526 set go_execute_args
64
527 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
528 # When using low ulimit
-u
limit, use maximum of
529 # a quarter of that
limit and
10000 even when running expensive
530 # tests
, otherwise parallel tests might fail after fork failures.
531 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
532 if { [string is
integer -strict $nproc
] } {
533 set nproc
[expr $nproc
/ 4]
534 if { $nproc
> 10000 } { set nproc
10000 }
535 if { $nproc
< 16 } { set nproc
16 }
536 set go_execute_args $nproc
539 if { "$go_execute_args" != "" } {
540 verbose
-log "$test: go_execute_args is $go_execute_args"
544 if { $test_line
== "// compile"
545 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
546 # This is a vanilla
compile test.
547 set dg
-do-what
-default
"assemble"
548 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
549 } elseif
{ $test_line
== "// run"
550 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
551 # This is a vanilla execution test.
552 go
-torture
-execute $test
553 file
delete core
[glob
-nocomplain core.
*]
554 } elseif
{ $test_line
== "// build" } {
555 # This is a vanilla
compile and link test.
556 set dg
-do-what
-default
"link"
557 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
558 } elseif
{ [string match
"// runoutput*" $test_line] \
559 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
560 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
561 # Run the test to
get a .go
program to run.
562 set go_execute_args
""
563 set hold_runtests $runtests
564 set runtests
"go-test.exp"
566 if { [string match
"// runoutput*" $test_line] } {
568 regsub
"// runoutput\(.*\)" $test_line "\\1" args
570 lappend files
"[file dirname $test]/$f"
573 set dg
-do-what
-default
"link"
574 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
575 set output_file
"./[file rootname [file tail $test]].exe"
576 set base
"[file rootname [file tail $test]]"
578 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
579 fail
"$name execution"
581 pass
"$name execution"
582 file
delete $base
-out.x
583 # Disable optimizations as some of these tests
584 # take a long time to
compile.
585 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
586 go
-torture
-execute "./$base-out.go"
588 file
delete $base
-out.go
590 file
delete $output_file
591 set runtests $hold_runtests
592 } elseif
{ $test_line
== "// cmpout" \
593 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
594 # This is an execution test
for which we need to check the
596 set hold_runtests $runtests
597 set runtests
"go-test.exp"
598 set dg
-do-what
-default
"link"
599 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
600 set output_file
"./[file rootname [file tail $test]].exe"
601 set base
"[file rootname [file tail $test]]"
603 verbose
-log "$output_file >$base.p 2>&1"
604 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
605 verbose
-log $catcherr
606 fail
"$name execution"
607 untested
"$name compare"
609 pass
"$name execution"
610 regsub
"\\.go$" $test ".out" expect
611 filecmp $expect $base.p
"$name compare"
615 untested
"$name execution"
616 untested
"$name compare"
618 set runtests $hold_runtests
619 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
621 go
-execute-xfail $test
622 } elseif
{ $test_line
== "// errorcheck" } {
624 } elseif
{ $test_line
== "// errorcheckdir" } {
625 set hold_runtests $runtests
626 set runtests
"go-test.exp"
627 set dir "[file rootname $test].dir"
628 set files
[lsort
[glob
"$dir/*.go"]]
629 set packages
[go
-find
-packages $test $
name $files
]
630 if { [llength $packages
] > 0 } {
631 set dg
-do-what
-default
"assemble"
633 set last
[lindex $packages end
]
634 set packages
[lreplace $packages end end
]
635 foreach p $packages
{
636 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
637 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
639 errchk
[lindex $last
1] "[lrange $last 2 end]"
644 set runtests $hold_runtests
645 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
646 # Run the test to
get a .go
program to error check.
647 set go_execute_args
""
648 set hold_runtests $runtests
649 set runtests
"go-test.exp"
651 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
653 lappend files
"[file dirname $test]/$f"
655 set dg
-do-what
-default
"link"
656 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
657 set output_file
"./[file rootname [file tail $test]].exe"
658 set base
"[file rootname [file tail $test]]"
660 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
661 fail
"$name execution"
663 pass
"$name execution"
664 errchk
"$base-out.go" ""
666 file
delete $base
-out.go
668 file
delete $output_file
669 set runtests $hold_runtests
670 } elseif
{ $test_line
== "// compiledir" } {
671 set hold_runtests $runtests
672 set runtests
"go-test.exp"
673 set dg
-do-what
-default
"assemble"
674 set dir "[file rootname $test].dir"
675 set files
[lsort
[glob
"$dir/*.go"]]
676 set packages
[go
-find
-packages $test $
name $files
]
677 if { [llength $packages
] > 0 } {
679 foreach p $packages
{
680 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O" "-w $DEFAULT_GOCFLAGS"
681 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
687 set runtests $hold_runtests
688 } elseif
{ $test_line
== "// rundir" } {
689 set hold_runtests $runtests
690 set runtests
"go-test.exp"
691 set dir "[file rootname $test].dir"
692 set files
[lsort
[glob
"$dir/*.go"]]
693 set packages
[go
-find
-packages $test $
name $files
]
694 if { [llength $packages
] > 0 } {
695 set dg
-do-what
-default
"assemble"
697 set last
[lindex $packages end
]
698 set packages
[lreplace $packages end end
]
699 foreach p $packages
{
700 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
701 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
703 set dg
-do-what
-default
"link"
704 set go_compile_args
""
705 append go_compile_args
[lrange $last
2 end
]
706 append go_compile_args $del
707 go
-torture
-execute [lindex $last
1]
712 set runtests $hold_runtests
713 } elseif
{ $test_line
== "// rundircmpout" } {
714 set hold_runtests $runtests
715 set runtests
"go-test.exp"
716 set dir "[file rootname $test].dir"
717 set files
[lsort
[glob
"$dir/*.go"]]
718 set packages
[go
-find
-packages $test $
name $files
]
719 if { [llength $packages
] > 0 } {
720 set dg
-do-what
-default
"assemble"
722 set last
[lindex $packages end
]
723 set packages
[lreplace $packages end end
]
724 foreach p $packages
{
725 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
726 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
728 set dg
-do-what
-default
"link"
729 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O" "-w $DEFAULT_GOCFLAGS"
730 set base
"[file rootname [file tail [lindex $last 1]]]"
731 set output_file
"./$base.exe"
732 lappend del $output_file
734 verbose
-log "$output_file >$base.p 2>&1"
735 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
736 verbose
-log $catcherr
737 fail
"$name execution"
738 untested
"$name compare"
740 pass
"$name execution"
741 regsub
"\\.go$" "$test" ".out" expect
742 filecmp $expect $base.p
"$name compare"
750 set runtests $hold_runtests
751 } elseif
{ "$test_line" == ""
752 ||
[string match
"// true*" $test_line]
753 ||
[string match
"// skip*" $test_line] } {
754 # Not a real test
, just ignore.
755 } elseif
{ [string match \
756 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
759 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
762 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
766 } elseif
{ [string match \
767 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
772 set hold_runtests $runtests
773 set runtests
"go-test.exp"
774 set dg
-do-what
-default
"assemble"
775 regsub
"\\.go$" $test ".dir/$name1" file1
776 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
777 regsub
"\\.go$" $test ".dir/$name2" file2
779 file
delete "[file rootname [file tail $file1]].o"
780 set runtests $hold_runtests
781 } elseif
{ [string match \
782 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
784 set hold_runtests $runtests
785 set runtests
"go-test.exp"
786 set dg
-do-what
-default
"assemble"
787 regsub
"\\.go$" $test "1.go" file1
788 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
790 file
delete "[file rootname [file tail $file1]].o"
791 set runtests $hold_runtests
792 } elseif
{ [string match \
793 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
795 set hold_runtests $runtests
796 set runtests
"go-test.exp"
797 set dg
-do-what
-default
"assemble"
798 regsub
"\\.go$" $test ".dir/bug0.go" file1
799 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
800 regsub
"\\.go$" $test ".dir/bug1.go" file2
801 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
802 regsub
"\\.go$" $test ".dir/bug2.go" file3
804 file
delete "[file rootname [file tail $file1]].o"
805 file
delete "[file rootname [file tail $file2]].o"
806 set runtests $hold_runtests
807 } elseif
{ [string match \
808 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
811 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
813 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
814 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
815 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
817 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
821 } elseif
{ [string match \
822 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
826 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
829 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
832 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
833 set name1
"method4a.go"
836 set hold_runtests $runtests
837 set runtests
"go-test.exp"
838 set dg
-do-what
-default
"assemble"
839 regsub
"\\.go$" $test ".dir/$name1" file1
840 if { $name1
== "method4a.go" } {
841 set file1
"[file dirname $test]/method4a.go"
843 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
844 set ofile1
"[file rootname [file tail $file1]].o"
845 regsub
"\\.go$" $test ".dir/$name2" file2
846 if { $name2
== "" } {
849 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
850 set ofile2
"[file rootname [file tail $file2]].o"
851 set dg
-do-what
-default
"link"
852 set output_file
"./[file rootname [file tail $test]].exe"
853 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
854 $output_file
"executable" "$options"]
855 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
856 verbose
-log $comp_output
857 set result
[go_load
"$output_file" "" ""]
858 set status [lindex $result
0]
860 file
delete $ofile1 $ofile2 $output_file
861 set runtests $hold_runtests
862 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
863 set hold_runtests $runtests
864 set runtests
"go-test.exp"
865 set dg
-do-what
-default
"assemble"
866 regsub
"\\.go$" $test ".dir/one.go" file1
867 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
868 set ofile1
"[file rootname [file tail $file1]].o"
869 regsub
"\\.go$" $test ".dir/two.go" file2
870 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
871 set ofile2
"[file rootname [file tail $file2]].o"
872 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
873 set ofile3
"[file rootname [file tail $test]].o"
874 set dg
-do-what
-default
"link"
875 set output_file
"./[file rootname [file tail $test]].exe"
876 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
877 $output_file
"executable" "$options"]
878 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
879 verbose
-log $comp_output
880 set result
[go_load
"$output_file" "" ""]
881 set status [lindex $result
0]
883 file
delete $ofile1 $ofile2 $ofile3 $output_file
884 set runtests $hold_runtests
885 } elseif
{ [string match \
886 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
888 set hold_runtests $runtests
889 set runtests
"go-test.exp"
890 set dg
-do-what
-default
"assemble"
891 regsub
"/\[^/\]*$" $test "/embed0.go" file1
892 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
893 set ofile1
"[file rootname [file tail $file1]].o"
894 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
895 set ofile2
"[file rootname [file tail $test]].o"
896 set output_file
"./[file rootname [file tail $test]].exe"
897 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
898 $output_file
"executable" "$options"]
899 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
900 if [string match
"" $comp_output] {
901 set result
[go_load
"$output_file" "" ""]
902 set status [lindex $result
0]
905 verbose
-log $comp_output
908 file
delete $ofile1 $ofile2 $output_file
909 set runtests $hold_runtests
910 } elseif
{ [string match \
911 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
914 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
917 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
921 } elseif
{ [string match \
922 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
927 set hold_runtests $runtests
928 set runtests
"go-test.exp"
929 set dg
-do-what
-default
"assemble"
930 regsub
"\\.go$" $test ".dir/$name1" file1
931 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
932 set ofile1
"[file rootname [file tail $file1]].o"
933 regsub
"\\.go$" $test ".dir/$name2" file2
934 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
935 set ofile2
"[file rootname [file tail $file2]].o"
936 set dg
-do-what
-default
"link"
937 set output_file
"./[file rootname [file tail $file2]].exe"
938 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
939 $output_file
"executable" "$options"]
940 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
941 if [string match
"" $comp_output] {
942 set result
[go_load
"$output_file" "" ""]
943 set status [lindex $result
0]
946 verbose
-log $comp_output
949 file
delete $ofile1 $ofile2 $output_file
950 set runtests $hold_runtests
951 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
952 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
953 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
954 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
955 && $test_line5
== "// \$L bug2.\$A &&" \
956 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
957 set hold_runtests $runtests
958 set runtests
"go-test.exp"
959 set dg
-do-what
-default
"assemble"
960 regsub
"\\.go$" $test ".dir/bug0.go" file0
961 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
962 set ofile0
"[file rootname [file tail $file0]].o"
963 regsub
"\\.go$" $test ".dir/bug1.go" file1
964 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
965 set ofile1
"[file rootname [file tail $file1]].o"
966 regsub
"\\.go$" $test ".dir/bug2.go" file2
967 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
968 set ofile2
"[file rootname [file tail $file2]].o"
969 regsub
"\\.go$" $test ".dir/bug3.go" file3
971 set output_file
"./[file rootname [file tail $test]].exe"
972 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
973 $output_file
"executable" "$options"]
974 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
975 if [string match
"" $comp_output] {
976 set result
[go_load
"$output_file" "" ""]
977 set status [lindex $result
0]
980 verbose
-log $comp_output
983 file
delete $ofile0 $ofile1 $ofile2 $output_file
984 set runtests $hold_runtests
985 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
986 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
987 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
988 set name1
"import2.go"
989 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
990 set name1
"recursive1.go"
992 set hold_runtests $runtests
993 set runtests
"go-test.exp"
994 set dg
-do-what
-default
"assemble"
995 regsub
"/\[^/\]*$" $test "/${name1}" file1
996 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
997 set ofile1
"[file rootname [file tail $file1]].o"
998 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1000 set runtests $hold_runtests
1001 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1002 set hold_runtests $runtests
1003 set runtests
"go-test.exp"
1004 set dg
-do-what
-default
"assemble"
1005 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
1006 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1007 set ofile1
"[file rootname [file tail $file1]].o"
1008 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1009 set ofile2
"[file rootname [file tail $test]].o"
1010 set output_file
"./[file rootname [file tail $test]].exe"
1011 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
1012 $output_file
"executable" "$options"]
1013 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1014 if [string match
"" $comp_output] {
1015 set result
[go_load
"$output_file" "" ""]
1016 set status [lindex $result
0]
1019 verbose
-log $comp_output
1022 file
delete $ofile1 $ofile2 $output_file
1023 set runtests $hold_runtests
1024 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1025 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1026 set output_file
"./[file rootname [file tail $test]].o"
1027 set comp_output
[go_target_compile
"$test $test2" \
1028 $output_file
"executable" "$options"]
1029 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1030 if [string match
"" $comp_output] {
1031 set result
[go_load
"$output_file" "" ""]
1032 set status [lindex $result
0]
1035 verbose
-log $comp_output
1038 file
delete $output_file
1039 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1040 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1041 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1042 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1043 set go_execute_args
""
1044 set hold_runtests $runtests
1045 set runtests
"go-test.exp"
1046 set dg
-do-what
-default
"link"
1047 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1048 set output_file
"./[file rootname [file tail $test]].exe"
1050 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1051 fail
"$name execution 0"
1053 pass
"$name execution 0"
1055 # Disable optimizations as this test takes a long time
1057 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1058 go
-torture
-execute "./tmp.go"
1060 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1061 fail
"$name execution 1"
1063 pass
"$name execution 1"
1066 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1067 fail
"$name execution 2"
1069 pass
"$name execution 2"
1074 file
delete $output_file
1075 set runtests $hold_runtests
1076 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1077 && $test_line2
== "// errchk \$G -e tmp.go" } {
1078 set go_execute_args
""
1079 set hold_runtests $runtests
1080 set runtests
"go-test.exp"
1081 set dg
-do-what
-default
"link"
1082 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1083 set output_file
"./[file rootname [file tail $test]].exe"
1085 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1086 fail
"$name execution"
1088 pass
"$name execution"
1093 file
delete $output_file
1094 set runtests $hold_runtests
1095 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1096 regsub
"\\.go$" $test ".dir/a.go" file1
1097 regsub
"\\.go$" $test ".dir/b.go" file2
1098 errchk
"$file1" "$file2"
1099 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1100 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1101 && $test_line3
== "// run" } {
1102 set hold_runtests $runtests
1103 set runtests
"go-test.exp"
1104 set dg
-do-what
-default
"assemble"
1105 regsub
"\\.go$" $test ".dir/pkg.go" file1
1106 dg
-test
-keep
-output $file1
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1107 set ofile1
"[file rootname [file tail $file1]].o"
1108 file
rename -force $ofile1 slow.o
1109 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1110 file
rename -force $ofile1 fast.o
1111 set ofile2
"[file rootname [file tail $test]].o"
1112 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1113 set output_file
"./[file rootname [file tail $test]].exe"
1114 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1115 $output_file
"executable" "$options"]
1116 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1117 if [string match
"" $comp_output] {
1118 set result
[go_load
"$output_file" "" ""]
1119 set status [lindex $result
0]
1122 verbose
-log $comp_output
1125 file
delete slow.o fast.o $ofile2 $output_file
1126 set runtests $hold_runtests
1127 } elseif
{ [string match \
1128 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1130 set hold_runtests $runtests
1131 set runtests
"go-test.exp"
1132 set dg
-do-what
-default
"assemble"
1133 regsub
"\\.go$" $test ".dir/pkg.go" file1
1134 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1135 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1136 file
delete "[file rootname [file tail $file1]].o"
1137 set runtests $hold_runtests
1138 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1140 set hold_runtests $runtests
1141 set runtests
"go-test.exp"
1142 set dg
-do-what
-default
"assemble"
1143 regsub
"\\.go$" $test ".dir/one.go" file1
1144 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1145 set ofile1
"[file rootname [file tail $file1]].o"
1146 regsub
"\\.go$" $test ".dir/two.go" file2
1147 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1149 set runtests $hold_runtests
1150 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1151 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1152 # These tests
import the same package under two different
1153 # names
, which gccgo does not support.
1154 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1155 # This tests whether initializers are written out
1156 # statically. gccgo does not provide a way to test that
,
1157 # as an initializer will be generated
for any code which
1158 # has global variables which need to be registered as GC
1160 } elseif
{ $test_line
== "// errorcheck -0 -m"
1161 || $test_line
== "// errorcheck -0 -m -l" } {
1162 # This tests debug output of the gc compiler
, which is
1163 # meaningless
for gccgo.
1164 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1165 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1166 # This tests specific handling of the gc compiler
on types
1167 # that are too large. It is target specific in a way I
1168 # haven
't bothered to check for here.
1169 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1170 # This tests the gc ld -X option, which gccgo does not
1172 } 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"
1173 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1174 # This tests the gc -u option, which gccgo does not
1176 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1177 || $test_line == "// errorcheck -0 -d=nil" } {
1178 # This tests gc nil pointer checks using -d=nil, which
1179 # gccgo does not support.
1181 clone_output "$name: unrecognized test line: $test_line"
1185 set go_compile_args ""
1186 set go_execute_args ""
1187 set TORTURE_OPTIONS [list { -O2 -g }]
1188 gcc_parallel_test_enable 1
1191 set dg-do-what-default ${saved-dg-do-what-default}
1192 set TORTURE_OPTIONS $saved_torture_options