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] {
248 if [check_effective_target_ilp32] {
255 perror "$target_triplet: unhandled architecture"
259 verbose -log "Setting GOARCH=$goarch" 1
260 setenv GOARCH $goarch
263 # Take a list of files and return a lists of lists, where each list is
264 # the set of files in the same package.
265 proc go-find-packages { test name files } {
270 if { [gets $fd line] < 0 } {
272 clone_output "$test: could not read $f"
277 if { [regexp "^package (\\w+)" $line match package] } {
278 set len [llength $packages]
279 for { set i 0 } { $i < $len } { incr i } {
280 set p [lindex $packages $i]
281 if { [lindex $p 0] == $package } {
288 lappend packages [list $package $f]
299 proc go-gc-tests { } {
302 global GCC_UNDER_TEST
304 global TORTURE_OPTIONS
305 global dg-do-what-default
306 global go_compile_args
307 global go_execute_args
308 global target_triplet
310 # If a testcase doesn't have special options
, use these.
311 global DEFAULT_GOCFLAGS
312 if ![info exists DEFAULT_GOCFLAGS
] {
313 set DEFAULT_GOCFLAGS
" -pedantic-errors"
317 lappend options
"additional_flags=$DEFAULT_GOCFLAGS"
319 #
Set GOARCH
for tests that need it.
322 # Running all the torture options takes too long and
, since the
323 # frontend ignores the standard options
, it doesn
't significantly
325 set saved_torture_options $TORTURE_OPTIONS
326 set TORTURE_OPTIONS [list { -O2 -g }]
328 set saved-dg-do-what-default ${dg-do-what-default}
332 set tests [lsort [find $srcdir/$subdir *.go]]
333 foreach test $tests {
334 if ![runtest_file_p $runtests $test] {
338 # Skip the files in bench; they are not tests.
339 if [string match "*go.test/test/bench/*" $test] {
343 # Skip the files in stress; they are not tests.
344 if [string match "*go.test/test/stress/*" $test] {
348 # Skip the files in safe; gccgo does not support safe mode.
349 if [string match "*go.test/test/safe/*" $test] {
353 # Skip files in sub-subdirectories: they are components of
355 if [string match "*go.test/test/*/*/*" $test] {
359 # Skip files in *.dir subdirectories: they are components of
361 if [string match "*go.test/test/*.dir/*" $test] {
365 set name [dg-trim-dirname $srcdir $test]
367 # Skip certain tests if target is RTEMS OS.
368 if [istarget "*-*-rtems*"] {
369 if { [string match "*go.test/test/args.go" $test] \
370 || [string match "*go.test/test/env.go" $test] } {
371 untested "$name: uses the command-line or environment variables"
375 if { [string match "*go.test/test/stack.go" $test] \
376 || [string match "*go.test/test/peano.go" $test] \
377 || [string match "*go.test/test/chan/goroutines.go" $test] } {
378 untested "$name: has very high memory requirement"
383 # Handle certain tests in a target-dependant way.
384 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] } {
385 if { [string match "*go.test/test/nilptr.go" $test] } {
391 if { [file tail $test] == "init1.go" } {
392 # This tests whether GC runs during init, which for gccgo
393 # it currently does not.
398 if { [file tail $test] == "closure.go" } {
399 # This tests whether function closures do any memory
400 # allocation, which for gccgo they currently do.
405 if { ( [file tail $test] == "select2.go" \
406 || [file tail $test] == "stack.go" \
407 || [file tail $test] == "peano.go" ) \
408 && ! [check_effective_target_split_stack] } {
409 # These tests fails on targets without split stack.
414 if [string match "*go.test/test/rotate\[0123\].go" $test] {
415 # These tests produces a temporary file that takes too long
416 # to compile--5 minutes on my laptop without optimization.
417 # When compiling without optimization it tests nothing
418 # useful, since the point of the test is to see whether
419 # the compiler generates rotate instructions.
424 if { [file tail $test] == "bug347.go" \
425 || [file tail $test] == "bug348.go" } {
426 # These tests don't work
if the functions are inlined.
427 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
430 set fd
[open $test r
]
435 if { [gets $fd test_line
] < 0 } {
437 clone_output
"$test: could not read first line"
443 if { [ string match
"*nacl*exit 0*" $test_line ] \
444 ||
[ string match
"*exit 0*nacl*" $test_line ] \
445 ||
[ string match
"*Android*exit 0*" $test_line ] \
446 ||
[ string match
"*exit 0*Android*" $test_line ] \
447 ||
[ string match
"*\"\$GOOS\" == windows*" $test_line ] } {
451 if { [ string match
"// +build *" $test_line ] } {
452 if { [ string match
"*[getenv GOARCH]*" $test_line ] } {
455 if { [ string match
"*linux*" $test_line ] } {
458 if { [ string match
"*!windows*" $test_line ] } {
469 if { $lines_ok
== 0 } {
474 set test_line1 $test_line
476 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
477 set lineno
[expr $lineno
+ 1]
478 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
480 clone_output
"$test: could not read line $lineno"
486 if { $lines_ok
== 0 } {
492 # runtest_file_p is already run above
, and the code below can run
493 # runtest_file_p again
, make sure everything
for this test is
494 # performed
if the above runtest_file_p decided this runtest
495 # instance should
execute the test
496 gcc_parallel_test_enable
0
498 set go_compile_args
""
499 set go_execute_args
""
500 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
501 && ! [string match
"*.go*" "$progargs"] } {
502 set go_execute_args $progargs
503 verbose
-log "$test: go_execute_args is $go_execute_args"
504 set index
[string last
" $progargs" $test_line]
505 set test_line
[string replace $test_line $index end
]
506 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
507 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
508 # goroutines.go spawns by default
10000 threads
, which is too much
510 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
511 set go_execute_args
64
512 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
513 # When using low ulimit
-u
limit, use maximum of
514 # a quarter of that
limit and
10000 even when running expensive
515 # tests
, otherwise parallel tests might fail after fork failures.
516 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
517 if { [string is
integer -strict $nproc
] } {
518 set nproc
[expr $nproc
/ 4]
519 if { $nproc
> 10000 } { set nproc
10000 }
520 if { $nproc
< 16 } { set nproc
16 }
521 set go_execute_args $nproc
524 if { "$go_execute_args" != "" } {
525 verbose
-log "$test: go_execute_args is $go_execute_args"
529 if { $test_line
== "// compile"
530 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
531 # This is a vanilla
compile test.
532 set dg
-do-what
-default
"assemble"
533 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
534 } elseif
{ $test_line
== "// run"
535 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
536 # This is a vanilla execution test.
537 go
-torture
-execute $test
538 file
delete core
[glob
-nocomplain core.
*]
539 } elseif
{ $test_line
== "// build" } {
540 # This is a vanilla
compile and link test.
541 set dg
-do-what
-default
"link"
542 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
543 } elseif
{ [string match
"// runoutput*" $test_line] \
544 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
545 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
546 # Run the test to
get a .go
program to run.
547 set go_execute_args
""
548 set hold_runtests $runtests
549 set runtests
"go-test.exp"
551 if { [string match
"// runoutput*" $test_line] } {
553 regsub
"// runoutput\(.*\)" $test_line "\\1" args
555 lappend files
"[file dirname $test]/$f"
558 set dg
-do-what
-default
"link"
559 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
560 set output_file
"./[file rootname [file tail $test]].exe"
561 set base
"[file rootname [file tail $test]]"
563 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
564 fail
"$name execution"
566 pass
"$name execution"
567 file
delete $base
-out.x
568 # Disable optimizations as some of these tests
569 # take a long time to
compile.
570 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
571 go
-torture
-execute "./$base-out.go"
573 file
delete $base
-out.go
575 file
delete $output_file
576 set runtests $hold_runtests
577 } elseif
{ $test_line
== "// cmpout" \
578 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
579 # This is an execution test
for which we need to check the
581 set hold_runtests $runtests
582 set runtests
"go-test.exp"
583 set dg
-do-what
-default
"link"
584 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
585 set output_file
"./[file rootname [file tail $test]].exe"
586 set base
"[file rootname [file tail $test]]"
588 verbose
-log "$output_file >$base.p 2>&1"
589 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
590 verbose
-log $catcherr
591 fail
"$name execution"
592 untested
"$name compare"
594 pass
"$name execution"
595 regsub
"\\.go$" $test ".out" expect
596 filecmp $expect $base.p
"$name compare"
600 untested
"$name execution"
601 untested
"$name compare"
603 set runtests $hold_runtests
604 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
606 go
-execute-xfail $test
607 } elseif
{ $test_line
== "// errorcheck" } {
609 } elseif
{ $test_line
== "// errorcheckdir" } {
610 set hold_runtests $runtests
611 set runtests
"go-test.exp"
612 set dir "[file rootname $test].dir"
613 set files
[lsort
[glob
"$dir/*.go"]]
614 set packages
[go
-find
-packages $test $
name $files
]
615 if { [llength $packages
] > 0 } {
616 set dg
-do-what
-default
"assemble"
618 set last
[lindex $packages end
]
619 set packages
[lreplace $packages end end
]
620 foreach p $packages
{
621 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
622 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
624 errchk
[lindex $last
1] "[lrange $last 2 end]"
629 set runtests $hold_runtests
630 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
631 # Run the test to
get a .go
program to error check.
632 set go_execute_args
""
633 set hold_runtests $runtests
634 set runtests
"go-test.exp"
636 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
638 lappend files
"[file dirname $test]/$f"
640 set dg
-do-what
-default
"link"
641 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
642 set output_file
"./[file rootname [file tail $test]].exe"
643 set base
"[file rootname [file tail $test]]"
645 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
646 fail
"$name execution"
648 pass
"$name execution"
649 errchk
"$base-out.go" ""
651 file
delete $base
-out.go
653 file
delete $output_file
654 set runtests $hold_runtests
655 } elseif
{ $test_line
== "// compiledir" } {
656 set hold_runtests $runtests
657 set runtests
"go-test.exp"
658 set dg
-do-what
-default
"assemble"
659 set dir "[file rootname $test].dir"
660 set files
[lsort
[glob
"$dir/*.go"]]
661 set packages
[go
-find
-packages $test $
name $files
]
662 if { [llength $packages
] > 0 } {
664 foreach p $packages
{
665 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O" "-w $DEFAULT_GOCFLAGS"
666 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
672 set runtests $hold_runtests
673 } elseif
{ $test_line
== "// rundir" } {
674 set hold_runtests $runtests
675 set runtests
"go-test.exp"
676 set dir "[file rootname $test].dir"
677 set files
[lsort
[glob
"$dir/*.go"]]
678 set packages
[go
-find
-packages $test $
name $files
]
679 if { [llength $packages
] > 0 } {
680 set dg
-do-what
-default
"assemble"
682 set last
[lindex $packages end
]
683 set packages
[lreplace $packages end end
]
684 foreach p $packages
{
685 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
686 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
688 set dg
-do-what
-default
"link"
689 set go_compile_args
""
690 append go_compile_args
[lrange $last
2 end
]
691 append go_compile_args $del
692 go
-torture
-execute [lindex $last
1]
697 set runtests $hold_runtests
698 } elseif
{ $test_line
== "// rundircmpout" } {
699 set hold_runtests $runtests
700 set runtests
"go-test.exp"
701 set dir "[file rootname $test].dir"
702 set files
[lsort
[glob
"$dir/*.go"]]
703 set packages
[go
-find
-packages $test $
name $files
]
704 if { [llength $packages
] > 0 } {
705 set dg
-do-what
-default
"assemble"
707 set last
[lindex $packages end
]
708 set packages
[lreplace $packages end end
]
709 foreach p $packages
{
710 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
711 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
713 set dg
-do-what
-default
"link"
714 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O" "-w $DEFAULT_GOCFLAGS"
715 set base
"[file rootname [file tail [lindex $last 1]]]"
716 set output_file
"./$base.exe"
717 lappend del $output_file
719 verbose
-log "$output_file >$base.p 2>&1"
720 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
721 verbose
-log $catcherr
722 fail
"$name execution"
723 untested
"$name compare"
725 pass
"$name execution"
726 regsub
"\\.go$" "$test" ".out" expect
727 filecmp $expect $base.p
"$name compare"
735 set runtests $hold_runtests
736 } elseif
{ "$test_line" == ""
737 ||
[string match
"// true*" $test_line]
738 ||
[string match
"// skip*" $test_line] } {
739 # Not a real test
, just ignore.
740 } elseif
{ [string match \
741 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
744 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
747 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
751 } elseif
{ [string match \
752 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
757 set hold_runtests $runtests
758 set runtests
"go-test.exp"
759 set dg
-do-what
-default
"assemble"
760 regsub
"\\.go$" $test ".dir/$name1" file1
761 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
762 regsub
"\\.go$" $test ".dir/$name2" file2
764 file
delete "[file rootname [file tail $file1]].o"
765 set runtests $hold_runtests
766 } elseif
{ [string match \
767 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
769 set hold_runtests $runtests
770 set runtests
"go-test.exp"
771 set dg
-do-what
-default
"assemble"
772 regsub
"\\.go$" $test "1.go" file1
773 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
775 file
delete "[file rootname [file tail $file1]].o"
776 set runtests $hold_runtests
777 } elseif
{ [string match \
778 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
780 set hold_runtests $runtests
781 set runtests
"go-test.exp"
782 set dg
-do-what
-default
"assemble"
783 regsub
"\\.go$" $test ".dir/bug0.go" file1
784 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
785 regsub
"\\.go$" $test ".dir/bug1.go" file2
786 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
787 regsub
"\\.go$" $test ".dir/bug2.go" file3
789 file
delete "[file rootname [file tail $file1]].o"
790 file
delete "[file rootname [file tail $file2]].o"
791 set runtests $hold_runtests
792 } elseif
{ [string match \
793 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
796 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
798 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
799 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
800 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
802 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
806 } elseif
{ [string match \
807 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
811 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
814 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
817 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
818 set name1
"method4a.go"
821 set hold_runtests $runtests
822 set runtests
"go-test.exp"
823 set dg
-do-what
-default
"assemble"
824 regsub
"\\.go$" $test ".dir/$name1" file1
825 if { $name1
== "method4a.go" } {
826 set file1
"[file dirname $test]/method4a.go"
828 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
829 set ofile1
"[file rootname [file tail $file1]].o"
830 regsub
"\\.go$" $test ".dir/$name2" file2
831 if { $name2
== "" } {
834 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
835 set ofile2
"[file rootname [file tail $file2]].o"
836 set dg
-do-what
-default
"link"
837 set output_file
"./[file rootname [file tail $test]].exe"
838 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
839 $output_file
"executable" "$options"]
840 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
841 verbose
-log $comp_output
842 set result
[go_load
"$output_file" "" ""]
843 set status [lindex $result
0]
845 file
delete $ofile1 $ofile2 $output_file
846 set runtests $hold_runtests
847 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
848 set hold_runtests $runtests
849 set runtests
"go-test.exp"
850 set dg
-do-what
-default
"assemble"
851 regsub
"\\.go$" $test ".dir/one.go" file1
852 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
853 set ofile1
"[file rootname [file tail $file1]].o"
854 regsub
"\\.go$" $test ".dir/two.go" file2
855 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
856 set ofile2
"[file rootname [file tail $file2]].o"
857 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
858 set ofile3
"[file rootname [file tail $test]].o"
859 set dg
-do-what
-default
"link"
860 set output_file
"./[file rootname [file tail $test]].exe"
861 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
862 $output_file
"executable" "$options"]
863 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
864 verbose
-log $comp_output
865 set result
[go_load
"$output_file" "" ""]
866 set status [lindex $result
0]
868 file
delete $ofile1 $ofile2 $ofile3 $output_file
869 set runtests $hold_runtests
870 } elseif
{ [string match \
871 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
873 set hold_runtests $runtests
874 set runtests
"go-test.exp"
875 set dg
-do-what
-default
"assemble"
876 regsub
"/\[^/\]*$" $test "/embed0.go" file1
877 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
878 set ofile1
"[file rootname [file tail $file1]].o"
879 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
880 set ofile2
"[file rootname [file tail $test]].o"
881 set output_file
"./[file rootname [file tail $test]].exe"
882 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
883 $output_file
"executable" "$options"]
884 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
885 if [string match
"" $comp_output] {
886 set result
[go_load
"$output_file" "" ""]
887 set status [lindex $result
0]
890 verbose
-log $comp_output
893 file
delete $ofile1 $ofile2 $output_file
894 set runtests $hold_runtests
895 } elseif
{ [string match \
896 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
899 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
902 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
906 } elseif
{ [string match \
907 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
912 set hold_runtests $runtests
913 set runtests
"go-test.exp"
914 set dg
-do-what
-default
"assemble"
915 regsub
"\\.go$" $test ".dir/$name1" file1
916 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
917 set ofile1
"[file rootname [file tail $file1]].o"
918 regsub
"\\.go$" $test ".dir/$name2" file2
919 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
920 set ofile2
"[file rootname [file tail $file2]].o"
921 set dg
-do-what
-default
"link"
922 set output_file
"./[file rootname [file tail $file2]].exe"
923 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
924 $output_file
"executable" "$options"]
925 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
926 if [string match
"" $comp_output] {
927 set result
[go_load
"$output_file" "" ""]
928 set status [lindex $result
0]
931 verbose
-log $comp_output
934 file
delete $ofile1 $ofile2 $output_file
935 set runtests $hold_runtests
936 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
937 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
938 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
939 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
940 && $test_line5
== "// \$L bug2.\$A &&" \
941 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
942 set hold_runtests $runtests
943 set runtests
"go-test.exp"
944 set dg
-do-what
-default
"assemble"
945 regsub
"\\.go$" $test ".dir/bug0.go" file0
946 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
947 set ofile0
"[file rootname [file tail $file0]].o"
948 regsub
"\\.go$" $test ".dir/bug1.go" file1
949 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
950 set ofile1
"[file rootname [file tail $file1]].o"
951 regsub
"\\.go$" $test ".dir/bug2.go" file2
952 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
953 set ofile2
"[file rootname [file tail $file2]].o"
954 regsub
"\\.go$" $test ".dir/bug3.go" file3
956 set output_file
"./[file rootname [file tail $test]].exe"
957 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
958 $output_file
"executable" "$options"]
959 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
960 if [string match
"" $comp_output] {
961 set result
[go_load
"$output_file" "" ""]
962 set status [lindex $result
0]
965 verbose
-log $comp_output
968 file
delete $ofile0 $ofile1 $ofile2 $output_file
969 set runtests $hold_runtests
970 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
971 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
972 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
973 set name1
"import2.go"
974 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
975 set name1
"recursive1.go"
977 set hold_runtests $runtests
978 set runtests
"go-test.exp"
979 set dg
-do-what
-default
"assemble"
980 regsub
"/\[^/\]*$" $test "/${name1}" file1
981 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
982 set ofile1
"[file rootname [file tail $file1]].o"
983 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
985 set runtests $hold_runtests
986 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
987 set hold_runtests $runtests
988 set runtests
"go-test.exp"
989 set dg
-do-what
-default
"assemble"
990 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
991 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
992 set ofile1
"[file rootname [file tail $file1]].o"
993 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
994 set ofile2
"[file rootname [file tail $test]].o"
995 set output_file
"./[file rootname [file tail $test]].exe"
996 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
997 $output_file
"executable" "$options"]
998 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
999 if [string match
"" $comp_output] {
1000 set result
[go_load
"$output_file" "" ""]
1001 set status [lindex $result
0]
1004 verbose
-log $comp_output
1007 file
delete $ofile1 $ofile2 $output_file
1008 set runtests $hold_runtests
1009 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1010 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1011 set output_file
"./[file rootname [file tail $test]].o"
1012 set comp_output
[go_target_compile
"$test $test2" \
1013 $output_file
"executable" "$options"]
1014 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1015 if [string match
"" $comp_output] {
1016 set result
[go_load
"$output_file" "" ""]
1017 set status [lindex $result
0]
1020 verbose
-log $comp_output
1023 file
delete $output_file
1024 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1025 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1026 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1027 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1028 set go_execute_args
""
1029 set hold_runtests $runtests
1030 set runtests
"go-test.exp"
1031 set dg
-do-what
-default
"link"
1032 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1033 set output_file
"./[file rootname [file tail $test]].exe"
1035 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1036 fail
"$name execution 0"
1038 pass
"$name execution 0"
1040 # Disable optimizations as this test takes a long time
1042 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1043 go
-torture
-execute "./tmp.go"
1045 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1046 fail
"$name execution 1"
1048 pass
"$name execution 1"
1051 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1052 fail
"$name execution 2"
1054 pass
"$name execution 2"
1059 file
delete $output_file
1060 set runtests $hold_runtests
1061 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1062 && $test_line2
== "// errchk \$G -e tmp.go" } {
1063 set go_execute_args
""
1064 set hold_runtests $runtests
1065 set runtests
"go-test.exp"
1066 set dg
-do-what
-default
"link"
1067 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1068 set output_file
"./[file rootname [file tail $test]].exe"
1070 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1071 fail
"$name execution"
1073 pass
"$name execution"
1078 file
delete $output_file
1079 set runtests $hold_runtests
1080 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1081 regsub
"\\.go$" $test ".dir/a.go" file1
1082 regsub
"\\.go$" $test ".dir/b.go" file2
1083 errchk
"$file1" "$file2"
1084 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1085 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1086 && $test_line3
== "// run" } {
1087 set hold_runtests $runtests
1088 set runtests
"go-test.exp"
1089 set dg
-do-what
-default
"assemble"
1090 regsub
"\\.go$" $test ".dir/pkg.go" file1
1091 dg
-test
-keep
-output $file1
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1092 set ofile1
"[file rootname [file tail $file1]].o"
1093 file
rename -force $ofile1 slow.o
1094 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1095 file
rename -force $ofile1 fast.o
1096 set ofile2
"[file rootname [file tail $test]].o"
1097 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1098 set output_file
"./[file rootname [file tail $test]].exe"
1099 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1100 $output_file
"executable" "$options"]
1101 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1102 if [string match
"" $comp_output] {
1103 set result
[go_load
"$output_file" "" ""]
1104 set status [lindex $result
0]
1107 verbose
-log $comp_output
1110 file
delete slow.o fast.o $ofile2 $output_file
1111 set runtests $hold_runtests
1112 } elseif
{ [string match \
1113 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1115 set hold_runtests $runtests
1116 set runtests
"go-test.exp"
1117 set dg
-do-what
-default
"assemble"
1118 regsub
"\\.go$" $test ".dir/pkg.go" file1
1119 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1120 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1121 file
delete "[file rootname [file tail $file1]].o"
1122 set runtests $hold_runtests
1123 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1125 set hold_runtests $runtests
1126 set runtests
"go-test.exp"
1127 set dg
-do-what
-default
"assemble"
1128 regsub
"\\.go$" $test ".dir/one.go" file1
1129 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1130 set ofile1
"[file rootname [file tail $file1]].o"
1131 regsub
"\\.go$" $test ".dir/two.go" file2
1132 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1134 set runtests $hold_runtests
1135 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1136 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1137 # These tests
import the same package under two different
1138 # names
, which gccgo does not support.
1139 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1140 # This tests whether initializers are written out
1141 # statically. gccgo does not provide a way to test that
,
1142 # as an initializer will be generated
for any code which
1143 # has global variables which need to be registered as GC
1145 } elseif
{ $test_line
== "// errorcheck -0 -m"
1146 || $test_line
== "// errorcheck -0 -m -l" } {
1147 # This tests debug output of the gc compiler
, which is
1148 # meaningless
for gccgo.
1149 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1150 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1151 # This tests specific handling of the gc compiler
on types
1152 # that are too large. It is target specific in a way I
1153 # haven
't bothered to check for here.
1154 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1155 # This tests the gc ld -X option, which gccgo does not
1157 } 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"
1158 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1159 # This tests the gc -u option, which gccgo does not
1161 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1162 || $test_line == "// errorcheck -0 -d=nil" } {
1163 # This tests gc nil pointer checks using -d=nil, which
1164 # gccgo does not support.
1166 clone_output "$name: unrecognized test line: $test_line"
1170 set go_compile_args ""
1171 set go_execute_args ""
1172 set TORTURE_OPTIONS [list { -O2 -g }]
1173 gcc_parallel_test_enable 1
1176 set dg-do-what-default ${saved-dg-do-what-default}
1177 set TORTURE_OPTIONS $saved_torture_options