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] {
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
222 set goarch "mips64p32"
223 } elseif [check_no_compiler_messages mipsn64 assembly {
224 #if _MIPS_SIM != _ABI64
230 perror "$target_triplet: unrecognized MIPS ABI"
234 if [istarget "mips*el-*-*"] {
239 if [check_effective_target_ilp32] {
242 if [istarget "powerpc64le-*-*"] {
253 if [check_effective_target_ilp32] {
260 if [check_effective_target_ilp32] {
267 perror "$target_triplet: unhandled architecture"
271 verbose -log "Setting GOARCH=$goarch" 1
272 setenv GOARCH $goarch
275 # Take a list of files and return a lists of lists, where each list is
276 # the set of files in the same package.
277 proc go-find-packages { test name files } {
282 if { [gets $fd line] < 0 } {
284 clone_output "$test: could not read $f"
289 if { [regexp "^package (\\w+)" $line match package] } {
290 set len [llength $packages]
291 for { set i 0 } { $i < $len } { incr i } {
292 set p [lindex $packages $i]
293 if { [lindex $p 0] == $package } {
300 lappend packages [list $package $f]
311 proc go-gc-tests { } {
314 global GCC_UNDER_TEST
316 global TORTURE_OPTIONS
317 global dg-do-what-default
318 global go_compile_args
319 global go_execute_args
320 global target_triplet
322 # If a testcase doesn't have special options
, use these.
323 global DEFAULT_GOCFLAGS
324 if ![info exists DEFAULT_GOCFLAGS
] {
325 set DEFAULT_GOCFLAGS
" -pedantic-errors"
329 lappend options
"additional_flags=$DEFAULT_GOCFLAGS"
331 #
Set GOARCH
for tests that need it.
334 # Running all the torture options takes too long and
, since the
335 # frontend ignores the standard options
, it doesn
't significantly
337 set saved_torture_options $TORTURE_OPTIONS
338 set TORTURE_OPTIONS [list { -O2 -g }]
340 set saved-dg-do-what-default ${dg-do-what-default}
344 set tests [lsort [find $srcdir/$subdir *.go]]
345 foreach test $tests {
346 if ![runtest_file_p $runtests $test] {
350 # Skip the files in bench; they are not tests.
351 if [string match "*go.test/test/bench/*" $test] {
355 # Skip the files in stress; they are not tests.
356 if [string match "*go.test/test/stress/*" $test] {
360 # Skip the files in safe; gccgo does not support safe mode.
361 if [string match "*go.test/test/safe/*" $test] {
365 # Skip files in sub-subdirectories: they are components of
367 if [string match "*go.test/test/*/*/*" $test] {
371 # Skip files in *.dir subdirectories: they are components of
373 if [string match "*go.test/test/*.dir/*" $test] {
377 set name [dg-trim-dirname $srcdir $test]
379 # Skip certain tests if target is RTEMS OS.
380 if [istarget "*-*-rtems*"] {
381 if { [string match "*go.test/test/args.go" $test] \
382 || [string match "*go.test/test/env.go" $test] } {
383 untested "$name: uses the command-line or environment variables"
387 if { [string match "*go.test/test/stack.go" $test] \
388 || [string match "*go.test/test/peano.go" $test] \
389 || [string match "*go.test/test/chan/goroutines.go" $test] } {
390 untested "$name: has very high memory requirement"
395 # Handle certain tests in a target-dependant way.
396 if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] || [istarget "s390*-*-*"] } {
397 if { [string match "*go.test/test/nilptr.go" $test] } {
403 if [check_effective_target_pie_enabled] {
408 if { [file tail $test] == "init1.go" } {
409 # This tests whether GC runs during init, which for gccgo
410 # it currently does not.
415 if { [file tail $test] == "closure.go" } {
416 # This tests whether function closures do any memory
417 # allocation, which for gccgo they currently do.
422 if { ( [file tail $test] == "select2.go" \
423 || [file tail $test] == "stack.go" \
424 || [file tail $test] == "peano.go" \
425 || [file tail $test] == "nilptr2.go" ) \
426 && ! [check_effective_target_split_stack] } {
427 # These tests fails on targets without split stack.
432 if [string match "*go.test/test/rotate\[0123\].go" $test] {
433 # These tests produces a temporary file that takes too long
434 # to compile--5 minutes on my laptop without optimization.
435 # When compiling without optimization it tests nothing
436 # useful, since the point of the test is to see whether
437 # the compiler generates rotate instructions.
442 if { [file tail $test] == "bug347.go" \
443 || [file tail $test] == "bug348.go" } {
444 # These tests don't work
if the functions are inlined.
445 set TORTURE_OPTIONS
[list
{ -O0
-g
}]
448 set fd
[open $test r
]
453 if { [gets $fd test_line
] < 0 } {
455 clone_output
"$test: could not read first line"
461 if { [ string match
"*nacl*exit 0*" $test_line ] \
462 ||
[ string match
"*exit 0*nacl*" $test_line ] \
463 ||
[ string match
"*Android*exit 0*" $test_line ] \
464 ||
[ string match
"*exit 0*Android*" $test_line ] \
465 ||
[ string match
"*\"\$GOOS\" == windows*" $test_line ] } {
469 if { [ string match
"// +build *" $test_line ] } {
472 if { [ regexp
-line
"\[ \][getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
474 } elseif
{ [ regexp
-line
"\[ \]\![getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
476 } elseif
{ [ regexp
-line
"\[ \]linux\(\[ \]\|\$\)" $test_line ] } {
478 } elseif
{ [ regexp
-line
"\[ \]\!linux\(\[ \]\|\$\)" $test_line ] } {
480 } elseif
{ [ regexp
-line
"\[ \]\!windows\(\[ \]\|\$\)" $test_line ] } {
482 } elseif
{ [ regexp
-line
"\[ \]windows\(\[ \]\|\$\)" $test_line ] } {
485 if { $matches_pos
== 1 && $matches_neg
== 0 } {
496 if { $lines_ok
== 0 } {
501 set test_line1 $test_line
503 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
504 set lineno
[expr $lineno
+ 1]
505 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
507 clone_output
"$test: could not read line $lineno"
513 if { $lines_ok
== 0 } {
519 # runtest_file_p is already run above
, and the code below can run
520 # runtest_file_p again
, make sure everything
for this test is
521 # performed
if the above runtest_file_p decided this runtest
522 # instance should
execute the test
523 gcc_parallel_test_enable
0
525 set go_compile_args
""
526 set go_execute_args
""
527 if { [regexp
"// run (\[^|&>2\].*)\$" $test_line match progargs] \
528 && ! [string match
"*.go*" "$progargs"] } {
529 set go_execute_args $progargs
530 verbose
-log "$test: go_execute_args is $go_execute_args"
531 set index
[string last
" $progargs" $test_line]
532 set test_line
[string replace $test_line $index end
]
533 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
534 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
535 # goroutines.go spawns by default
10000 threads
, which is too much
537 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
538 set go_execute_args
64
539 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
540 # When using low ulimit
-u
limit, use maximum of
541 # a quarter of that
limit and
10000 even when running expensive
542 # tests
, otherwise parallel tests might fail after fork failures.
543 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
544 if { [string is
integer -strict $nproc
] } {
545 set nproc
[expr $nproc
/ 4]
546 if { $nproc
> 10000 } { set nproc
10000 }
547 if { $nproc
< 16 } { set nproc
16 }
548 set go_execute_args $nproc
551 if { "$go_execute_args" != "" } {
552 verbose
-log "$test: go_execute_args is $go_execute_args"
556 if { $test_line
== "// compile"
557 || $test_line
== "// echo bug395 is broken # takes 90+ seconds to break" } {
558 # This is a vanilla
compile test.
559 set dg
-do-what
-default
"assemble"
560 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
561 } elseif
{ $test_line
== "// run"
562 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
563 # This is a vanilla execution test.
564 go
-torture
-execute $test
565 file
delete core
[glob
-nocomplain core.
*]
566 } elseif
{ $test_line
== "// build" } {
567 # This is a vanilla
compile and link test.
568 set dg
-do-what
-default
"link"
569 go
-dg
-runtest $test
"" "-w $DEFAULT_GOCFLAGS"
570 } elseif
{ [string match
"// runoutput*" $test_line] \
571 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
572 && $test_line2
== "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
573 # Run the test to
get a .go
program to run.
574 set go_execute_args
""
575 set hold_runtests $runtests
576 set runtests
"go-test.exp"
578 if { [string match
"// runoutput*" $test_line] } {
580 regsub
"// runoutput\(.*\)" $test_line "\\1" args
582 lappend files
"[file dirname $test]/$f"
585 set dg
-do-what
-default
"link"
586 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
587 set output_file
"./[file rootname [file tail $test]].exe"
588 set base
"[file rootname [file tail $test]]"
590 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
591 fail
"$name execution"
593 pass
"$name execution"
594 file
delete $base
-out.x
595 # Disable optimizations as some of these tests
596 # take a long time to
compile.
597 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
598 go
-torture
-execute "./$base-out.go"
600 file
delete $base
-out.go
602 file
delete $output_file
603 set runtests $hold_runtests
604 } elseif
{ $test_line
== "// cmpout" \
605 || $test_line
== "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
606 # This is an execution test
for which we need to check the
608 set hold_runtests $runtests
609 set runtests
"go-test.exp"
610 set dg
-do-what
-default
"link"
611 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
612 set output_file
"./[file rootname [file tail $test]].exe"
613 set base
"[file rootname [file tail $test]]"
615 verbose
-log "$output_file >$base.p 2>&1"
616 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
617 verbose
-log $catcherr
618 fail
"$name execution"
619 untested
"$name compare"
621 pass
"$name execution"
622 regsub
"\\.go$" $test ".out" expect
623 filecmp $expect $base.p
"$name compare"
624 file
delete $output_file
628 untested
"$name execution"
629 untested
"$name compare"
631 set runtests $hold_runtests
632 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
634 go
-execute-xfail $test
635 } elseif
{ $test_line
== "// errorcheck" } {
637 } elseif
{ $test_line
== "// errorcheckdir" } {
638 set hold_runtests $runtests
639 set runtests
"go-test.exp"
640 set dir "[file rootname $test].dir"
641 set files
[lsort
[glob
"$dir/*.go"]]
642 set packages
[go
-find
-packages $test $
name $files
]
643 if { [llength $packages
] > 0 } {
644 set dg
-do-what
-default
"assemble"
646 set last
[lindex $packages end
]
647 set packages
[lreplace $packages end end
]
648 foreach p $packages
{
649 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
650 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
652 errchk
[lindex $last
1] "[lrange $last 2 end]"
657 set runtests $hold_runtests
658 } elseif
{ [string match
"// errorcheckoutput*" $test_line] } {
659 # Run the test to
get a .go
program to error check.
660 set go_execute_args
""
661 set hold_runtests $runtests
662 set runtests
"go-test.exp"
664 regsub
"// errorcheckoutput\(.*\)" $test_line "\\1" args
666 lappend files
"[file dirname $test]/$f"
668 set dg
-do-what
-default
"link"
669 dg
-test
-keep
-output $test
"-O" "$files -w $DEFAULT_GOCFLAGS"
670 set output_file
"./[file rootname [file tail $test]].exe"
671 set base
"[file rootname [file tail $test]]"
673 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
674 fail
"$name execution"
676 pass
"$name execution"
677 errchk
"$base-out.go" ""
679 file
delete $base
-out.go
681 file
delete $output_file
682 set runtests $hold_runtests
683 } elseif
{ $test_line
== "// compiledir" } {
684 set hold_runtests $runtests
685 set runtests
"go-test.exp"
686 set dg
-do-what
-default
"assemble"
687 set dir "[file rootname $test].dir"
688 set files
[lsort
[glob
"$dir/*.go"]]
689 set packages
[go
-find
-packages $test $
name $files
]
690 if { [llength $packages
] > 0 } {
692 foreach p $packages
{
693 dg
-test
-keep
-output
[lindex $p
1] "[lrange $p 2 end] -O" "-w $DEFAULT_GOCFLAGS"
694 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
700 set runtests $hold_runtests
701 } elseif
{ $test_line
== "// rundir" } {
702 set hold_runtests $runtests
703 set runtests
"go-test.exp"
704 set dir "[file rootname $test].dir"
705 set files
[lsort
[glob
"$dir/*.go"]]
706 set packages
[go
-find
-packages $test $
name $files
]
707 if { [llength $packages
] > 0 } {
708 set dg
-do-what
-default
"assemble"
710 set last
[lindex $packages end
]
711 set packages
[lreplace $packages end end
]
712 foreach p $packages
{
713 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
714 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
716 set dg
-do-what
-default
"link"
717 set go_compile_args
""
718 append go_compile_args
[lrange $last
2 end
]
719 append go_compile_args $del
720 go
-torture
-execute [lindex $last
1]
725 set runtests $hold_runtests
726 } elseif
{ $test_line
== "// rundircmpout" } {
727 set hold_runtests $runtests
728 set runtests
"go-test.exp"
729 set dir "[file rootname $test].dir"
730 set files
[lsort
[glob
"$dir/*.go"]]
731 set packages
[go
-find
-packages $test $
name $files
]
732 if { [llength $packages
] > 0 } {
733 set dg
-do-what
-default
"assemble"
735 set last
[lindex $packages end
]
736 set packages
[lreplace $packages end end
]
737 foreach p $packages
{
738 dg
-test
-keep
-output
[lrange $p
1 end
] "-O" "-w $DEFAULT_GOCFLAGS"
739 lappend del
"[file rootname [file tail [lindex $p 1]]].o"
741 set dg
-do-what
-default
"link"
742 dg
-test
-keep
-output
[lrange $last
1 end
] "$del -O" "-w $DEFAULT_GOCFLAGS"
743 set base
"[file rootname [file tail [lindex $last 1]]]"
744 set output_file
"./$base.exe"
745 lappend del $output_file
747 verbose
-log "$output_file >$base.p 2>&1"
748 if { [catch
"exec $output_file 2>$base.p" catcherr] != 0 } {
749 verbose
-log $catcherr
750 fail
"$name execution"
751 untested
"$name compare"
753 pass
"$name execution"
754 regsub
"\\.go$" "$test" ".out" expect
755 filecmp $expect $base.p
"$name compare"
763 set runtests $hold_runtests
764 } elseif
{ "$test_line" == ""
765 ||
[string match
"// true*" $test_line]
766 ||
[string match
"// skip*" $test_line] } {
767 # Not a real test
, just ignore.
768 } elseif
{ [string match \
769 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
772 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
775 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
779 } elseif
{ [string match \
780 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
785 set hold_runtests $runtests
786 set runtests
"go-test.exp"
787 set dg
-do-what
-default
"assemble"
788 regsub
"\\.go$" $test ".dir/$name1" file1
789 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
790 regsub
"\\.go$" $test ".dir/$name2" file2
792 file
delete "[file rootname [file tail $file1]].o"
793 set runtests $hold_runtests
794 } elseif
{ [string match \
795 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
797 set hold_runtests $runtests
798 set runtests
"go-test.exp"
799 set dg
-do-what
-default
"assemble"
800 regsub
"\\.go$" $test "1.go" file1
801 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
803 file
delete "[file rootname [file tail $file1]].o"
804 set runtests $hold_runtests
805 } elseif
{ [string match \
806 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
808 set hold_runtests $runtests
809 set runtests
"go-test.exp"
810 set dg
-do-what
-default
"assemble"
811 regsub
"\\.go$" $test ".dir/bug0.go" file1
812 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
813 regsub
"\\.go$" $test ".dir/bug1.go" file2
814 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
815 regsub
"\\.go$" $test ".dir/bug2.go" file3
817 file
delete "[file rootname [file tail $file1]].o"
818 file
delete "[file rootname [file tail $file2]].o"
819 set runtests $hold_runtests
820 } elseif
{ [string match \
821 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
824 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
826 || $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
827 || $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
828 || $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
830 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
834 } elseif
{ [string match \
835 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
839 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
842 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
845 } elseif
{ $test_line
== "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
846 set name1
"method4a.go"
849 set hold_runtests $runtests
850 set runtests
"go-test.exp"
851 set dg
-do-what
-default
"assemble"
852 regsub
"\\.go$" $test ".dir/$name1" file1
853 if { $name1
== "method4a.go" } {
854 set file1
"[file dirname $test]/method4a.go"
856 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
857 set ofile1
"[file rootname [file tail $file1]].o"
858 regsub
"\\.go$" $test ".dir/$name2" file2
859 if { $name2
== "" } {
862 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
863 set ofile2
"[file rootname [file tail $file2]].o"
864 set dg
-do-what
-default
"link"
865 set output_file
"./[file rootname [file tail $test]].exe"
866 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
867 $output_file
"executable" "$options"]
868 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
869 verbose
-log $comp_output
870 set result
[go_load
"$output_file" "" ""]
871 set status [lindex $result
0]
873 file
delete $ofile1 $ofile2 $output_file
874 set runtests $hold_runtests
875 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
876 set hold_runtests $runtests
877 set runtests
"go-test.exp"
878 set dg
-do-what
-default
"assemble"
879 regsub
"\\.go$" $test ".dir/one.go" file1
880 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
881 set ofile1
"[file rootname [file tail $file1]].o"
882 regsub
"\\.go$" $test ".dir/two.go" file2
883 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
884 set ofile2
"[file rootname [file tail $file2]].o"
885 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
886 set ofile3
"[file rootname [file tail $test]].o"
887 set dg
-do-what
-default
"link"
888 set output_file
"./[file rootname [file tail $test]].exe"
889 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
890 $output_file
"executable" "$options"]
891 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
892 verbose
-log $comp_output
893 set result
[go_load
"$output_file" "" ""]
894 set status [lindex $result
0]
896 file
delete $ofile1 $ofile2 $ofile3 $output_file
897 set runtests $hold_runtests
898 } elseif
{ [string match \
899 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
901 set hold_runtests $runtests
902 set runtests
"go-test.exp"
903 set dg
-do-what
-default
"assemble"
904 regsub
"/\[^/\]*$" $test "/embed0.go" file1
905 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
906 set ofile1
"[file rootname [file tail $file1]].o"
907 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
908 set ofile2
"[file rootname [file tail $test]].o"
909 set output_file
"./[file rootname [file tail $test]].exe"
910 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
911 $output_file
"executable" "$options"]
912 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
913 if [string match
"" $comp_output] {
914 set result
[go_load
"$output_file" "" ""]
915 set status [lindex $result
0]
918 verbose
-log $comp_output
921 file
delete $ofile1 $ofile2 $output_file
922 set runtests $hold_runtests
923 } elseif
{ [string match \
924 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
927 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
930 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
934 } elseif
{ [string match \
935 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
940 set hold_runtests $runtests
941 set runtests
"go-test.exp"
942 set dg
-do-what
-default
"assemble"
943 regsub
"\\.go$" $test ".dir/$name1" file1
944 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
945 set ofile1
"[file rootname [file tail $file1]].o"
946 regsub
"\\.go$" $test ".dir/$name2" file2
947 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
948 set ofile2
"[file rootname [file tail $file2]].o"
949 set dg
-do-what
-default
"link"
950 set output_file
"./[file rootname [file tail $file2]].exe"
951 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
952 $output_file
"executable" "$options"]
953 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
954 if [string match
"" $comp_output] {
955 set result
[go_load
"$output_file" "" ""]
956 set status [lindex $result
0]
959 verbose
-log $comp_output
962 file
delete $ofile1 $ofile2 $output_file
963 set runtests $hold_runtests
964 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
965 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
966 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
967 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
968 && $test_line5
== "// \$L bug2.\$A &&" \
969 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
970 set hold_runtests $runtests
971 set runtests
"go-test.exp"
972 set dg
-do-what
-default
"assemble"
973 regsub
"\\.go$" $test ".dir/bug0.go" file0
974 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
975 set ofile0
"[file rootname [file tail $file0]].o"
976 regsub
"\\.go$" $test ".dir/bug1.go" file1
977 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
978 set ofile1
"[file rootname [file tail $file1]].o"
979 regsub
"\\.go$" $test ".dir/bug2.go" file2
980 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
981 set ofile2
"[file rootname [file tail $file2]].o"
982 regsub
"\\.go$" $test ".dir/bug3.go" file3
984 set output_file
"./[file rootname [file tail $test]].exe"
985 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
986 $output_file
"executable" "$options"]
987 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
988 if [string match
"" $comp_output] {
989 set result
[go_load
"$output_file" "" ""]
990 set status [lindex $result
0]
993 verbose
-log $comp_output
996 file
delete $ofile0 $ofile1 $ofile2 $output_file
997 set runtests $hold_runtests
998 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
999 || $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
1000 if { $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
1001 set name1
"import2.go"
1002 } elseif
{ $test_line
== "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
1003 set name1
"recursive1.go"
1005 set hold_runtests $runtests
1006 set runtests
"go-test.exp"
1007 set dg
-do-what
-default
"assemble"
1008 regsub
"/\[^/\]*$" $test "/${name1}" file1
1009 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1010 set ofile1
"[file rootname [file tail $file1]].o"
1011 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1013 set runtests $hold_runtests
1014 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1015 set hold_runtests $runtests
1016 set runtests
"go-test.exp"
1017 set dg
-do-what
-default
"assemble"
1018 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
1019 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1020 set ofile1
"[file rootname [file tail $file1]].o"
1021 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1022 set ofile2
"[file rootname [file tail $test]].o"
1023 set output_file
"./[file rootname [file tail $test]].exe"
1024 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
1025 $output_file
"executable" "$options"]
1026 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1027 if [string match
"" $comp_output] {
1028 set result
[go_load
"$output_file" "" ""]
1029 set status [lindex $result
0]
1032 verbose
-log $comp_output
1035 file
delete $ofile1 $ofile2 $output_file
1036 set runtests $hold_runtests
1037 } elseif
{ $test_line
== "// run cmplxdivide1.go" } {
1038 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
1039 set output_file
"./[file rootname [file tail $test]].o"
1040 set comp_output
[go_target_compile
"$test $test2" \
1041 $output_file
"executable" "$options"]
1042 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1043 if [string match
"" $comp_output] {
1044 set result
[go_load
"$output_file" "" ""]
1045 set status [lindex $result
0]
1048 verbose
-log $comp_output
1051 file
delete $output_file
1052 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
1053 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
1054 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
1055 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
1056 set go_execute_args
""
1057 set hold_runtests $runtests
1058 set runtests
"go-test.exp"
1059 set dg
-do-what
-default
"link"
1060 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1061 set output_file
"./[file rootname [file tail $test]].exe"
1063 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
1064 fail
"$name execution 0"
1066 pass
"$name execution 0"
1068 # Disable optimizations as this test takes a long time
1070 set TORTURE_OPTIONS
[list
{ -O0
-g
-fno
-var
-tracking
-assignments
}]
1071 go
-torture
-execute "./tmp.go"
1073 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
1074 fail
"$name execution 1"
1076 pass
"$name execution 1"
1079 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
1080 fail
"$name execution 2"
1082 pass
"$name execution 2"
1087 file
delete $output_file
1088 set runtests $hold_runtests
1089 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
1090 && $test_line2
== "// errchk \$G -e tmp.go" } {
1091 set go_execute_args
""
1092 set hold_runtests $runtests
1093 set runtests
"go-test.exp"
1094 set dg
-do-what
-default
"link"
1095 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1096 set output_file
"./[file rootname [file tail $test]].exe"
1098 if { [catch
"exec $output_file >tmp.go"] != 0 } {
1099 fail
"$name execution"
1101 pass
"$name execution"
1106 file
delete $output_file
1107 set runtests $hold_runtests
1108 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1109 regsub
"\\.go$" $test ".dir/a.go" file1
1110 regsub
"\\.go$" $test ".dir/b.go" file2
1111 errchk
"$file1" "$file2"
1112 } elseif
{ $test_line
== "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1113 && $test_line2
== "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1114 && $test_line3
== "// run" } {
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
"" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1120 set ofile1
"[file rootname [file tail $file1]].o"
1121 file
rename -force $ofile1 slow.o
1122 dg
-test
-keep
-output $file1
"-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1123 file
rename -force $ofile1 fast.o
1124 set ofile2
"[file rootname [file tail $test]].o"
1125 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
1126 set output_file
"./[file rootname [file tail $test]].exe"
1127 set comp_output
[go_target_compile
"$ofile2 slow.o fast.o" \
1128 $output_file
"executable" "$options"]
1129 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
1130 if [string match
"" $comp_output] {
1131 set result
[go_load
"$output_file" "" ""]
1132 set status [lindex $result
0]
1135 verbose
-log $comp_output
1138 file
delete slow.o fast.o $ofile2 $output_file
1139 set runtests $hold_runtests
1140 } elseif
{ [string match \
1141 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1143 set hold_runtests $runtests
1144 set runtests
"go-test.exp"
1145 set dg
-do-what
-default
"assemble"
1146 regsub
"\\.go$" $test ".dir/pkg.go" file1
1147 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1148 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
1149 file
delete "[file rootname [file tail $file1]].o"
1150 set runtests $hold_runtests
1151 } elseif
{ [string match
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
1153 set hold_runtests $runtests
1154 set runtests
"go-test.exp"
1155 set dg
-do-what
-default
"assemble"
1156 regsub
"\\.go$" $test ".dir/one.go" file1
1157 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
1158 set ofile1
"[file rootname [file tail $file1]].o"
1159 regsub
"\\.go$" $test ".dir/two.go" file2
1160 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
1162 set runtests $hold_runtests
1163 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1164 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1165 # These tests
import the same package under two different
1166 # names
, which gccgo does not support.
1167 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1168 # This tests whether initializers are written out
1169 # statically. gccgo does not provide a way to test that
,
1170 # as an initializer will be generated
for any code which
1171 # has global variables which need to be registered as GC
1173 } elseif
{ $test_line
== "// errorcheck -0 -m"
1174 || $test_line
== "// errorcheck -0 -m -l" } {
1175 # This tests debug output of the gc compiler
, which is
1176 # meaningless
for gccgo.
1177 } elseif
{ $test_line
== "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
1178 || $test_line
== "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
1179 # This tests specific handling of the gc compiler
on types
1180 # that are too large. It is target specific in a way I
1181 # haven
't bothered to check for here.
1182 } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
1183 # This tests the gc ld -X option, which gccgo does not
1185 } 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"
1186 || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
1187 # This tests the gc -u option, which gccgo does not
1189 } elseif { $test_line == "// errorcheck -0 -N -d=nil" \
1190 || $test_line == "// errorcheck -0 -d=nil" } {
1191 # This tests gc nil pointer checks using -d=nil, which
1192 # gccgo does not support.
1194 clone_output "$name: unrecognized test line: $test_line"
1198 set go_compile_args ""
1199 set go_execute_args ""
1200 set TORTURE_OPTIONS [list { -O2 -g }]
1201 gcc_parallel_test_enable 1
1204 set dg-do-what-default ${saved-dg-do-what-default}
1205 set TORTURE_OPTIONS $saved_torture_options