1 # Copyright
(C
) 2009-2015 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 || [file tail $test] == "nilptr2.go" ) \
419 && ! [check_effective_target_split_stack] } {
420 # These tests fails on targets without split stack.
425 if [string match "*go.test/test/rotate\[0123\].go" $test] {
426 # These tests produces a temporary file that takes too long
427 # to compile--5 minutes on my laptop without optimization.
428 # When compiling without optimization it tests nothing
429 # useful, since the point of the test is to see whether
430 # the compiler generates rotate instructions.
435 if { [file tail $test] == "bug347.go" \
436 || [file tail $test] == "bug348.go" } {
437 # These tests don't work
if the functions are inlined.
438 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
441 set fd
[open $test r
]
446 if { [gets $fd test_line
] < 0 } {
448 clone_output
"$test: could not read first line"
454 if { [ string match
"*nacl*exit 0*" $test_line ] \
455 ||
[ string match
"*exit 0*nacl*" $test_line ] \
456 ||
[ string match
"*Android*exit 0*" $test_line ] \
457 ||
[ string match
"*exit 0*Android*" $test_line ] \
458 ||
[ string match
"*\"\$GOOS\" == windows*" $test_line ] } {
462 if { [ string match
"// +build *" $test_line ] } {
465 if { [ regexp
-line
"\[ \][getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
467 } elseif
{ [ regexp
-line
"\[ \]\![getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
469 } elseif
{ [ regexp
-line
"\[ \]linux\(\[ \]\|\$\)" $test_line ] } {
471 } elseif
{ [ regexp
-line
"\[ \]\!linux\(\[ \]\|\$\)" $test_line ] } {
473 } elseif
{ [ regexp
-line
"\[ \]\!windows\(\[ \]\|\$\)" $test_line ] } {
475 } elseif
{ [ regexp
-line
"\[ \]windows\(\[ \]\|\$\)" $test_line ] } {
478 if { $matches_pos
== 1 && $matches_neg
== 0 } {
489 if { $lines_ok
== 0 } {
494 set test_line1 $test_line
496 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
497 set lineno
[expr $lineno
+ 1]
498 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
500 clone_output
"$test: could not read line $lineno"
506 if { $lines_ok
== 0 } {
512 # runtest_file_p is already run above
, and the code below can run
513 # runtest_file_p again
, make sure everything
for this test is
514 # performed
if the above runtest_file_p decided this runtest
515 # instance should
execute the test
516 gcc_parallel_test_enable
0
518 set go_compile_args
""
519 set go_execute_args
""
520 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
521 && ! [string match
"*.go*" "$progargs"] } {
522 set go_execute_args $progargs
523 verbose
-log "$test: go_execute_args is $go_execute_args"
524 set index
[string last
" $progargs" $test_line]
525 set test_line
[string replace $test_line $index end
]
526 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
527 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
528 # goroutines.go spawns by default
10000 threads
, which is too much
530 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
531 set go_execute_args
64
532 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
533 # When using low ulimit
-u
limit, use maximum of
534 # a quarter of that
limit and
10000 even when running expensive
535 # tests
, otherwise parallel tests might fail after fork failures.
536 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
537 if { [string is
integer -strict $nproc
] } {
538 set nproc
[expr $nproc
/ 4]
539 if { $nproc
> 10000 } { set nproc
10000 }
540 if { $nproc
< 16 } { set nproc
16 }
541 set go_execute_args $nproc
544 if { "$go_execute_args" != "" } {
545 verbose
-log "$test: go_execute_args is $go_execute_args"
549 if { $test_line
== "// compile"
550 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
551 # This is a vanilla
compile test.
552 set dg
-do-what
-default
"assemble"
553 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
554 } elseif
{ $test_line
== "// run"
555 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
556 # This is a vanilla execution test.
557 go
-torture
-execute $test
558 file
delete core
[glob
-nocomplain core.
*]
559 } elseif
{ $test_line
== "// build" } {
560 # This is a vanilla
compile and link test.
561 set dg
-do-what
-default
"link"
562 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
563 } elseif
{ [string match
"// runoutput*" $test_line] \
564 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
565 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
566 # Run the test to
get a .go
program to run.
567 set go_execute_args
""
568 set hold_runtests $runtests
569 set runtests
"go-test.exp"
571 if { [string match
"// runoutput*" $test_line] } {
573 regsub
"// runoutput\(.*\)" $test_line "\\1" args
575 lappend files
"[file dirname $test]/$f"
578 set dg
-do-what
-default
"link"
579 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
580 set output_file
"./[file rootname [file tail $test]].exe"
581 set base
"[file rootname [file tail $test]]"
583 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
584 fail
"$name execution"
586 pass
"$name execution"
587 file
delete $base
-out.x
588 # Disable optimizations as some of these tests
589 # take a long time to
compile.
590 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
591 go
-torture
-execute "./$base-out.go"
593 file
delete $base
-out.go
595 file
delete $output_file
596 set runtests $hold_runtests
597 } elseif
{ $test_line
== "// cmpout" \
598 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
599 # This is an execution test
for which we need to check the
601 set hold_runtests $runtests
602 set runtests
"go-test.exp"
603 set dg
-do-what
-default
"link"
604 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
605 set output_file
"./[file rootname [file tail $test]].exe"
606 set base
"[file rootname [file tail $test]]"
608 verbose
-log "$output_file >$base.p 2>&1"
609 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
610 verbose
-log $catcherr
611 fail
"$name execution"
612 untested
"$name compare"
614 pass
"$name execution"
615 regsub
"\\.go$" $test ".out" expect
616 filecmp $expect $base.p
"$name compare"
617 file
delete $output_file
621 untested
"$name execution"
622 untested
"$name compare"
624 set runtests $hold_runtests
625 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
627 go
-execute-xfail $test
628 } elseif
{ $test_line
== "// errorcheck" } {
630 } elseif
{ $test_line
== "// errorcheckdir" } {
631 set hold_runtests $runtests
632 set runtests
"go-test.exp"
633 set dir "[file rootname $test].dir"
634 set files
[lsort
[glob
"$dir/*.go"]]
635 set packages
[go
-find
-packages $test $
name $files
]
636 if { [llength $packages
] > 0 } {
637 set dg
-do-what
-default
"assemble"
639 set last
[lindex $packages end
]
640 set packages
[lreplace $packages end end
]
641 foreach p $packages
{
642 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
643 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
645 errchk
[lindex $last
1] "[lrange $last 2 end]"
650 set runtests $hold_runtests
651 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
652 # Run the test to
get a .go
program to error check.
653 set go_execute_args
""
654 set hold_runtests $runtests
655 set runtests
"go-test.exp"
657 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
659 lappend files
"[file dirname $test]/$f"
661 set dg
-do-what
-default
"link"
662 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
663 set output_file
"./[file rootname [file tail $test]].exe"
664 set base
"[file rootname [file tail $test]]"
666 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
667 fail
"$name execution"
669 pass
"$name execution"
670 errchk
"$base-out.go" ""
672 file
delete $base
-out.go
674 file
delete $output_file
675 set runtests $hold_runtests
676 } elseif
{ $test_line
== "// compiledir" } {
677 set hold_runtests $runtests
678 set runtests
"go-test.exp"
679 set dg
-do-what
-default
"assemble"
680 set dir "[file rootname $test].dir"
681 set files
[lsort
[glob
"$dir/*.go"]]
682 set packages
[go
-find
-packages $test $
name $files
]
683 if { [llength $packages
] > 0 } {
685 foreach p $packages
{
686 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O" "-w $DEFAULT_GOCFLAGS"
687 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
693 set runtests $hold_runtests
694 } elseif
{ $test_line
== "// rundir" } {
695 set hold_runtests $runtests
696 set runtests
"go-test.exp"
697 set dir "[file rootname $test].dir"
698 set files
[lsort
[glob
"$dir/*.go"]]
699 set packages
[go
-find
-packages $test $
name $files
]
700 if { [llength $packages
] > 0 } {
701 set dg
-do-what
-default
"assemble"
703 set last
[lindex $packages end
]
704 set packages
[lreplace $packages end end
]
705 foreach p $packages
{
706 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
707 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
709 set dg
-do-what
-default
"link"
710 set go_compile_args
""
711 append go_compile_args
[lrange $last
2 end
]
712 append go_compile_args $del
713 go
-torture
-execute [lindex $last
1]
718 set runtests $hold_runtests
719 } elseif
{ $test_line
== "// rundircmpout" } {
720 set hold_runtests $runtests
721 set runtests
"go-test.exp"
722 set dir "[file rootname $test].dir"
723 set files
[lsort
[glob
"$dir/*.go"]]
724 set packages
[go
-find
-packages $test $
name $files
]
725 if { [llength $packages
] > 0 } {
726 set dg
-do-what
-default
"assemble"
728 set last
[lindex $packages end
]
729 set packages
[lreplace $packages end end
]
730 foreach p $packages
{
731 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
732 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
734 set dg
-do-what
-default
"link"
735 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O" "-w $DEFAULT_GOCFLAGS"
736 set base
"[file rootname [file tail [lindex $last 1]]]"
737 set output_file
"./$base.exe"
738 lappend del $output_file
740 verbose
-log "$output_file >$base.p 2>&1"
741 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
742 verbose
-log $catcherr
743 fail
"$name execution"
744 untested
"$name compare"
746 pass
"$name execution"
747 regsub
"\\.go$" "$test" ".out" expect
748 filecmp $expect $base.p
"$name compare"
756 set runtests $hold_runtests
757 } elseif
{ "$test_line" == ""
758 ||
[string match
"// true*" $test_line]
759 ||
[string match
"// skip*" $test_line] } {
760 # Not a real test
, just ignore.
761 } elseif
{ [string match \
762 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
765 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
768 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
772 } elseif
{ [string match \
773 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
778 set hold_runtests $runtests
779 set runtests
"go-test.exp"
780 set dg
-do-what
-default
"assemble"
781 regsub
"\\.go$" $test ".dir/$name1" file1
782 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
783 regsub
"\\.go$" $test ".dir/$name2" file2
785 file
delete "[file rootname [file tail $file1]].o"
786 set runtests $hold_runtests
787 } elseif
{ [string match \
788 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
790 set hold_runtests $runtests
791 set runtests
"go-test.exp"
792 set dg
-do-what
-default
"assemble"
793 regsub
"\\.go$" $test "1.go" file1
794 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
796 file
delete "[file rootname [file tail $file1]].o"
797 set runtests $hold_runtests
798 } elseif
{ [string match \
799 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
801 set hold_runtests $runtests
802 set runtests
"go-test.exp"
803 set dg
-do-what
-default
"assemble"
804 regsub
"\\.go$" $test ".dir/bug0.go" file1
805 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
806 regsub
"\\.go$" $test ".dir/bug1.go" file2
807 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
808 regsub
"\\.go$" $test ".dir/bug2.go" file3
810 file
delete "[file rootname [file tail $file1]].o"
811 file
delete "[file rootname [file tail $file2]].o"
812 set runtests $hold_runtests
813 } elseif
{ [string match \
814 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
817 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
819 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
820 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
821 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
823 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
827 } elseif
{ [string match \
828 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
832 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
835 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
838 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
839 set name1
"method4a.go"
842 set hold_runtests $runtests
843 set runtests
"go-test.exp"
844 set dg
-do-what
-default
"assemble"
845 regsub
"\\.go$" $test ".dir/$name1" file1
846 if { $name1
== "method4a.go" } {
847 set file1
"[file dirname $test]/method4a.go"
849 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
850 set ofile1
"[file rootname [file tail $file1]].o"
851 regsub
"\\.go$" $test ".dir/$name2" file2
852 if { $name2
== "" } {
855 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
856 set ofile2
"[file rootname [file tail $file2]].o"
857 set dg
-do-what
-default
"link"
858 set output_file
"./[file rootname [file tail $test]].exe"
859 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
860 $output_file
"executable" "$options"]
861 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
862 verbose
-log $comp_output
863 set result
[go_load
"$output_file" "" ""]
864 set status [lindex $result
0]
866 file
delete $ofile1 $ofile2 $output_file
867 set runtests $hold_runtests
868 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
869 set hold_runtests $runtests
870 set runtests
"go-test.exp"
871 set dg
-do-what
-default
"assemble"
872 regsub
"\\.go$" $test ".dir/one.go" file1
873 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
874 set ofile1
"[file rootname [file tail $file1]].o"
875 regsub
"\\.go$" $test ".dir/two.go" file2
876 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
877 set ofile2
"[file rootname [file tail $file2]].o"
878 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
879 set ofile3
"[file rootname [file tail $test]].o"
880 set dg
-do-what
-default
"link"
881 set output_file
"./[file rootname [file tail $test]].exe"
882 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
883 $output_file
"executable" "$options"]
884 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
885 verbose
-log $comp_output
886 set result
[go_load
"$output_file" "" ""]
887 set status [lindex $result
0]
889 file
delete $ofile1 $ofile2 $ofile3 $output_file
890 set runtests $hold_runtests
891 } elseif
{ [string match \
892 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
894 set hold_runtests $runtests
895 set runtests
"go-test.exp"
896 set dg
-do-what
-default
"assemble"
897 regsub
"/\[^/\]*$" $test "/embed0.go" file1
898 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
899 set ofile1
"[file rootname [file tail $file1]].o"
900 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
901 set ofile2
"[file rootname [file tail $test]].o"
902 set output_file
"./[file rootname [file tail $test]].exe"
903 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
904 $output_file
"executable" "$options"]
905 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
906 if [string match
"" $comp_output] {
907 set result
[go_load
"$output_file" "" ""]
908 set status [lindex $result
0]
911 verbose
-log $comp_output
914 file
delete $ofile1 $ofile2 $output_file
915 set runtests $hold_runtests
916 } elseif
{ [string match \
917 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
920 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
923 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
927 } elseif
{ [string match \
928 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
933 set hold_runtests $runtests
934 set runtests
"go-test.exp"
935 set dg
-do-what
-default
"assemble"
936 regsub
"\\.go$" $test ".dir/$name1" file1
937 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
938 set ofile1
"[file rootname [file tail $file1]].o"
939 regsub
"\\.go$" $test ".dir/$name2" file2
940 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
941 set ofile2
"[file rootname [file tail $file2]].o"
942 set dg
-do-what
-default
"link"
943 set output_file
"./[file rootname [file tail $file2]].exe"
944 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
945 $output_file
"executable" "$options"]
946 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
947 if [string match
"" $comp_output] {
948 set result
[go_load
"$output_file" "" ""]
949 set status [lindex $result
0]
952 verbose
-log $comp_output
955 file
delete $ofile1 $ofile2 $output_file
956 set runtests $hold_runtests
957 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
958 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
959 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
960 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
961 && $test_line5
== "// \$L bug2.\$A &&" \
962 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
963 set hold_runtests $runtests
964 set runtests
"go-test.exp"
965 set dg
-do-what
-default
"assemble"
966 regsub
"\\.go$" $test ".dir/bug0.go" file0
967 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
968 set ofile0
"[file rootname [file tail $file0]].o"
969 regsub
"\\.go$" $test ".dir/bug1.go" file1
970 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
971 set ofile1
"[file rootname [file tail $file1]].o"
972 regsub
"\\.go$" $test ".dir/bug2.go" file2
973 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
974 set ofile2
"[file rootname [file tail $file2]].o"
975 regsub
"\\.go$" $test ".dir/bug3.go" file3
977 set output_file
"./[file rootname [file tail $test]].exe"
978 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
979 $output_file
"executable" "$options"]
980 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
981 if [string match
"" $comp_output] {
982 set result
[go_load
"$output_file" "" ""]
983 set status [lindex $result
0]
986 verbose
-log $comp_output
989 file
delete $ofile0 $ofile1 $ofile2 $output_file
990 set runtests $hold_runtests
991 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
992 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
993 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
994 set name1
"import2.go"
995 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
996 set name1
"recursive1.go"
998 set hold_runtests $runtests
999 set runtests
"go-test.exp"
1000 set dg
-do-what
-default
"assemble"
1001 regsub
"/\[^/\]*$" $test "/${name1}" file1
1002 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1003 set ofile1
"[file rootname [file tail $file1]].o"
1004 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1006 set runtests $hold_runtests
1007 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1008 set hold_runtests $runtests
1009 set runtests
"go-test.exp"
1010 set dg
-do-what
-default
"assemble"
1011 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
1012 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1013 set ofile1
"[file rootname [file tail $file1]].o"
1014 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1015 set ofile2
"[file rootname [file tail $test]].o"
1016 set output_file
"./[file rootname [file tail $test]].exe"
1017 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
1018 $output_file
"executable" "$options"]
1019 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1020 if [string match
"" $comp_output] {
1021 set result
[go_load
"$output_file" "" ""]
1022 set status [lindex $result
0]
1025 verbose
-log $comp_output
1028 file
delete $ofile1 $ofile2 $output_file
1029 set runtests $hold_runtests
1030 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1031 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1032 set output_file
"./[file rootname [file tail $test]].o"
1033 set comp_output
[go_target_compile
"$test $test2" \
1034 $output_file
"executable" "$options"]
1035 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1036 if [string match
"" $comp_output] {
1037 set result
[go_load
"$output_file" "" ""]
1038 set status [lindex $result
0]
1041 verbose
-log $comp_output
1044 file
delete $output_file
1045 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1046 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1047 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1048 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1049 set go_execute_args
""
1050 set hold_runtests $runtests
1051 set runtests
"go-test.exp"
1052 set dg
-do-what
-default
"link"
1053 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1054 set output_file
"./[file rootname [file tail $test]].exe"
1056 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1057 fail
"$name execution 0"
1059 pass
"$name execution 0"
1061 # Disable optimizations as this test takes a long time
1063 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1064 go
-torture
-execute "./tmp.go"
1066 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1067 fail
"$name execution 1"
1069 pass
"$name execution 1"
1072 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1073 fail
"$name execution 2"
1075 pass
"$name execution 2"
1080 file
delete $output_file
1081 set runtests $hold_runtests
1082 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1083 && $test_line2
== "// errchk \$G -e tmp.go" } {
1084 set go_execute_args
""
1085 set hold_runtests $runtests
1086 set runtests
"go-test.exp"
1087 set dg
-do-what
-default
"link"
1088 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1089 set output_file
"./[file rootname [file tail $test]].exe"
1091 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1092 fail
"$name execution"
1094 pass
"$name execution"
1099 file
delete $output_file
1100 set runtests $hold_runtests
1101 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1102 regsub
"\\.go$" $test ".dir/a.go" file1
1103 regsub
"\\.go$" $test ".dir/b.go" file2
1104 errchk
"$file1" "$file2"
1105 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1106 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1107 && $test_line3
== "// run" } {
1108 set hold_runtests $runtests
1109 set runtests
"go-test.exp"
1110 set dg
-do-what
-default
"assemble"
1111 regsub
"\\.go$" $test ".dir/pkg.go" file1
1112 dg
-test
-keep
-output $file1
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1113 set ofile1
"[file rootname [file tail $file1]].o"
1114 file
rename -force $ofile1 slow.o
1115 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1116 file
rename -force $ofile1 fast.o
1117 set ofile2
"[file rootname [file tail $test]].o"
1118 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1119 set output_file
"./[file rootname [file tail $test]].exe"
1120 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1121 $output_file
"executable" "$options"]
1122 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1123 if [string match
"" $comp_output] {
1124 set result
[go_load
"$output_file" "" ""]
1125 set status [lindex $result
0]
1128 verbose
-log $comp_output
1131 file
delete slow.o fast.o $ofile2 $output_file
1132 set runtests $hold_runtests
1133 } elseif
{ [string match \
1134 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1136 set hold_runtests $runtests
1137 set runtests
"go-test.exp"
1138 set dg
-do-what
-default
"assemble"
1139 regsub
"\\.go$" $test ".dir/pkg.go" file1
1140 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1141 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1142 file
delete "[file rootname [file tail $file1]].o"
1143 set runtests $hold_runtests
1144 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1146 set hold_runtests $runtests
1147 set runtests
"go-test.exp"
1148 set dg
-do-what
-default
"assemble"
1149 regsub
"\\.go$" $test ".dir/one.go" file1
1150 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1151 set ofile1
"[file rootname [file tail $file1]].o"
1152 regsub
"\\.go$" $test ".dir/two.go" file2
1153 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1155 set runtests $hold_runtests
1156 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1157 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1158 # These tests
import the same package under two different
1159 # names
, which gccgo does not support.
1160 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1161 # This tests whether initializers are written out
1162 # statically. gccgo does not provide a way to test that
,
1163 # as an initializer will be generated
for any code which
1164 # has global variables which need to be registered as GC
1166 } elseif
{ $test_line
== "// errorcheck -0 -m"
1167 || $test_line
== "// errorcheck -0 -m -l" } {
1168 # This tests debug output of the gc compiler
, which is
1169 # meaningless
for gccgo.
1170 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1171 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1172 # This tests specific handling of the gc compiler
on types
1173 # that are too large. It is target specific in a way I
1174 # haven
't bothered to check for here.
1175 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1176 # This tests the gc ld -X option, which gccgo does not
1178 } 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"
1179 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1180 # This tests the gc -u option, which gccgo does not
1182 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1183 || $test_line == "// errorcheck -0 -d=nil" } {
1184 # This tests gc nil pointer checks using -d=nil, which
1185 # gccgo does not support.
1187 clone_output "$name: unrecognized test line: $test_line"
1191 set go_compile_args ""
1192 set go_execute_args ""
1193 set TORTURE_OPTIONS [list { -O2 -g }]
1194 gcc_parallel_test_enable 1
1197 set dg-do-what-default ${saved-dg-do-what-default}
1198 set TORTURE_OPTIONS $saved_torture_options