1 # Copyright
(C
) 2009, 2010, 2011 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
-start $index
-all
"\{" $out_line "\\\\\[\\\{\\\\\]" 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 "\\\\\[\\\(\\\\\]" 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 "\\\\\[\\\)\\\\\]\\1" out_line
80 if [string match
"*dg-error*\[.\]*" $out_line] {
81 set index
[string first
"dg-error" $out_line]
82 regsub
-all
"\\\[\\.\\\]" $out_line "\\\\\[.\\\\\]" out_line
89 set hold_runtests $runtests
90 set runtests
"go-test.exp"
91 go
-dg
-runtest $filename
"-fno-show-column $DEFAULT_GOCFLAGS $opts"
92 set runtests $hold_runtests
95 set dg
-do-what
-default $
{saved
-dg
-do-what
-default
}
98 # This is an execution test which should fail.
99 proc go
-execute-xfail
{ test
} {
100 global DEFAULT_GOCFLAGS
103 set filename
[file tail $test
]
104 set fdin
[open $test r
]
105 set fdout
[open $filename w
]
106 puts $fdout
"// { dg-do run { xfail *-*-* } }"
107 while { [gets $fdin copy_line
] >= 0 } {
108 puts $fdout $copy_line
113 set hold_runtests $runtests
114 set runtests
"go-test.exp"
115 go
-dg
-runtest $filename
"-w $DEFAULT_GOCFLAGS"
116 set runtests $hold_runtests
118 file
delete $filename
121 # N.B. Keep in sync with libgo
/configure.ac.
122 proc go
-set-goarch
{ } {
123 global target_triplet
125 switch -glob $target_triplet
{
134 if [check_effective_target_ilp32
] {
141 if [check_no_compiler_messages mipso32 assembly
{
142 #
if _MIPS_SIM
!= _ABIO32
147 } elseif
[check_no_compiler_messages mipsn32 assembly
{
148 #
if _MIPS_SIM
!= _ABIN32
153 } elseif
[check_no_compiler_messages mipsn64 assembly
{
154 #
if _MIPS_SIM
!= _ABI64
159 } elseif
[check_no_compiler_messages mipso64 assembly
{
160 #
if _MIPS_SIM
!= _ABIO64
166 perror
"$target_triplet: unrecognized MIPS ABI"
171 if [check_effective_target_ilp32
] {
178 perror
"$target_triplet: unhandled architecture"
182 verbose
-log "Setting GOARCH=$goarch" 1
183 setenv GOARCH $goarch
186 proc go
-gc
-tests
{ } {
189 global GCC_UNDER_TEST
191 global TORTURE_OPTIONS
192 global dg
-do-what
-default
193 global go_execute_args
194 global target_triplet
196 #
If a testcase doesn
't have special options, use these.
197 global DEFAULT_GOCFLAGS
198 if ![info exists DEFAULT_GOCFLAGS] {
199 set DEFAULT_GOCFLAGS " -pedantic-errors"
202 # Set GOARCH for tests that need it.
205 # Running all the torture options takes too long and, since the
206 # frontend ignores the standard options, it doesn't significantly
208 set saved_torture_options $TORTURE_OPTIONS
209 set TORTURE_OPTIONS
[ list
{ -O2
-g
}]
211 set saved
-dg
-do-what
-default $
{dg
-do-what
-default
}
215 set tests
[lsort
[find $srcdir
/$subdir
*.go
]]
216 foreach test $tests
{
217 if ![runtest_file_p $runtests $test
] {
221 # Skip the files in bench and garbage
; they are not tests.
222 if [string match
"*go.test/test/bench/*" $test] {
225 if [string match
"*go.test/test/garbage/*" $test] {
229 # Skip files in sub
-subdirectories
: they are components of
231 if [string match
"*go.test/test/*/*/*" $test] {
235 set name [dg
-trim
-dirname $srcdir $test
]
237 # Skip certain tests
if target is RTEMS OS.
238 if [istarget
"*-*-rtems*"] {
239 if { [string match
"*go.test/test/args.go" \
241 ||
[string match
"*go.test/test/env.go" \
243 untested
"$name: uses the command-line or environment variables"
247 if { [string match
"*go.test/test/stack.go" \
249 ||
[string match
"*go.test/test/peano.go" \
251 ||
[string match
"*go.test/test/chan/goroutines.go" \
253 untested
"$name: has very high memory requirement"
258 set fd
[open $test r
]
263 if { [gets $fd test_line
] < 0 } {
265 clone_output
"$test: could not read first line"
271 if { [ string match
"*nacl*exit 0*" $test_line ] \
272 ||
[ string match
"*exit 0*nacl*" $test_line ] \
273 ||
[ string match
"*Android*exit 0*" $test_line ] \
274 ||
[ string match
"*exit 0*Android*" $test_line ] } {
281 if { $lines_ok
== 0 } {
286 set test_line1 $test_line
288 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
289 set lineno
[expr $lineno
+ 1]
290 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
292 clone_output
"$test: could not read line $lineno"
298 if { $lines_ok
== 0 } {
304 set go_execute_args
""
305 if { [regexp
".*\\\$A.out (\[^|&>\].*)\$" $test_line match progargs] } {
306 set go_execute_args $progargs
307 verbose
-log "$test: go_execute_args is $go_execute_args"
308 set index
[string last
" $progargs" $test_line]
309 set test_line
[string replace $test_line $index end
]
310 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
311 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
312 # goroutines.go spawns by default
10000 threads
, which is too much
314 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
315 set go_execute_args
64
316 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
317 # When using low ulimit
-u
limit, use maximum of
318 # a quarter of that
limit and
10000 even when running expensive
319 # tests
, otherwise parallel tests might fail after fork failures.
320 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
321 if { [string is
integer -strict $nproc
] } {
322 set nproc
[expr $nproc
/ 4]
323 if { $nproc
> 10000 } { set nproc
10000 }
324 if { $nproc
< 16 } { set nproc
16 }
325 set go_execute_args $nproc
328 if { "$go_execute_args" != "" } {
329 verbose
-log "$test: go_execute_args is $go_execute_args"
333 if { $test_line
== "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
334 && $test_line2
== "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
335 #
64bit.go is a special case.
336 set go_execute_args
""
337 set hold_runtests $runtests
338 set runtests
"go-test.exp"
339 set dg
-do-what
-default
"link"
340 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
341 set output_file
"./[file rootname [file tail $test]].exe"
342 set base
"[file rootname [file tail $test]]"
344 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
345 fail
"$name execution"
347 pass
"$name execution"
348 file
delete $base
-out.x
349 go
-torture
-execute "./$base-out.go"
351 file
delete $base
-out.go
353 file
delete $output_file
354 set runtests $hold_runtests
355 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
356 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
357 || $test_line
== "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
358 || $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
360 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
363 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
366 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
369 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
372 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
374 # This is a vanilla execution test.
375 go
-torture
-execute $test
376 file
delete core
[glob
-nocomplain core.
*]
377 } elseif
{ [string match \
378 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
380 ||
[string match
"// \$G \$F.go && \$L \$F.\$A #*" \
382 || $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A" } {
383 # This is a vanilla
compile and link test.
384 set dg
-do-what
-default
"link"
385 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
386 } elseif
{ [string match
"// \$G \$D/\$F.go" $test_line] \
387 ||
[string match
"// \$G \$D/\$F.go || echo BUG*" \
389 ||
[string match
"// \$G \$F.go || echo BUG*" \
391 ||
[string match
"// ! \$G \$D/\$F.go && echo BUG*" \
393 # This is a vanilla
compile test.
394 set dg
-do-what
-default
"assemble"
395 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
396 } elseif
{ [string match
"// \$G \$D/\$F.go && echo BUG*" \
398 || $test_line
== "// ! \$G \$D/\$F.go >/dev/null" \
399 || $test_line
== "// ! \$G \$D/\$F.go" \
400 || $test_line
== "// ! \$G \$F.go" \
401 ||
[string match
"// ! \$G \$D/\$F.go || echo BUG*" \
403 # This is a
compile test which should fail.
404 set dg
-do-what
-default
"assemble"
406 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
407 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
409 ||
[string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
411 ||
[string match
"// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
413 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
414 && $test_line2
== "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
415 go
-execute-xfail $test
416 } elseif
{ [string match
"// errchk \$G \$F.go" $test_line] \
417 ||
[string match
"// errchk \$G -e \$F.go" $test_line] \
418 ||
[string match
"// errchk \$G \$D/\$F.go" $test_line] \
419 ||
[string match
"//errchk \$G \$D/\$F.go" $test_line] \
420 ||
[string match
"// errchk \$G -e \$D/\$F.go" \
422 ||
[string match
"// ! errchk \$G \$D/\$F.go" $test_line] \
423 ||
[string match
"// ! errchk \$G -e \$D/\$F.go" \
425 ||
[string match
"// errchk \$G \$F.go || true" \
427 ||
[string match
"// errchk \$G \$D/\$F.go || true" \
429 ||
[string match
"// errchk \$G -e \$D/\$F.go || true" \
431 ||
[string match
"// errchk \$G \$D/\$F.go || echo BUG*" \
434 } elseif
{ [string match \
435 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
437 set hold_runtests $runtests
438 set runtests
"go-test.exp"
439 set dg
-do-what
-default
"assemble"
440 regsub
"\\.go$" $test ".dir/bug0.go" file1
441 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
442 regsub
"\\.go$" $test ".dir/bug1.go" file2
443 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
444 file
delete "[file rootname [file tail $file1]].o"
445 set runtests $hold_runtests
446 } elseif
{ [string match \
447 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
450 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
453 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
461 set hold_runtests $runtests
462 set runtests
"go-test.exp"
463 set dg
-do-what
-default
"assemble"
464 regsub
"\\.go$" $test ".dir/$name1" file1
465 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
466 regsub
"\\.go$" $test ".dir/$name2" file2
468 file
delete "[file rootname [file tail $file1]].o"
469 set runtests $hold_runtests
470 } elseif
{ [string match \
471 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
473 set hold_runtests $runtests
474 set runtests
"go-test.exp"
475 set dg
-do-what
-default
"assemble"
476 regsub
"\\.go$" $test ".dir/bug0.go" file1
477 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
478 regsub
"\\.go$" $test ".dir/bug1.go" file2
480 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
481 file
delete "[file rootname [file tail $file1]].o"
482 set runtests $hold_runtests
483 } elseif
{ [string match \
484 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
486 set hold_runtests $runtests
487 set runtests
"go-test.exp"
488 set dg
-do-what
-default
"assemble"
489 regsub
"\\.go$" $test ".dir/bug0.go" file1
490 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
491 regsub
"\\.go$" $test ".dir/bug1.go" file2
492 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
493 regsub
"\\.go$" $test ".dir/bug2.go" file3
495 dg
-test $file3
"-O" "-w $DEFAULT_GOCFLAGS"
496 file
delete "[file rootname [file tail $file1]].o"
497 file
delete "[file rootname [file tail $file2]].o"
498 set runtests $hold_runtests
499 } elseif
{ [string match \
500 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
502 set hold_runtests $runtests
503 set runtests
"go-test.exp"
504 set dg
-do-what
-default
"assemble"
505 regsub
"\\.go$" $test ".dir/bug0.go" file1
506 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
507 regsub
"\\.go$" $test ".dir/bug1.go" file2
508 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
509 regsub
"\\.go$" $test ".dir/bug2.go" file3
511 file
delete "[file rootname [file tail $file1]].o"
512 file
delete "[file rootname [file tail $file2]].o"
513 set runtests $hold_runtests
514 } elseif
{ [string match \
515 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
517 set hold_runtests $runtests
518 set runtests
"go-test.exp"
519 set dg
-do-what
-default
"assemble"
520 regsub
"\\.go$" $test ".dir/x.go" file1
521 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
522 set ofile1
"[file rootname [file tail $file1]].o"
523 regsub
"\\.go$" $test ".dir/y.go" file2
524 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
525 set ofile2
"[file rootname [file tail $file2]].o"
526 set dg
-do-what
-default
"link"
527 set output_file
"./[file rootname [file tail $test]].exe"
528 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
529 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
530 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
531 verbose
-log $comp_output
532 set result
[go_load
"$output_file" "" ""]
533 set status [lindex $result
0]
535 file
delete $ofile1 $ofile2 $output_file
536 set runtests $hold_runtests
537 } elseif
{ [string match \
538 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
540 set hold_runtests $runtests
541 set runtests
"go-test.exp"
542 set dg
-do-what
-default
"assemble"
543 regsub
"\\.go$" $test ".dir/a.go" file1
544 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
545 set ofile1
"[file rootname [file tail $file1]].o"
546 regsub
"\\.go$" $test ".dir/b.go" file2
547 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
548 set ofile2
"[file rootname [file tail $file2]].o"
549 dg
-test
-keep
-output
"$test" "-O" "-w $DEFAULT_GOCFLAGS"
550 set ofile3
"[file rootname [file tail $test]].o"
551 set dg
-do-what
-default
"link"
552 set output_file
"./[file rootname [file tail $test]].exe"
553 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
554 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
555 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
556 if [string match
"" $comp_output] {
559 verbose
-log $comp_output
562 file
delete $ofile1 $ofile2 $ofile3 $output_file
563 set runtests $hold_runtests
564 } elseif
{ [string match \
565 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
567 set hold_runtests $runtests
568 set runtests
"go-test.exp"
569 set dg
-do-what
-default
"assemble"
570 regsub
"/\[^/\]*$" $test "/embed0.go" file1
571 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
572 set ofile1
"[file rootname [file tail $file1]].o"
573 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
574 set ofile2
"[file rootname [file tail $test]].o"
575 set output_file
"./[file rootname [file tail $test]].exe"
576 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
577 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
578 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
579 if [string match
"" $comp_output] {
580 set result
[go_load
"$output_file" "" ""]
581 set status [lindex $result
0]
584 verbose
-log $comp_output
587 file
delete $ofile1 $ofile2 $output_file
588 set runtests $hold_runtests
589 } elseif
{ [string match \
590 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
592 set hold_runtests $runtests
593 set runtests
"go-test.exp"
594 set dg
-do-what
-default
"assemble"
595 regsub
"\\.go$" $test ".dir/lib.go" file1
596 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
597 set ofile1
"[file rootname [file tail $file1]].o"
598 regsub
"\\.go$" $test ".dir/main.go" file2
599 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
600 set ofile2
"[file rootname [file tail $file2]].o"
601 set dg
-do-what
-default
"link"
602 set output_file
"./[file rootname [file tail $file2]].exe"
603 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
604 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
605 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
606 if [string match
"" $comp_output] {
607 set result
[go_load
"$output_file" "" ""]
608 set status [lindex $result
0]
611 verbose
-log $comp_output
614 file
delete $ofile1 $ofile2 $output_file
615 set runtests $hold_runtests
616 } elseif
{ [string match \
617 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
619 set hold_runtests $runtests
620 set runtests
"go-test.exp"
621 set dg
-do-what
-default
"assemble"
622 regsub
"\\.go$" $test ".dir/chanbug.go" file1
623 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
624 regsub
"\\.go$" $test ".dir/chanbug2.go" file2
625 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
626 file
delete "[file rootname [file tail $file1]].o"
627 set runtests $hold_runtests
628 } elseif
{ [string match \
629 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
631 set dg
-do-what
-default
"assemble"
633 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
634 } elseif
{ [string match \
635 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
637 set hold_runtests $runtests
638 set runtests
"go-test.exp"
639 set dg
-do-what
-default
"assemble"
640 regsub
"\\.go$" $test ".dir/x.go" file1
641 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
642 regsub
"\\.go$" $test ".dir/y.go" file2
644 file
delete "[file rootname [file tail $file1]].o"
645 set runtests $hold_runtests
646 } elseif
{ [string match
"// true*" $test_line] } {
647 # Not a real test
, just ignore.
648 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
649 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
650 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
651 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
652 && $test_line5
== "// \$L bug2.\$A &&" \
653 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
654 set hold_runtests $runtests
655 set runtests
"go-test.exp"
656 set dg
-do-what
-default
"assemble"
657 regsub
"\\.go$" $test ".dir/bug0.go" file0
658 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
659 set ofile0
"[file rootname [file tail $file0]].o"
660 regsub
"\\.go$" $test ".dir/bug1.go" file1
661 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
662 set ofile1
"[file rootname [file tail $file1]].o"
663 regsub
"\\.go$" $test ".dir/bug2.go" file2
664 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
665 set ofile2
"[file rootname [file tail $file2]].o"
666 regsub
"\\.go$" $test ".dir/bug3.go" file3
668 set output_file
"./[file rootname [file tail $test]].exe"
669 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
670 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
671 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
672 if [string match
"" $comp_output] {
673 set result
[go_load
"$output_file" "" ""]
674 set status [lindex $result
0]
677 verbose
-log $comp_output
680 file
delete $ofile0 $ofile1 $ofile2 $output_file
681 set runtests $hold_runtests
682 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
683 set hold_runtests $runtests
684 set runtests
"go-test.exp"
685 set dg
-do-what
-default
"assemble"
686 regsub
"/\[^/\]*$" $test "/import2.go" file1
687 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
688 set ofile1
"[file rootname [file tail $file1]].o"
689 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
691 set runtests $hold_runtests
692 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
693 set hold_runtests $runtests
694 set runtests
"go-test.exp"
695 set dg
-do-what
-default
"assemble"
696 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
697 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
698 set ofile1
"[file rootname [file tail $file1]].o"
699 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
700 set ofile2
"[file rootname [file tail $test]].o"
701 set output_file
"./[file rootname [file tail $test]].exe"
702 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
703 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
704 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
705 if [string match
"" $comp_output] {
706 set result
[go_load
"$output_file" "" ""]
707 set status [lindex $result
0]
710 verbose
-log $comp_output
713 file
delete $ofile1 $ofile2 $output_file
714 set runtests $hold_runtests
715 } elseif
{ $test_line
== "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
716 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
717 set output_file
"./[file rootname [file tail $test]].o"
718 set comp_output
[go_target_compile
"$test $test2" \
719 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
720 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
721 if [string match
"" $comp_output] {
722 set result
[go_load
"$output_file" "" ""]
723 set status [lindex $result
0]
726 verbose
-log $comp_output
729 file
delete $output_file
730 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
731 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
732 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
733 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
734 set go_execute_args
""
735 set hold_runtests $runtests
736 set runtests
"go-test.exp"
737 set dg
-do-what
-default
"link"
738 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
739 set output_file
"./[file rootname [file tail $test]].exe"
741 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
742 fail
"$name execution 0"
744 pass
"$name execution 0"
746 go
-torture
-execute "./tmp.go"
748 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
749 fail
"$name execution 1"
751 pass
"$name execution 1"
754 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
755 fail
"$name execution 2"
757 pass
"$name execution 2"
762 file
delete $output_file
763 set runtests $hold_runtests
764 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
765 && $test_line2
== "// errchk \$G -e tmp.go" } {
766 set go_execute_args
""
767 set hold_runtests $runtests
768 set runtests
"go-test.exp"
769 set dg
-do-what
-default
"link"
770 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
771 set output_file
"./[file rootname [file tail $test]].exe"
773 if { [catch
"exec $output_file >tmp.go"] != 0 } {
774 fail
"$name execution"
776 pass
"$name execution"
781 file
delete $output_file
782 set runtests $hold_runtests
783 } elseif
{ [string match \
784 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
786 set hold_runtests $runtests
787 set runtests
"go-test.exp"
788 set dg
-do-what
-default
"assemble"
789 regsub
"\\.go$" $test ".dir/p.go" file1
790 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
791 set ofile1
"[file rootname [file tail $file1]].o"
792 regsub
"\\.go$" $test ".dir/main.go" file2
793 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
794 set ofile2
"[file rootname [file tail $file2]].o"
795 set output_file
"./[file rootname [file tail $test]].exe"
796 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
797 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
798 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
799 if [string match
"" $comp_output] {
801 set result
[go_load
"$output_file" "" ""]
802 set status [lindex $result
0]
805 verbose
-log $comp_output
808 file
delete $ofile1 $ofile2 $output_file
809 set runtests $hold_runtests
810 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
811 && $test_line2
== "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
812 set go_execute_args
""
813 set hold_runtests $runtests
814 set runtests
"go-test.exp"
815 set dg
-do-what
-default
"link"
816 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
817 set output_file
"./[file rootname [file tail $test]].exe"
818 set base
"[file rootname [file tail $test]]"
820 if { [catch
"exec $output_file > $base-out.go"] != 0 } {
821 fail
"$name execution"
823 pass
"$name execution"
824 file
delete $base
-out.x
825 go
-torture
-execute "./$base-out.go"
827 # file
delete $base
-out.go
829 file
delete $output_file
830 set runtests $hold_runtests
831 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
832 regsub
"\\.go$" $test ".dir/a.go" file1
833 regsub
"\\.go$" $test ".dir/b.go" file2
834 errchk
"$file1" "$file2"
835 } elseif
{ $test_line
== "// # generated by cmplxdivide.c" } {
837 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
838 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
839 # These tests
import the same package under two different
840 # names
, which gccgo does not support.
841 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo FAIL || true" } {
842 # This tests whether initializers are written out
843 # statically. gccgo does not provide a way to test that
,
844 # as an initializer will be generated
for any code which
845 # has global variables which need to be registered as GC
848 clone_output
"$name: unrecognized test line: $test_line"
852 set go_execute_args
""
855 set dg
-do-what
-default $
{saved
-dg
-do-what
-default
}
856 set TORTURE_OPTIONS $saved_torture_options