1 # Copyright
(C
) 2009-2018 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] {
206 } elseif [check_effective_target_x32] {
207 set goarch "amd64p32"
213 if [check_no_compiler_messages mipso32 assembly {
214 #if _MIPS_SIM != _ABIO32
219 } elseif [check_no_compiler_messages mipsn32 assembly {
220 #if _MIPS_SIM != _ABIN32
224 set goarch "mips64p32"
225 } elseif [check_no_compiler_messages mipsn64 assembly {
226 #if _MIPS_SIM != _ABI64
232 perror "$target_triplet: unrecognized MIPS ABI"
236 if [istarget "mips*el-*-*"] {
241 if [check_effective_target_ilp32] {
244 if [istarget "powerpc64le-*-*"] {
255 if [check_effective_target_ilp32] {
262 if [check_effective_target_ilp32] {
269 perror "$target_triplet: unhandled architecture"
273 verbose -log "Setting GOARCH=$goarch" 1
274 setenv GOARCH $goarch
277 # Take a list of files and return a lists of lists, where each list is
278 # the set of files in the same package.
279 proc go-find-packages { test name files } {
284 if { [gets $fd line] < 0 } {
286 clone_output "$test: could not read $f"
291 if { [regexp "^package (\\w+)" $line match package] } {
292 set len [llength $packages]
293 for { set i 0 } { $i < $len } { incr i } {
294 set p [lindex $packages $i]
295 if { [lindex $p 0] == $package } {
302 lappend packages [list $package $f]
313 proc go-gc-tests { } {
316 global GCC_UNDER_TEST
318 global TORTURE_OPTIONS
319 global dg-do-what-default
320 global go_compile_args
321 global go_execute_args
322 global target_triplet
324 # If a testcase doesn't have special options
, use these.
325 global DEFAULT_GOCFLAGS
326 if ![info exists DEFAULT_GOCFLAGS
] {
327 set DEFAULT_GOCFLAGS
" -pedantic-errors"
331 lappend options
"additional_flags=$DEFAULT_GOCFLAGS"
333 #
Set GOARCH
for tests that need it.
336 # Running all the torture options takes too long and
, since the
337 # frontend ignores the standard options
, it doesn
't significantly
339 set saved_torture_options $TORTURE_OPTIONS
340 set TORTURE_OPTIONS [list { -O2 -g }]
342 set saved-dg-do-what-default ${dg-do-what-default}
346 set tests [lsort [find $srcdir/$subdir *.go]]
347 foreach test $tests {
348 if ![runtest_file_p $runtests $test] {
352 # Skip the files in bench; they are not tests.
353 if [string match "*go.test/test/bench/*" $test] {
357 # Skip the files in stress; they are not tests.
358 if [string match "*go.test/test/stress/*" $test] {
362 # Skip the files in safe; gccgo does not support safe mode.
363 if [string match "*go.test/test/safe/*" $test] {
367 # Skip files in sub-subdirectories: they are components of
369 if [string match "*go.test/test/*/*/*" $test] {
373 # Skip files in *.dir subdirectories: they are components of
375 if [string match "*go.test/test/*.dir/*" $test] {
379 set name [dg-trim-dirname $srcdir $test]
381 # Skip certain tests if target is RTEMS OS.
382 if [istarget "*-*-rtems*"] {
383 if { [string match "*go.test/test/args.go" $test] \
384 || [string match "*go.test/test/env.go" $test] } {
385 untested "$name: uses the command-line or environment variables"
389 if { [string match "*go.test/test/stack.go" $test] \
390 || [string match "*go.test/test/peano.go" $test] \
391 || [string match "*go.test/test/chan/goroutines.go" $test] } {
392 untested "$name: has very high memory requirement"
397 # Handle certain tests in a target-dependant way.
398 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] || [istarget "s390*-*-*"] } {
399 if { [string match "*go.test/test/nilptr.go" $test] } {
405 if [check_effective_target_pie_enabled] {
410 if { [file tail $test] == "init1.go" } {
411 # This tests whether GC runs during init, which for gccgo
412 # it currently does not.
417 if { [file tail $test] == "closure.go" } {
418 # This tests whether function closures do any memory
419 # allocation, which for gccgo they currently do.
424 if { ( [file tail $test] == "select2.go" \
425 || [file tail $test] == "stack.go" \
426 || [file tail $test] == "peano.go" \
427 || [file tail $test] == "nilptr2.go" ) \
428 && ! [check_effective_target_split_stack] } {
429 # These tests fails on targets without split stack.
434 if [string match "*go.test/test/rotate\[0123\].go" $test] {
435 # These tests produces a temporary file that takes too long
436 # to compile--5 minutes on my laptop without optimization.
437 # When compiling without optimization it tests nothing
438 # useful, since the point of the test is to see whether
439 # the compiler generates rotate instructions.
444 if { [file tail $test] == "bug347.go" \
445 || [file tail $test] == "bug348.go" } {
446 # These tests don't work
if the functions are inlined.
447 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
450 set fd
[open $test r
]
455 if { [gets $fd test_line
] < 0 } {
457 clone_output
"$test: could not read first line"
463 if { [ string match
"*nacl*exit 0*" $test_line ] \
464 ||
[ string match
"*exit 0*nacl*" $test_line ] \
465 ||
[ string match
"*Android*exit 0*" $test_line ] \
466 ||
[ string match
"*exit 0*Android*" $test_line ] \
467 ||
[ string match
"*\"\$GOOS\" == windows*" $test_line ] } {
471 if { [ string match
"// +build *" $test_line ] } {
474 if { [ regexp
-line
"\[ \][getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
476 } elseif
{ [ regexp
-line
"\[ \]\![getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
478 } elseif
{ [ regexp
-line
"\[ \]linux\(\[ \]\|\$\)" $test_line ] } {
480 } elseif
{ [ regexp
-line
"\[ \]\!linux\(\[ \]\|\$\)" $test_line ] } {
482 } elseif
{ [ regexp
-line
"\[ \]\!windows\(\[ \]\|\$\)" $test_line ] } {
484 } elseif
{ [ regexp
-line
"\[ \]windows\(\[ \]\|\$\)" $test_line ] } {
487 if { $matches_pos
== 1 && $matches_neg
== 0 } {
498 if { $lines_ok
== 0 } {
503 set test_line1 $test_line
505 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
506 set lineno
[expr $lineno
+ 1]
507 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
509 clone_output
"$test: could not read line $lineno"
515 if { $lines_ok
== 0 } {
521 # runtest_file_p is already run above
, and the code below can run
522 # runtest_file_p again
, make sure everything
for this test is
523 # performed
if the above runtest_file_p decided this runtest
524 # instance should
execute the test
525 gcc_parallel_test_enable
0
527 set go_compile_args
""
528 set go_execute_args
""
529 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
530 && ! [string match
"*.go*" "$progargs"] } {
531 set go_execute_args $progargs
532 verbose
-log "$test: go_execute_args is $go_execute_args"
533 set index
[string last
" $progargs" $test_line]
534 set test_line
[string replace $test_line $index end
]
535 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
536 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
537 # goroutines.go spawns by default
10000 threads
, which is too much
539 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
540 set go_execute_args
64
541 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
542 # When using low ulimit
-u
limit, use maximum of
543 # a quarter of that
limit and
10000 even when running expensive
544 # tests
, otherwise parallel tests might fail after fork failures.
545 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
546 if { [string is
integer -strict $nproc
] } {
547 set nproc
[expr $nproc
/ 4]
548 if { $nproc
> 10000 } { set nproc
10000 }
549 if { $nproc
< 16 } { set nproc
16 }
550 set go_execute_args $nproc
553 if { "$go_execute_args" != "" } {
554 verbose
-log "$test: go_execute_args is $go_execute_args"
558 if { $test_line
== "// compile"
559 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
560 # This is a vanilla
compile test.
561 set dg
-do-what
-default
"assemble"
562 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
563 } elseif
{ $test_line
== "// run"
564 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
565 # This is a vanilla execution test.
566 go
-torture
-execute $test
567 file
delete core
[glob
-nocomplain core.
*]
568 } elseif
{ $test_line
== "// build" } {
569 # This is a vanilla
compile and link test.
570 set dg
-do-what
-default
"link"
571 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
572 } elseif
{ [string match
"// runoutput*" $test_line] \
573 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
574 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
575 # Run the test to
get a .go
program to run.
576 set go_execute_args
""
577 set hold_runtests $runtests
578 set runtests
"go-test.exp"
580 if { [string match
"// runoutput*" $test_line] } {
582 regsub
"// runoutput\(.*\)" $test_line "\\1" args
584 lappend files
"[file dirname $test]/$f"
587 set dg
-do-what
-default
"link"
588 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
589 set output_file
"./[file rootname [file tail $test]].exe"
590 set base
"[file rootname [file tail $test]]"
592 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
593 fail
"$name execution"
595 pass
"$name execution"
596 file
delete $base
-out.x
597 # Disable optimizations as some of these tests
598 # take a long time to
compile.
599 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
600 go
-torture
-execute "./$base-out.go"
602 file
delete $base
-out.go
604 file
delete $output_file
605 set runtests $hold_runtests
606 } elseif
{ $test_line
== "// cmpout" \
607 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
608 # This is an execution test
for which we need to check the
610 set hold_runtests $runtests
611 set runtests
"go-test.exp"
612 set dg
-do-what
-default
"link"
613 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
614 set output_file
"./[file rootname [file tail $test]].exe"
615 set base
"[file rootname [file tail $test]]"
617 verbose
-log "$output_file >$base.p 2>&1"
618 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
619 verbose
-log $catcherr
620 fail
"$name execution"
621 untested
"$name compare"
623 pass
"$name execution"
624 regsub
"\\.go$" $test ".out" expect
625 filecmp $expect $base.p
"$name compare"
626 file
delete $output_file
630 untested
"$name execution"
631 untested
"$name compare"
633 set runtests $hold_runtests
634 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
636 go
-execute-xfail $test
637 } elseif
{ $test_line
== "// errorcheck" } {
639 } elseif
{ $test_line
== "// errorcheckdir" } {
640 set hold_runtests $runtests
641 set runtests
"go-test.exp"
642 set dir "[file rootname $test].dir"
643 set files
[lsort
[glob
"$dir/*.go"]]
644 set packages
[go
-find
-packages $test $
name $files
]
645 if { [llength $packages
] > 0 } {
646 set dg
-do-what
-default
"assemble"
648 set last
[lindex $packages end
]
649 set packages
[lreplace $packages end end
]
650 foreach p $packages
{
651 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
652 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
654 errchk
[lindex $last
1] "[lrange $last 2 end]"
659 set runtests $hold_runtests
660 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
661 # Run the test to
get a .go
program to error check.
662 set go_execute_args
""
663 set hold_runtests $runtests
664 set runtests
"go-test.exp"
666 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
668 lappend files
"[file dirname $test]/$f"
670 set dg
-do-what
-default
"link"
671 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
672 set output_file
"./[file rootname [file tail $test]].exe"
673 set base
"[file rootname [file tail $test]]"
675 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
676 fail
"$name execution"
678 pass
"$name execution"
679 errchk
"$base-out.go" ""
681 file
delete $base
-out.go
683 file
delete $output_file
684 set runtests $hold_runtests
685 } elseif
{ $test_line
== "// compiledir" } {
686 set hold_runtests $runtests
687 set runtests
"go-test.exp"
688 set dg
-do-what
-default
"assemble"
689 set dir "[file rootname $test].dir"
690 set files
[lsort
[glob
"$dir/*.go"]]
691 set packages
[go
-find
-packages $test $
name $files
]
692 if { [llength $packages
] > 0 } {
694 foreach p $packages
{
695 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O" "-w $DEFAULT_GOCFLAGS"
696 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
702 set runtests $hold_runtests
703 } elseif
{ $test_line
== "// rundir" } {
704 set hold_runtests $runtests
705 set runtests
"go-test.exp"
706 set dir "[file rootname $test].dir"
707 set files
[lsort
[glob
"$dir/*.go"]]
708 set packages
[go
-find
-packages $test $
name $files
]
709 if { [llength $packages
] > 0 } {
710 set dg
-do-what
-default
"assemble"
712 set last
[lindex $packages end
]
713 set packages
[lreplace $packages end end
]
714 foreach p $packages
{
715 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
716 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
718 set dg
-do-what
-default
"link"
719 set go_compile_args
""
720 append go_compile_args
[lrange $last
2 end
]
721 append go_compile_args $del
722 go
-torture
-execute [lindex $last
1]
727 set runtests $hold_runtests
728 } elseif
{ $test_line
== "// rundircmpout" } {
729 set hold_runtests $runtests
730 set runtests
"go-test.exp"
731 set dir "[file rootname $test].dir"
732 set files
[lsort
[glob
"$dir/*.go"]]
733 set packages
[go
-find
-packages $test $
name $files
]
734 if { [llength $packages
] > 0 } {
735 set dg
-do-what
-default
"assemble"
737 set last
[lindex $packages end
]
738 set packages
[lreplace $packages end end
]
739 foreach p $packages
{
740 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
741 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
743 set dg
-do-what
-default
"link"
744 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O" "-w $DEFAULT_GOCFLAGS"
745 set base
"[file rootname [file tail [lindex $last 1]]]"
746 set output_file
"./$base.exe"
747 lappend del $output_file
749 verbose
-log "$output_file >$base.p 2>&1"
750 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
751 verbose
-log $catcherr
752 fail
"$name execution"
753 untested
"$name compare"
755 pass
"$name execution"
756 regsub
"\\.go$" "$test" ".out" expect
757 filecmp $expect $base.p
"$name compare"
765 set runtests $hold_runtests
766 } elseif
{ "$test_line" == ""
767 ||
[string match
"// true*" $test_line]
768 ||
[string match
"// skip*" $test_line] } {
769 # Not a real test
, just ignore.
770 } elseif
{ [string match \
771 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
774 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
777 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
781 } elseif
{ [string match \
782 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
787 set hold_runtests $runtests
788 set runtests
"go-test.exp"
789 set dg
-do-what
-default
"assemble"
790 regsub
"\\.go$" $test ".dir/$name1" file1
791 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
792 regsub
"\\.go$" $test ".dir/$name2" file2
794 file
delete "[file rootname [file tail $file1]].o"
795 set runtests $hold_runtests
796 } elseif
{ [string match \
797 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
799 set hold_runtests $runtests
800 set runtests
"go-test.exp"
801 set dg
-do-what
-default
"assemble"
802 regsub
"\\.go$" $test "1.go" file1
803 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
805 file
delete "[file rootname [file tail $file1]].o"
806 set runtests $hold_runtests
807 } elseif
{ [string match \
808 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
810 set hold_runtests $runtests
811 set runtests
"go-test.exp"
812 set dg
-do-what
-default
"assemble"
813 regsub
"\\.go$" $test ".dir/bug0.go" file1
814 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
815 regsub
"\\.go$" $test ".dir/bug1.go" file2
816 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
817 regsub
"\\.go$" $test ".dir/bug2.go" file3
819 file
delete "[file rootname [file tail $file1]].o"
820 file
delete "[file rootname [file tail $file2]].o"
821 set runtests $hold_runtests
822 } elseif
{ [string match \
823 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
826 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
828 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
829 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
830 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
832 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
836 } elseif
{ [string match \
837 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
841 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
844 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
847 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
848 set name1
"method4a.go"
851 set hold_runtests $runtests
852 set runtests
"go-test.exp"
853 set dg
-do-what
-default
"assemble"
854 regsub
"\\.go$" $test ".dir/$name1" file1
855 if { $name1
== "method4a.go" } {
856 set file1
"[file dirname $test]/method4a.go"
858 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
859 set ofile1
"[file rootname [file tail $file1]].o"
860 regsub
"\\.go$" $test ".dir/$name2" file2
861 if { $name2
== "" } {
864 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
865 set ofile2
"[file rootname [file tail $file2]].o"
866 set dg
-do-what
-default
"link"
867 set output_file
"./[file rootname [file tail $test]].exe"
868 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
869 $output_file
"executable" "$options"]
870 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
871 verbose
-log $comp_output
872 set result
[go_load
"$output_file" "" ""]
873 set status [lindex $result
0]
875 file
delete $ofile1 $ofile2 $output_file
876 set runtests $hold_runtests
877 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
878 set hold_runtests $runtests
879 set runtests
"go-test.exp"
880 set dg
-do-what
-default
"assemble"
881 regsub
"\\.go$" $test ".dir/one.go" file1
882 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
883 set ofile1
"[file rootname [file tail $file1]].o"
884 regsub
"\\.go$" $test ".dir/two.go" file2
885 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
886 set ofile2
"[file rootname [file tail $file2]].o"
887 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
888 set ofile3
"[file rootname [file tail $test]].o"
889 set dg
-do-what
-default
"link"
890 set output_file
"./[file rootname [file tail $test]].exe"
891 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
892 $output_file
"executable" "$options"]
893 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
894 verbose
-log $comp_output
895 set result
[go_load
"$output_file" "" ""]
896 set status [lindex $result
0]
898 file
delete $ofile1 $ofile2 $ofile3 $output_file
899 set runtests $hold_runtests
900 } elseif
{ [string match \
901 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
903 set hold_runtests $runtests
904 set runtests
"go-test.exp"
905 set dg
-do-what
-default
"assemble"
906 regsub
"/\[^/\]*$" $test "/embed0.go" file1
907 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
908 set ofile1
"[file rootname [file tail $file1]].o"
909 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
910 set ofile2
"[file rootname [file tail $test]].o"
911 set output_file
"./[file rootname [file tail $test]].exe"
912 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
913 $output_file
"executable" "$options"]
914 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
915 if [string match
"" $comp_output] {
916 set result
[go_load
"$output_file" "" ""]
917 set status [lindex $result
0]
920 verbose
-log $comp_output
923 file
delete $ofile1 $ofile2 $output_file
924 set runtests $hold_runtests
925 } elseif
{ [string match \
926 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
929 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
932 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
936 } elseif
{ [string match \
937 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
942 set hold_runtests $runtests
943 set runtests
"go-test.exp"
944 set dg
-do-what
-default
"assemble"
945 regsub
"\\.go$" $test ".dir/$name1" file1
946 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
947 set ofile1
"[file rootname [file tail $file1]].o"
948 regsub
"\\.go$" $test ".dir/$name2" file2
949 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
950 set ofile2
"[file rootname [file tail $file2]].o"
951 set dg
-do-what
-default
"link"
952 set output_file
"./[file rootname [file tail $file2]].exe"
953 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
954 $output_file
"executable" "$options"]
955 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
956 if [string match
"" $comp_output] {
957 set result
[go_load
"$output_file" "" ""]
958 set status [lindex $result
0]
961 verbose
-log $comp_output
964 file
delete $ofile1 $ofile2 $output_file
965 set runtests $hold_runtests
966 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
967 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
968 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
969 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
970 && $test_line5
== "// \$L bug2.\$A &&" \
971 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
972 set hold_runtests $runtests
973 set runtests
"go-test.exp"
974 set dg
-do-what
-default
"assemble"
975 regsub
"\\.go$" $test ".dir/bug0.go" file0
976 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
977 set ofile0
"[file rootname [file tail $file0]].o"
978 regsub
"\\.go$" $test ".dir/bug1.go" file1
979 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
980 set ofile1
"[file rootname [file tail $file1]].o"
981 regsub
"\\.go$" $test ".dir/bug2.go" file2
982 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
983 set ofile2
"[file rootname [file tail $file2]].o"
984 regsub
"\\.go$" $test ".dir/bug3.go" file3
986 set output_file
"./[file rootname [file tail $test]].exe"
987 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
988 $output_file
"executable" "$options"]
989 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
990 if [string match
"" $comp_output] {
991 set result
[go_load
"$output_file" "" ""]
992 set status [lindex $result
0]
995 verbose
-log $comp_output
998 file
delete $ofile0 $ofile1 $ofile2 $output_file
999 set runtests $hold_runtests
1000 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
1001 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
1002 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
1003 set name1
"import2.go"
1004 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
1005 set name1
"recursive1.go"
1007 set hold_runtests $runtests
1008 set runtests
"go-test.exp"
1009 set dg
-do-what
-default
"assemble"
1010 regsub
"/\[^/\]*$" $test "/${name1}" file1
1011 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1012 set ofile1
"[file rootname [file tail $file1]].o"
1013 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1015 set runtests $hold_runtests
1016 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1017 set hold_runtests $runtests
1018 set runtests
"go-test.exp"
1019 set dg
-do-what
-default
"assemble"
1020 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
1021 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1022 set ofile1
"[file rootname [file tail $file1]].o"
1023 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1024 set ofile2
"[file rootname [file tail $test]].o"
1025 set output_file
"./[file rootname [file tail $test]].exe"
1026 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
1027 $output_file
"executable" "$options"]
1028 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1029 if [string match
"" $comp_output] {
1030 set result
[go_load
"$output_file" "" ""]
1031 set status [lindex $result
0]
1034 verbose
-log $comp_output
1037 file
delete $ofile1 $ofile2 $output_file
1038 set runtests $hold_runtests
1039 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1040 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1041 set output_file
"./[file rootname [file tail $test]].o"
1042 set comp_output
[go_target_compile
"$test $test2" \
1043 $output_file
"executable" "$options"]
1044 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1045 if [string match
"" $comp_output] {
1046 set result
[go_load
"$output_file" "" ""]
1047 set status [lindex $result
0]
1050 verbose
-log $comp_output
1053 file
delete $output_file
1054 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1055 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1056 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1057 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1058 set go_execute_args
""
1059 set hold_runtests $runtests
1060 set runtests
"go-test.exp"
1061 set dg
-do-what
-default
"link"
1062 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1063 set output_file
"./[file rootname [file tail $test]].exe"
1065 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1066 fail
"$name execution 0"
1068 pass
"$name execution 0"
1070 # Disable optimizations as this test takes a long time
1072 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1073 go
-torture
-execute "./tmp.go"
1075 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1076 fail
"$name execution 1"
1078 pass
"$name execution 1"
1081 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1082 fail
"$name execution 2"
1084 pass
"$name execution 2"
1089 file
delete $output_file
1090 set runtests $hold_runtests
1091 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1092 && $test_line2
== "// errchk \$G -e tmp.go" } {
1093 set go_execute_args
""
1094 set hold_runtests $runtests
1095 set runtests
"go-test.exp"
1096 set dg
-do-what
-default
"link"
1097 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1098 set output_file
"./[file rootname [file tail $test]].exe"
1100 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1101 fail
"$name execution"
1103 pass
"$name execution"
1108 file
delete $output_file
1109 set runtests $hold_runtests
1110 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1111 regsub
"\\.go$" $test ".dir/a.go" file1
1112 regsub
"\\.go$" $test ".dir/b.go" file2
1113 errchk
"$file1" "$file2"
1114 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1115 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1116 && $test_line3
== "// run" } {
1117 set hold_runtests $runtests
1118 set runtests
"go-test.exp"
1119 set dg
-do-what
-default
"assemble"
1120 regsub
"\\.go$" $test ".dir/pkg.go" file1
1121 dg
-test
-keep
-output $file1
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1122 set ofile1
"[file rootname [file tail $file1]].o"
1123 file
rename -force $ofile1 slow.o
1124 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1125 file
rename -force $ofile1 fast.o
1126 set ofile2
"[file rootname [file tail $test]].o"
1127 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1128 set output_file
"./[file rootname [file tail $test]].exe"
1129 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1130 $output_file
"executable" "$options"]
1131 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1132 if [string match
"" $comp_output] {
1133 set result
[go_load
"$output_file" "" ""]
1134 set status [lindex $result
0]
1137 verbose
-log $comp_output
1140 file
delete slow.o fast.o $ofile2 $output_file
1141 set runtests $hold_runtests
1142 } elseif
{ [string match \
1143 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1145 set hold_runtests $runtests
1146 set runtests
"go-test.exp"
1147 set dg
-do-what
-default
"assemble"
1148 regsub
"\\.go$" $test ".dir/pkg.go" file1
1149 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1150 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1151 file
delete "[file rootname [file tail $file1]].o"
1152 set runtests $hold_runtests
1153 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1155 set hold_runtests $runtests
1156 set runtests
"go-test.exp"
1157 set dg
-do-what
-default
"assemble"
1158 regsub
"\\.go$" $test ".dir/one.go" file1
1159 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1160 set ofile1
"[file rootname [file tail $file1]].o"
1161 regsub
"\\.go$" $test ".dir/two.go" file2
1162 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1164 set runtests $hold_runtests
1165 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1166 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1167 # These tests
import the same package under two different
1168 # names
, which gccgo does not support.
1169 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1170 # This tests whether initializers are written out
1171 # statically. gccgo does not provide a way to test that
,
1172 # as an initializer will be generated
for any code which
1173 # has global variables which need to be registered as GC
1175 } elseif
{ $test_line
== "// errorcheck -0 -m"
1176 || $test_line
== "// errorcheck -0 -m -l" } {
1177 # This tests debug output of the gc compiler
, which is
1178 # meaningless
for gccgo.
1179 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1180 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1181 # This tests specific handling of the gc compiler
on types
1182 # that are too large. It is target specific in a way I
1183 # haven
't bothered to check for here.
1184 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1185 # This tests the gc ld -X option, which gccgo does not
1187 } 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"
1188 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1189 # This tests the gc -u option, which gccgo does not
1191 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1192 || $test_line == "// errorcheck -0 -d=nil" } {
1193 # This tests gc nil pointer checks using -d=nil, which
1194 # gccgo does not support.
1196 clone_output "$name: unrecognized test line: $test_line"
1200 set go_compile_args ""
1201 set go_execute_args ""
1202 set TORTURE_OPTIONS [list { -O2 -g }]
1203 gcc_parallel_test_enable 1
1206 set dg-do-what-default ${saved-dg-do-what-default}
1207 set TORTURE_OPTIONS $saved_torture_options