1 # Copyright
(C
) 2009, 2010, 2011, 2012 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
:
29 #
// $G $D
/$F.go
&& $L $F.$A
&& .
/$A.out
30 #
// $G $D
/$F.go
&& $L $F.$A || echo BUG
: known to fail incorrectly
31 #
// $G $D
/$F.go
&& echo BUG
: compilation succeeds incorrectly
32 #
// $G $D
/$F.go || echo BUG
: compilation should succeed
35 load_lib go
-torture.exp
38 proc errchk
{ test opts
} {
39 global dg
-do-what
-default
40 global DEFAULT_GOCFLAGS
43 set saved
-dg
-do-what
-default $
{dg
-do-what
-default
}
44 set dg
-do-what
-default
compile
45 set filename
[file tail $test
]
46 if { "$filename" == "$test" } {
47 set filename
"errchk-$filename"
49 set fdin
[open $test r
]
50 fconfigure $fdin
-encoding binary
51 set fdout
[open $filename w
]
52 fconfigure $fdout
-encoding binary
53 while { [gets $fdin copy_line
] >= 0 } {
54 if [string match
"*////*" $copy_line] {
55 puts $fdout $copy_line
58 regsub
"// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
59 if [string match
"*dg-error*.\**" $out_line] {
60 # I worked out the right number of backslashes by
61 # experimentation
, not analysis.
62 regsub
-all
"\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
64 if [string match
"*dg-error*\\\[?\\\]*" $out_line] {
65 set index
[string first
"dg-error" $out_line]
66 regsub
-all
"\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
68 if [string match
"*dg-error*\{*" $out_line] {
69 set index
[string first
"dg-error" $out_line]
70 regsub
-start $index
-all
"\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
72 if [string match
"*dg-error*\}*\}" $out_line] {
73 set index
[string first
"dg-error" $out_line]
74 regsub
-start $index
-all
"\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
76 if [string match
"*dg-error*\(*" $out_line] {
77 set index
[string first
"dg-error" $out_line]
78 regsub
-start $index
-all
"\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
80 if [string match
"*dg-error*\)*\}" $out_line] {
81 set index
[string first
"dg-error" $out_line]
82 regsub
-start $index
-all
"\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
84 # Special case
for bug332
, in which the error message wants to
85 # match the file
name, which is not what dg
-error expects.
86 if [string match
"*dg-error*bug332*" $out_line] {
87 set index
[string first
"dg-error" $out_line]
88 regsub
-start $index
"bug332" $out_line "undefined type" out_line
95 set hold_runtests $runtests
96 set runtests
"go-test.exp"
97 go
-dg
-runtest $filename
"-fno-show-column $DEFAULT_GOCFLAGS $opts"
98 set runtests $hold_runtests
100 file
delete $filename
101 set dg
-do-what
-default $
{saved
-dg
-do-what
-default
}
104 # This is an execution test which should fail.
105 proc go
-execute-xfail
{ test
} {
106 global DEFAULT_GOCFLAGS
109 set filename
[file tail $test
]
110 set fdin
[open $test r
]
111 set fdout
[open $filename w
]
112 puts $fdout
"// { dg-do run { xfail *-*-* } }"
113 while { [gets $fdin copy_line
] >= 0 } {
114 puts $fdout $copy_line
119 set hold_runtests $runtests
120 set runtests
"go-test.exp"
121 go
-dg
-runtest $filename
"-w $DEFAULT_GOCFLAGS"
122 set runtests $hold_runtests
124 file
delete $filename
127 # N.B. Keep in sync with libgo
/configure.ac.
128 proc go
-set-goarch
{ } {
129 global target_triplet
131 switch -glob $target_triplet
{
143 if [check_effective_target_ia32
] {
150 if [check_no_compiler_messages mipso32 assembly
{
151 #
if _MIPS_SIM
!= _ABIO32
156 } elseif
[check_no_compiler_messages mipsn32 assembly
{
157 #
if _MIPS_SIM
!= _ABIN32
162 } elseif
[check_no_compiler_messages mipsn64 assembly
{
163 #
if _MIPS_SIM
!= _ABI64
168 } elseif
[check_no_compiler_messages mipso64 assembly
{
169 #
if _MIPS_SIM
!= _ABIO64
175 perror
"$target_triplet: unrecognized MIPS ABI"
180 if [check_effective_target_ilp32
] {
187 perror
"$target_triplet: unhandled architecture"
191 verbose
-log "Setting GOARCH=$goarch" 1
192 setenv GOARCH $goarch
195 proc go
-gc
-tests
{ } {
198 global GCC_UNDER_TEST
200 global TORTURE_OPTIONS
201 global dg
-do-what
-default
202 global go_execute_args
203 global target_triplet
205 #
If a testcase doesn
't have special options, use these.
206 global DEFAULT_GOCFLAGS
207 if ![info exists DEFAULT_GOCFLAGS] {
208 set DEFAULT_GOCFLAGS " -pedantic-errors"
212 lappend options "additional_flags=$DEFAULT_GOCFLAGS"
214 # Set GOARCH for tests that need it.
217 # Running all the torture options takes too long and, since the
218 # frontend ignores the standard options, it doesn't significantly
220 set saved_torture_options $TORTURE_OPTIONS
221 set TORTURE_OPTIONS
[ list
{ -O2
-g
}]
223 set saved
-dg
-do-what
-default $
{dg
-do-what
-default
}
227 set tests
[lsort
[find $srcdir
/$subdir
*.go
]]
228 foreach test $tests
{
229 if ![runtest_file_p $runtests $test
] {
233 # Skip the files in bench and garbage
; they are not tests.
234 if [string match
"*go.test/test/bench/*" $test] {
237 if [string match
"*go.test/test/garbage/*" $test] {
241 # Skip files in sub
-subdirectories
: they are components of
243 if [string match
"*go.test/test/*/*/*" $test] {
247 set name [dg
-trim
-dirname $srcdir $test
]
249 # Skip certain tests
if target is RTEMS OS.
250 if [istarget
"*-*-rtems*"] {
251 if { [string match
"*go.test/test/args.go" \
253 ||
[string match
"*go.test/test/env.go" \
255 untested
"$name: uses the command-line or environment variables"
259 if { [string match
"*go.test/test/stack.go" \
261 ||
[string match
"*go.test/test/peano.go" \
263 ||
[string match
"*go.test/test/chan/goroutines.go" \
265 untested
"$name: has very high memory requirement"
270 if { [string match
"*bug347*" $test] \
271 ||
[string match
"*bug348*" $test] } {
272 # These bugs rely
on runtime.Caller which currently fails.
277 set fd
[open $test r
]
282 if { [gets $fd test_line
] < 0 } {
284 clone_output
"$test: could not read first line"
290 if { [ string match
"*nacl*exit 0*" $test_line ] \
291 ||
[ string match
"*exit 0*nacl*" $test_line ] \
292 ||
[ string match
"*Android*exit 0*" $test_line ] \
293 ||
[ string match
"*exit 0*Android*" $test_line ] } {
300 if { $lines_ok
== 0 } {
305 set test_line1 $test_line
307 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
308 set lineno
[expr $lineno
+ 1]
309 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
311 clone_output
"$test: could not read line $lineno"
317 if { $lines_ok
== 0 } {
323 set go_execute_args
""
324 if { [regexp
".*\\\$A.out (\[^|&>\].*)\$" $test_line match progargs] } {
325 set go_execute_args $progargs
326 verbose
-log "$test: go_execute_args is $go_execute_args"
327 set index
[string last
" $progargs" $test_line]
328 set test_line
[string replace $test_line $index end
]
329 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
330 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
331 # goroutines.go spawns by default
10000 threads
, which is too much
333 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
334 set go_execute_args
64
335 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
336 # When using low ulimit
-u
limit, use maximum of
337 # a quarter of that
limit and
10000 even when running expensive
338 # tests
, otherwise parallel tests might fail after fork failures.
339 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
340 if { [string is
integer -strict $nproc
] } {
341 set nproc
[expr $nproc
/ 4]
342 if { $nproc
> 10000 } { set nproc
10000 }
343 if { $nproc
< 16 } { set nproc
16 }
344 set go_execute_args $nproc
347 if { "$go_execute_args" != "" } {
348 verbose
-log "$test: go_execute_args is $go_execute_args"
352 if { $test_line
== "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
353 && $test_line2
== "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
354 #
64bit.go is a special case.
355 set go_execute_args
""
356 set hold_runtests $runtests
357 set runtests
"go-test.exp"
358 set dg
-do-what
-default
"link"
359 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
360 set output_file
"./[file rootname [file tail $test]].exe"
361 set base
"[file rootname [file tail $test]]"
363 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
364 fail
"$name execution"
366 pass
"$name execution"
367 file
delete $base
-out.x
368 go
-torture
-execute "./$base-out.go"
370 file
delete $base
-out.go
372 file
delete $output_file
373 set runtests $hold_runtests
374 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
375 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
376 || $test_line
== "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
377 || $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
379 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
382 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
385 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
388 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
391 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
393 # This is a vanilla execution test.
394 go
-torture
-execute $test
395 file
delete core
[glob
-nocomplain core.
*]
396 } elseif
{ [string match \
397 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
399 ||
[string match
"// \$G \$F.go && \$L \$F.\$A #*" \
401 || $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A" } {
402 # This is a vanilla
compile and link test.
403 set dg
-do-what
-default
"link"
404 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
405 } elseif
{ [string match
"// \$G \$D/\$F.go" $test_line] \
406 ||
[string match
"// \$G \$D/\$F.go || echo BUG*" \
408 ||
[string match
"// \$G \$F.go || echo BUG*" \
410 ||
[string match
"// ! \$G \$D/\$F.go && echo BUG*" \
412 # This is a vanilla
compile test.
413 set dg
-do-what
-default
"assemble"
414 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
415 } elseif
{ [string match
"// \$G \$D/\$F.go && echo BUG*" \
417 || $test_line
== "// ! \$G \$D/\$F.go >/dev/null" \
418 || $test_line
== "// ! \$G \$D/\$F.go" \
419 || $test_line
== "// ! \$G \$F.go" \
420 ||
[string match
"// ! \$G \$D/\$F.go || echo BUG*" \
422 # This is a
compile test which should fail.
423 set dg
-do-what
-default
"assemble"
425 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
426 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
428 ||
[string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
430 ||
[string match
"// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
432 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
433 && $test_line2
== "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
434 go
-execute-xfail $test
435 } elseif
{ [string match
"// errchk \$G \$F.go" $test_line] \
436 ||
[string match
"// errchk \$G -e \$F.go" $test_line] \
437 ||
[string match
"// errchk \$G \$D/\$F.go" $test_line] \
438 ||
[string match
"//errchk \$G \$D/\$F.go" $test_line] \
439 ||
[string match
"// errchk \$G -e \$D/\$F.go" \
441 ||
[string match
"// ! errchk \$G \$D/\$F.go" $test_line] \
442 ||
[string match
"// ! errchk \$G -e \$D/\$F.go" \
444 ||
[string match
"// errchk \$G \$F.go || true" \
446 ||
[string match
"// errchk \$G \$D/\$F.go || true" \
448 ||
[string match
"// errchk \$G -e \$D/\$F.go || true" \
450 ||
[string match
"// errchk \$G \$D/\$F.go || echo BUG*" \
453 } elseif
{ [string match \
454 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
456 set hold_runtests $runtests
457 set runtests
"go-test.exp"
458 set dg
-do-what
-default
"assemble"
459 regsub
"\\.go$" $test ".dir/bug0.go" file1
460 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
461 regsub
"\\.go$" $test ".dir/bug1.go" file2
462 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
463 file
delete "[file rootname [file tail $file1]].o"
464 set runtests $hold_runtests
465 } elseif
{ [string match \
466 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
469 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
472 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
475 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
478 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
482 } elseif
{ [string match \
483 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
487 } elseif
{ [string match \
488 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
492 } elseif
{ [string match \
493 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
498 set hold_runtests $runtests
499 set runtests
"go-test.exp"
500 set dg
-do-what
-default
"assemble"
501 regsub
"\\.go$" $test ".dir/$name1" file1
502 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
503 regsub
"\\.go$" $test ".dir/$name2" file2
505 file
delete "[file rootname [file tail $file1]].o"
506 set runtests $hold_runtests
507 } elseif
{ [string match \
508 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
510 set hold_runtests $runtests
511 set runtests
"go-test.exp"
512 set dg
-do-what
-default
"assemble"
513 regsub
"\\.go$" $test "1.go" file1
514 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
516 file
delete "[file rootname [file tail $file1]].o"
517 set runtests $hold_runtests
518 } elseif
{ [string match \
519 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
521 set hold_runtests $runtests
522 set runtests
"go-test.exp"
523 set dg
-do-what
-default
"assemble"
524 regsub
"\\.go$" $test ".dir/bug0.go" file1
525 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
526 regsub
"\\.go$" $test ".dir/bug1.go" file2
528 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
529 file
delete "[file rootname [file tail $file1]].o"
530 set runtests $hold_runtests
531 } elseif
{ [string match \
532 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
534 set hold_runtests $runtests
535 set runtests
"go-test.exp"
536 set dg
-do-what
-default
"assemble"
537 regsub
"\\.go$" $test ".dir/bug0.go" file1
538 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
539 regsub
"\\.go$" $test ".dir/bug1.go" file2
540 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
541 regsub
"\\.go$" $test ".dir/bug2.go" file3
543 dg
-test $file3
"-O" "-w $DEFAULT_GOCFLAGS"
544 file
delete "[file rootname [file tail $file1]].o"
545 file
delete "[file rootname [file tail $file2]].o"
546 set runtests $hold_runtests
547 } elseif
{ [string match \
548 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
550 set hold_runtests $runtests
551 set runtests
"go-test.exp"
552 set dg
-do-what
-default
"assemble"
553 regsub
"\\.go$" $test ".dir/bug0.go" file1
554 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
555 regsub
"\\.go$" $test ".dir/bug1.go" file2
556 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
557 regsub
"\\.go$" $test ".dir/bug2.go" file3
559 file
delete "[file rootname [file tail $file1]].o"
560 file
delete "[file rootname [file tail $file2]].o"
561 set runtests $hold_runtests
562 } elseif
{ [string match \
563 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
566 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
569 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
573 } elseif
{ [string match \
574 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
579 set hold_runtests $runtests
580 set runtests
"go-test.exp"
581 set dg
-do-what
-default
"assemble"
582 regsub
"\\.go$" $test ".dir/$name1" file1
583 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
584 set ofile1
"[file rootname [file tail $file1]].o"
585 regsub
"\\.go$" $test ".dir/$name2" file2
586 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
587 set ofile2
"[file rootname [file tail $file2]].o"
588 set dg
-do-what
-default
"link"
589 set output_file
"./[file rootname [file tail $test]].exe"
590 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
591 $output_file
"executable" "$options"]
592 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
593 verbose
-log $comp_output
594 set result
[go_load
"$output_file" "" ""]
595 set status [lindex $result
0]
597 file
delete $ofile1 $ofile2 $output_file
598 set runtests $hold_runtests
599 } elseif
{ [string match \
600 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
602 set hold_runtests $runtests
603 set runtests
"go-test.exp"
604 set dg
-do-what
-default
"assemble"
605 regsub
"\\.go$" $test ".dir/a.go" file1
606 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
607 set ofile1
"[file rootname [file tail $file1]].o"
608 regsub
"\\.go$" $test ".dir/b.go" file2
609 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
610 set ofile2
"[file rootname [file tail $file2]].o"
611 dg
-test
-keep
-output
"$test" "-O" "-w $DEFAULT_GOCFLAGS"
612 set ofile3
"[file rootname [file tail $test]].o"
613 set dg
-do-what
-default
"link"
614 set output_file
"./[file rootname [file tail $test]].exe"
615 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
616 $output_file
"executable" "$options"]
617 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
618 if [string match
"" $comp_output] {
621 verbose
-log $comp_output
624 file
delete $ofile1 $ofile2 $ofile3 $output_file
625 set runtests $hold_runtests
626 } elseif
{ [string match \
627 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
629 set hold_runtests $runtests
630 set runtests
"go-test.exp"
631 set dg
-do-what
-default
"assemble"
632 regsub
"/\[^/\]*$" $test "/embed0.go" file1
633 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
634 set ofile1
"[file rootname [file tail $file1]].o"
635 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
636 set ofile2
"[file rootname [file tail $test]].o"
637 set output_file
"./[file rootname [file tail $test]].exe"
638 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
639 $output_file
"executable" "$options"]
640 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
641 if [string match
"" $comp_output] {
642 set result
[go_load
"$output_file" "" ""]
643 set status [lindex $result
0]
646 verbose
-log $comp_output
649 file
delete $ofile1 $ofile2 $output_file
650 set runtests $hold_runtests
651 } elseif
{ [string match \
652 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
654 set hold_runtests $runtests
655 set runtests
"go-test.exp"
656 set dg
-do-what
-default
"assemble"
657 regsub
"\\.go$" $test ".dir/lib.go" file1
658 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
659 set ofile1
"[file rootname [file tail $file1]].o"
660 regsub
"\\.go$" $test ".dir/main.go" file2
661 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
662 set ofile2
"[file rootname [file tail $file2]].o"
663 set dg
-do-what
-default
"link"
664 set output_file
"./[file rootname [file tail $file2]].exe"
665 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
666 $output_file
"executable" "$options"]
667 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
668 if [string match
"" $comp_output] {
669 set result
[go_load
"$output_file" "" ""]
670 set status [lindex $result
0]
673 verbose
-log $comp_output
676 file
delete $ofile1 $ofile2 $output_file
677 set runtests $hold_runtests
678 } elseif
{ [string match \
679 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
681 set hold_runtests $runtests
682 set runtests
"go-test.exp"
683 set dg
-do-what
-default
"assemble"
684 regsub
"\\.go$" $test ".dir/chanbug.go" file1
685 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
686 regsub
"\\.go$" $test ".dir/chanbug2.go" file2
687 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
688 file
delete "[file rootname [file tail $file1]].o"
689 set runtests $hold_runtests
690 } elseif
{ [string match \
691 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
693 set dg
-do-what
-default
"assemble"
695 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
696 } elseif
{ [string match \
697 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
699 set hold_runtests $runtests
700 set runtests
"go-test.exp"
701 set dg
-do-what
-default
"assemble"
702 regsub
"\\.go$" $test ".dir/x.go" file1
703 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
704 regsub
"\\.go$" $test ".dir/y.go" file2
706 file
delete "[file rootname [file tail $file1]].o"
707 set runtests $hold_runtests
708 } elseif
{ [string match
"// true*" $test_line] } {
709 # Not a real test
, just ignore.
710 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
711 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
712 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
713 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
714 && $test_line5
== "// \$L bug2.\$A &&" \
715 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
716 set hold_runtests $runtests
717 set runtests
"go-test.exp"
718 set dg
-do-what
-default
"assemble"
719 regsub
"\\.go$" $test ".dir/bug0.go" file0
720 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
721 set ofile0
"[file rootname [file tail $file0]].o"
722 regsub
"\\.go$" $test ".dir/bug1.go" file1
723 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
724 set ofile1
"[file rootname [file tail $file1]].o"
725 regsub
"\\.go$" $test ".dir/bug2.go" file2
726 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
727 set ofile2
"[file rootname [file tail $file2]].o"
728 regsub
"\\.go$" $test ".dir/bug3.go" file3
730 set output_file
"./[file rootname [file tail $test]].exe"
731 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
732 $output_file
"executable" "$options"]
733 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
734 if [string match
"" $comp_output] {
735 set result
[go_load
"$output_file" "" ""]
736 set status [lindex $result
0]
739 verbose
-log $comp_output
742 file
delete $ofile0 $ofile1 $ofile2 $output_file
743 set runtests $hold_runtests
744 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
745 set hold_runtests $runtests
746 set runtests
"go-test.exp"
747 set dg
-do-what
-default
"assemble"
748 regsub
"/\[^/\]*$" $test "/import2.go" file1
749 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
750 set ofile1
"[file rootname [file tail $file1]].o"
751 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
753 set runtests $hold_runtests
754 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
755 set hold_runtests $runtests
756 set runtests
"go-test.exp"
757 set dg
-do-what
-default
"assemble"
758 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
759 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
760 set ofile1
"[file rootname [file tail $file1]].o"
761 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
762 set ofile2
"[file rootname [file tail $test]].o"
763 set output_file
"./[file rootname [file tail $test]].exe"
764 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
765 $output_file
"executable" "$options"]
766 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
767 if [string match
"" $comp_output] {
768 set result
[go_load
"$output_file" "" ""]
769 set status [lindex $result
0]
772 verbose
-log $comp_output
775 file
delete $ofile1 $ofile2 $output_file
776 set runtests $hold_runtests
777 } elseif
{ $test_line
== "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
778 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
779 set output_file
"./[file rootname [file tail $test]].o"
780 set comp_output
[go_target_compile
"$test $test2" \
781 $output_file
"executable" "$options"]
782 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
783 if [string match
"" $comp_output] {
784 set result
[go_load
"$output_file" "" ""]
785 set status [lindex $result
0]
788 verbose
-log $comp_output
791 file
delete $output_file
792 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
793 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
794 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
795 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
796 set go_execute_args
""
797 set hold_runtests $runtests
798 set runtests
"go-test.exp"
799 set dg
-do-what
-default
"link"
800 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
801 set output_file
"./[file rootname [file tail $test]].exe"
803 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
804 fail
"$name execution 0"
806 pass
"$name execution 0"
808 go
-torture
-execute "./tmp.go"
810 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
811 fail
"$name execution 1"
813 pass
"$name execution 1"
816 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
817 fail
"$name execution 2"
819 pass
"$name execution 2"
824 file
delete $output_file
825 set runtests $hold_runtests
826 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
827 && $test_line2
== "// errchk \$G -e tmp.go" } {
828 set go_execute_args
""
829 set hold_runtests $runtests
830 set runtests
"go-test.exp"
831 set dg
-do-what
-default
"link"
832 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
833 set output_file
"./[file rootname [file tail $test]].exe"
835 if { [catch
"exec $output_file >tmp.go"] != 0 } {
836 fail
"$name execution"
838 pass
"$name execution"
843 file
delete $output_file
844 set runtests $hold_runtests
845 } elseif
{ [string match \
846 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
848 set hold_runtests $runtests
849 set runtests
"go-test.exp"
850 set dg
-do-what
-default
"assemble"
851 regsub
"\\.go$" $test ".dir/p.go" file1
852 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
853 set ofile1
"[file rootname [file tail $file1]].o"
854 regsub
"\\.go$" $test ".dir/main.go" file2
855 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
856 set ofile2
"[file rootname [file tail $file2]].o"
857 set output_file
"./[file rootname [file tail $test]].exe"
858 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
859 $output_file
"executable" "$options"]
860 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
861 if [string match
"" $comp_output] {
863 set result
[go_load
"$output_file" "" ""]
864 set status [lindex $result
0]
867 verbose
-log $comp_output
870 file
delete $ofile1 $ofile2 $output_file
871 set runtests $hold_runtests
872 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
873 && $test_line2
== "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
874 set go_execute_args
""
875 set hold_runtests $runtests
876 set runtests
"go-test.exp"
877 set dg
-do-what
-default
"link"
878 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
879 set output_file
"./[file rootname [file tail $test]].exe"
880 set base
"[file rootname [file tail $test]]"
882 if { [catch
"exec $output_file > $base-out.go"] != 0 } {
883 fail
"$name execution"
885 pass
"$name execution"
886 file
delete $base
-out.x
887 go
-torture
-execute "./$base-out.go"
889 # file
delete $base
-out.go
891 file
delete $output_file
892 set runtests $hold_runtests
893 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
894 regsub
"\\.go$" $test ".dir/a.go" file1
895 regsub
"\\.go$" $test ".dir/b.go" file2
896 errchk
"$file1" "$file2"
897 } elseif
{ $test_line
== "// # generated by cmplxdivide.c" } {
899 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
900 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
901 # These tests
import the same package under two different
902 # names
, which gccgo does not support.
903 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo FAIL || true" } {
904 # This tests whether initializers are written out
905 # statically. gccgo does not provide a way to test that
,
906 # as an initializer will be generated
for any code which
907 # has global variables which need to be registered as GC
910 clone_output
"$name: unrecognized test line: $test_line"
914 set go_execute_args
""
917 set dg
-do-what
-default $
{saved
-dg
-do-what
-default
}
918 set TORTURE_OPTIONS $saved_torture_options