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
{
137 if [check_effective_target_ilp32
] {
144 if [check_no_compiler_messages mipso32 assembly
{
145 #
if _MIPS_SIM
!= _ABIO32
150 } elseif
[check_no_compiler_messages mipsn32 assembly
{
151 #
if _MIPS_SIM
!= _ABIN32
156 } elseif
[check_no_compiler_messages mipsn64 assembly
{
157 #
if _MIPS_SIM
!= _ABI64
162 } elseif
[check_no_compiler_messages mipso64 assembly
{
163 #
if _MIPS_SIM
!= _ABIO64
169 perror
"$target_triplet: unrecognized MIPS ABI"
174 if [check_effective_target_ilp32
] {
181 perror
"$target_triplet: unhandled architecture"
185 verbose
-log "Setting GOARCH=$goarch" 1
186 setenv GOARCH $goarch
189 proc go
-gc
-tests
{ } {
192 global GCC_UNDER_TEST
194 global TORTURE_OPTIONS
195 global dg
-do-what
-default
196 global go_execute_args
197 global target_triplet
199 #
If a testcase doesn
't have special options, use these.
200 global DEFAULT_GOCFLAGS
201 if ![info exists DEFAULT_GOCFLAGS] {
202 set DEFAULT_GOCFLAGS " -pedantic-errors"
205 # Set GOARCH for tests that need it.
208 # Running all the torture options takes too long and, since the
209 # frontend ignores the standard options, it doesn't significantly
211 set saved_torture_options $TORTURE_OPTIONS
212 set TORTURE_OPTIONS
[ list
{ -O2
-g
}]
214 set saved
-dg
-do-what
-default $
{dg
-do-what
-default
}
218 set tests
[lsort
[find $srcdir
/$subdir
*.go
]]
219 foreach test $tests
{
220 if ![runtest_file_p $runtests $test
] {
224 # Skip the files in bench and garbage
; they are not tests.
225 if [string match
"*go.test/test/bench/*" $test] {
228 if [string match
"*go.test/test/garbage/*" $test] {
232 # Skip files in sub
-subdirectories
: they are components of
234 if [string match
"*go.test/test/*/*/*" $test] {
238 set name [dg
-trim
-dirname $srcdir $test
]
240 # Skip certain tests
if target is RTEMS OS.
241 if [istarget
"*-*-rtems*"] {
242 if { [string match
"*go.test/test/args.go" \
244 ||
[string match
"*go.test/test/env.go" \
246 untested
"$name: uses the command-line or environment variables"
250 if { [string match
"*go.test/test/stack.go" \
252 ||
[string match
"*go.test/test/peano.go" \
254 ||
[string match
"*go.test/test/chan/goroutines.go" \
256 untested
"$name: has very high memory requirement"
261 set fd
[open $test r
]
266 if { [gets $fd test_line
] < 0 } {
268 clone_output
"$test: could not read first line"
274 if { [ string match
"*nacl*exit 0*" $test_line ] \
275 ||
[ string match
"*exit 0*nacl*" $test_line ] \
276 ||
[ string match
"*Android*exit 0*" $test_line ] \
277 ||
[ string match
"*exit 0*Android*" $test_line ] } {
284 if { $lines_ok
== 0 } {
289 set test_line1 $test_line
291 while { [eval
"string match \"//*&&\" \${test_line$lineno}"] } {
292 set lineno
[expr $lineno
+ 1]
293 if { [eval
"gets \$fd test_line$lineno"] < 0 } {
295 clone_output
"$test: could not read line $lineno"
301 if { $lines_ok
== 0 } {
307 set go_execute_args
""
308 if { [regexp
".*\\\$A.out (\[^|&>\].*)\$" $test_line match progargs] } {
309 set go_execute_args $progargs
310 verbose
-log "$test: go_execute_args is $go_execute_args"
311 set index
[string last
" $progargs" $test_line]
312 set test_line
[string replace $test_line $index end
]
313 } elseif
{ [string match
"*go.test/test/chan/goroutines.go" $test] \
314 && [getenv GCCGO_RUN_ALL_TESTS
] == "" } {
315 # goroutines.go spawns by default
10000 threads
, which is too much
317 if { [getenv GCC_TEST_RUN_EXPENSIVE
] == "" } {
318 set go_execute_args
64
319 } elseif
{ ![is_remote host
] && ![is_remote target
] } {
320 # When using low ulimit
-u
limit, use maximum of
321 # a quarter of that
limit and
10000 even when running expensive
322 # tests
, otherwise parallel tests might fail after fork failures.
323 set nproc
[lindex
[remote_exec host
{sh
-c ulimit\
-u
}] 1]
324 if { [string is
integer -strict $nproc
] } {
325 set nproc
[expr $nproc
/ 4]
326 if { $nproc
> 10000 } { set nproc
10000 }
327 if { $nproc
< 16 } { set nproc
16 }
328 set go_execute_args $nproc
331 if { "$go_execute_args" != "" } {
332 verbose
-log "$test: go_execute_args is $go_execute_args"
336 if { $test_line
== "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
337 && $test_line2
== "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
338 #
64bit.go is a special case.
339 set go_execute_args
""
340 set hold_runtests $runtests
341 set runtests
"go-test.exp"
342 set dg
-do-what
-default
"link"
343 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
344 set output_file
"./[file rootname [file tail $test]].exe"
345 set base
"[file rootname [file tail $test]]"
347 if { [catch
"exec $output_file >$base-out.go"] != 0 } {
348 fail
"$name execution"
350 pass
"$name execution"
351 file
delete $base
-out.x
352 go
-torture
-execute "./$base-out.go"
354 file
delete $base
-out.go
356 file
delete $output_file
357 set runtests $hold_runtests
358 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
359 || $test_line
== "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
360 || $test_line
== "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
361 || $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
363 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
366 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
369 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
372 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
375 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
377 # This is a vanilla execution test.
378 go
-torture
-execute $test
379 file
delete core
[glob
-nocomplain core.
*]
380 } elseif
{ [string match \
381 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
383 ||
[string match
"// \$G \$F.go && \$L \$F.\$A #*" \
385 || $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A" } {
386 # This is a vanilla
compile and link test.
387 set dg
-do-what
-default
"link"
388 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
389 } elseif
{ [string match
"// \$G \$D/\$F.go" $test_line] \
390 ||
[string match
"// \$G \$D/\$F.go || echo BUG*" \
392 ||
[string match
"// \$G \$F.go || echo BUG*" \
394 ||
[string match
"// ! \$G \$D/\$F.go && echo BUG*" \
396 # This is a vanilla
compile test.
397 set dg
-do-what
-default
"assemble"
398 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
399 } elseif
{ [string match
"// \$G \$D/\$F.go && echo BUG*" \
401 || $test_line
== "// ! \$G \$D/\$F.go >/dev/null" \
402 || $test_line
== "// ! \$G \$D/\$F.go" \
403 || $test_line
== "// ! \$G \$F.go" \
404 ||
[string match
"// ! \$G \$D/\$F.go || echo BUG*" \
406 # This is a
compile test which should fail.
407 set dg
-do-what
-default
"assemble"
409 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
410 } elseif
{ [string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
412 ||
[string match
"// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
414 ||
[string match
"// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
416 ||
($test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&"
417 && $test_line2
== "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
418 go
-execute-xfail $test
419 } elseif
{ [string match
"// errchk \$G \$F.go" $test_line] \
420 ||
[string match
"// errchk \$G -e \$F.go" $test_line] \
421 ||
[string match
"// errchk \$G \$D/\$F.go" $test_line] \
422 ||
[string match
"//errchk \$G \$D/\$F.go" $test_line] \
423 ||
[string match
"// errchk \$G -e \$D/\$F.go" \
425 ||
[string match
"// ! errchk \$G \$D/\$F.go" $test_line] \
426 ||
[string match
"// ! errchk \$G -e \$D/\$F.go" \
428 ||
[string match
"// errchk \$G \$F.go || true" \
430 ||
[string match
"// errchk \$G \$D/\$F.go || true" \
432 ||
[string match
"// errchk \$G -e \$D/\$F.go || true" \
434 ||
[string match
"// errchk \$G \$D/\$F.go || echo BUG*" \
437 } elseif
{ [string match \
438 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
440 set hold_runtests $runtests
441 set runtests
"go-test.exp"
442 set dg
-do-what
-default
"assemble"
443 regsub
"\\.go$" $test ".dir/bug0.go" file1
444 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
445 regsub
"\\.go$" $test ".dir/bug1.go" file2
446 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
447 file
delete "[file rootname [file tail $file1]].o"
448 set runtests $hold_runtests
449 } elseif
{ [string match \
450 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
453 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
456 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
464 set hold_runtests $runtests
465 set runtests
"go-test.exp"
466 set dg
-do-what
-default
"assemble"
467 regsub
"\\.go$" $test ".dir/$name1" file1
468 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
469 regsub
"\\.go$" $test ".dir/$name2" file2
471 file
delete "[file rootname [file tail $file1]].o"
472 set runtests $hold_runtests
473 } elseif
{ [string match \
474 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
476 set hold_runtests $runtests
477 set runtests
"go-test.exp"
478 set dg
-do-what
-default
"assemble"
479 regsub
"\\.go$" $test ".dir/bug0.go" file1
480 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
481 regsub
"\\.go$" $test ".dir/bug1.go" file2
483 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
484 file
delete "[file rootname [file tail $file1]].o"
485 set runtests $hold_runtests
486 } elseif
{ [string match \
487 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
489 set hold_runtests $runtests
490 set runtests
"go-test.exp"
491 set dg
-do-what
-default
"assemble"
492 regsub
"\\.go$" $test ".dir/bug0.go" file1
493 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
494 regsub
"\\.go$" $test ".dir/bug1.go" file2
495 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
496 regsub
"\\.go$" $test ".dir/bug2.go" file3
498 dg
-test $file3
"-O" "-w $DEFAULT_GOCFLAGS"
499 file
delete "[file rootname [file tail $file1]].o"
500 file
delete "[file rootname [file tail $file2]].o"
501 set runtests $hold_runtests
502 } elseif
{ [string match \
503 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
505 set hold_runtests $runtests
506 set runtests
"go-test.exp"
507 set dg
-do-what
-default
"assemble"
508 regsub
"\\.go$" $test ".dir/bug0.go" file1
509 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
510 regsub
"\\.go$" $test ".dir/bug1.go" file2
511 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
512 regsub
"\\.go$" $test ".dir/bug2.go" file3
514 file
delete "[file rootname [file tail $file1]].o"
515 file
delete "[file rootname [file tail $file2]].o"
516 set runtests $hold_runtests
517 } elseif
{ [string match \
518 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
520 set hold_runtests $runtests
521 set runtests
"go-test.exp"
522 set dg
-do-what
-default
"assemble"
523 regsub
"\\.go$" $test ".dir/x.go" file1
524 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
525 set ofile1
"[file rootname [file tail $file1]].o"
526 regsub
"\\.go$" $test ".dir/y.go" file2
527 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
528 set ofile2
"[file rootname [file tail $file2]].o"
529 set dg
-do-what
-default
"link"
530 set output_file
"./[file rootname [file tail $test]].exe"
531 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
532 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
533 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
534 verbose
-log $comp_output
535 set result
[go_load
"$output_file" "" ""]
536 set status [lindex $result
0]
538 file
delete $ofile1 $ofile2 $output_file
539 set runtests $hold_runtests
540 } elseif
{ [string match \
541 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
543 set hold_runtests $runtests
544 set runtests
"go-test.exp"
545 set dg
-do-what
-default
"assemble"
546 regsub
"\\.go$" $test ".dir/a.go" file1
547 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
548 set ofile1
"[file rootname [file tail $file1]].o"
549 regsub
"\\.go$" $test ".dir/b.go" file2
550 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
551 set ofile2
"[file rootname [file tail $file2]].o"
552 dg
-test
-keep
-output
"$test" "-O" "-w $DEFAULT_GOCFLAGS"
553 set ofile3
"[file rootname [file tail $test]].o"
554 set dg
-do-what
-default
"link"
555 set output_file
"./[file rootname [file tail $test]].exe"
556 set comp_output
[go_target_compile
"$ofile1 $ofile2 $ofile3" \
557 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
558 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
559 if [string match
"" $comp_output] {
562 verbose
-log $comp_output
565 file
delete $ofile1 $ofile2 $ofile3 $output_file
566 set runtests $hold_runtests
567 } elseif
{ [string match \
568 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
570 set hold_runtests $runtests
571 set runtests
"go-test.exp"
572 set dg
-do-what
-default
"assemble"
573 regsub
"/\[^/\]*$" $test "/embed0.go" file1
574 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
575 set ofile1
"[file rootname [file tail $file1]].o"
576 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
577 set ofile2
"[file rootname [file tail $test]].o"
578 set output_file
"./[file rootname [file tail $test]].exe"
579 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
580 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
581 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
582 if [string match
"" $comp_output] {
583 set result
[go_load
"$output_file" "" ""]
584 set status [lindex $result
0]
587 verbose
-log $comp_output
590 file
delete $ofile1 $ofile2 $output_file
591 set runtests $hold_runtests
592 } elseif
{ [string match \
593 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
595 set hold_runtests $runtests
596 set runtests
"go-test.exp"
597 set dg
-do-what
-default
"assemble"
598 regsub
"\\.go$" $test ".dir/lib.go" file1
599 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
600 set ofile1
"[file rootname [file tail $file1]].o"
601 regsub
"\\.go$" $test ".dir/main.go" file2
602 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
603 set ofile2
"[file rootname [file tail $file2]].o"
604 set dg
-do-what
-default
"link"
605 set output_file
"./[file rootname [file tail $file2]].exe"
606 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
607 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
608 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
609 if [string match
"" $comp_output] {
610 set result
[go_load
"$output_file" "" ""]
611 set status [lindex $result
0]
614 verbose
-log $comp_output
617 file
delete $ofile1 $ofile2 $output_file
618 set runtests $hold_runtests
619 } elseif
{ [string match \
620 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
622 set hold_runtests $runtests
623 set runtests
"go-test.exp"
624 set dg
-do-what
-default
"assemble"
625 regsub
"\\.go$" $test ".dir/chanbug.go" file1
626 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
627 regsub
"\\.go$" $test ".dir/chanbug2.go" file2
628 dg
-test $file2
"-O" "-w $DEFAULT_GOCFLAGS"
629 file
delete "[file rootname [file tail $file1]].o"
630 set runtests $hold_runtests
631 } elseif
{ [string match \
632 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
634 set dg
-do-what
-default
"assemble"
636 go
-dg
-runtest $test
"-w $DEFAULT_GOCFLAGS"
637 } elseif
{ [string match \
638 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
640 set hold_runtests $runtests
641 set runtests
"go-test.exp"
642 set dg
-do-what
-default
"assemble"
643 regsub
"\\.go$" $test ".dir/x.go" file1
644 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
645 regsub
"\\.go$" $test ".dir/y.go" file2
647 file
delete "[file rootname [file tail $file1]].o"
648 set runtests $hold_runtests
649 } elseif
{ [string match
"// true*" $test_line] } {
650 # Not a real test
, just ignore.
651 } elseif
{ $test_line
== "// \$G \$D/\$F.dir/bug0.go &&" \
652 && $test_line2
== "// \$G \$D/\$F.dir/bug1.go &&" \
653 && $test_line3
== "// \$G \$D/\$F.dir/bug2.go &&" \
654 && $test_line4
== "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
655 && $test_line5
== "// \$L bug2.\$A &&" \
656 && [string match
"// ./\$A.out || echo BUG*" $test_line6] } {
657 set hold_runtests $runtests
658 set runtests
"go-test.exp"
659 set dg
-do-what
-default
"assemble"
660 regsub
"\\.go$" $test ".dir/bug0.go" file0
661 dg
-test
-keep
-output $file0
"-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
662 set ofile0
"[file rootname [file tail $file0]].o"
663 regsub
"\\.go$" $test ".dir/bug1.go" file1
664 dg
-test
-keep
-output $file1
"-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
665 set ofile1
"[file rootname [file tail $file1]].o"
666 regsub
"\\.go$" $test ".dir/bug2.go" file2
667 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
668 set ofile2
"[file rootname [file tail $file2]].o"
669 regsub
"\\.go$" $test ".dir/bug3.go" file3
671 set output_file
"./[file rootname [file tail $test]].exe"
672 set comp_output
[go_target_compile
"$ofile0 $ofile1 $ofile2" \
673 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
674 set comp
-output
[go
-dg
-prune $target_triplet $comp_output
]
675 if [string match
"" $comp_output] {
676 set result
[go_load
"$output_file" "" ""]
677 set status [lindex $result
0]
680 verbose
-log $comp_output
683 file
delete $ofile0 $ofile1 $ofile2 $output_file
684 set runtests $hold_runtests
685 } elseif
{ $test_line
== "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
686 set hold_runtests $runtests
687 set runtests
"go-test.exp"
688 set dg
-do-what
-default
"assemble"
689 regsub
"/\[^/\]*$" $test "/import2.go" file1
690 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
691 set ofile1
"[file rootname [file tail $file1]].o"
692 dg
-test $test
"-O" "-w $DEFAULT_GOCFLAGS"
694 set runtests $hold_runtests
695 } elseif
{ $test_line
== "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
696 set hold_runtests $runtests
697 set runtests
"go-test.exp"
698 set dg
-do-what
-default
"assemble"
699 regsub
"/\[^/\]*$" $test "/ddd2.go" file1
700 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
701 set ofile1
"[file rootname [file tail $file1]].o"
702 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
703 set ofile2
"[file rootname [file tail $test]].o"
704 set output_file
"./[file rootname [file tail $test]].exe"
705 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
706 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
707 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
708 if [string match
"" $comp_output] {
709 set result
[go_load
"$output_file" "" ""]
710 set status [lindex $result
0]
713 verbose
-log $comp_output
716 file
delete $ofile1 $ofile2 $output_file
717 set runtests $hold_runtests
718 } elseif
{ $test_line
== "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
719 regsub
"/\[^/\]*$" $test "/cmplxdivide1.go" test2
720 set output_file
"./[file rootname [file tail $test]].o"
721 set comp_output
[go_target_compile
"$test $test2" \
722 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
723 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
724 if [string match
"" $comp_output] {
725 set result
[go_load
"$output_file" "" ""]
726 set status [lindex $result
0]
729 verbose
-log $comp_output
732 file
delete $output_file
733 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
734 && $test_line2
== "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
735 && $test_line3
== "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
736 && $test_line4
== "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
737 set go_execute_args
""
738 set hold_runtests $runtests
739 set runtests
"go-test.exp"
740 set dg
-do-what
-default
"link"
741 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
742 set output_file
"./[file rootname [file tail $test]].exe"
744 if { [catch
"exec $output_file -pass 0 >tmp.go"] != 0 } {
745 fail
"$name execution 0"
747 pass
"$name execution 0"
749 go
-torture
-execute "./tmp.go"
751 if { [catch
"exec $output_file -pass 1 >tmp.go"] != 0 } {
752 fail
"$name execution 1"
754 pass
"$name execution 1"
757 if { [catch
"exec $output_file -pass 2 >tmp.go"] != 0 } {
758 fail
"$name execution 2"
760 pass
"$name execution 2"
765 file
delete $output_file
766 set runtests $hold_runtests
767 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
768 && $test_line2
== "// errchk \$G -e tmp.go" } {
769 set go_execute_args
""
770 set hold_runtests $runtests
771 set runtests
"go-test.exp"
772 set dg
-do-what
-default
"link"
773 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
774 set output_file
"./[file rootname [file tail $test]].exe"
776 if { [catch
"exec $output_file >tmp.go"] != 0 } {
777 fail
"$name execution"
779 pass
"$name execution"
784 file
delete $output_file
785 set runtests $hold_runtests
786 } elseif
{ [string match \
787 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
789 set hold_runtests $runtests
790 set runtests
"go-test.exp"
791 set dg
-do-what
-default
"assemble"
792 regsub
"\\.go$" $test ".dir/p.go" file1
793 dg
-test
-keep
-output $file1
"-O" "-w $DEFAULT_GOCFLAGS"
794 set ofile1
"[file rootname [file tail $file1]].o"
795 regsub
"\\.go$" $test ".dir/main.go" file2
796 dg
-test
-keep
-output $file2
"-O" "-w $DEFAULT_GOCFLAGS"
797 set ofile2
"[file rootname [file tail $file2]].o"
798 set output_file
"./[file rootname [file tail $test]].exe"
799 set comp_output
[go_target_compile
"$ofile1 $ofile2" \
800 $output_file
"executable" "$DEFAULT_GOCFLAGS"]
801 set comp_output
[go
-dg
-prune $target_triplet $comp_output
]
802 if [string match
"" $comp_output] {
804 set result
[go_load
"$output_file" "" ""]
805 set status [lindex $result
0]
808 verbose
-log $comp_output
811 file
delete $ofile1 $ofile2 $output_file
812 set runtests $hold_runtests
813 } elseif
{ $test_line
== "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
814 && $test_line2
== "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
815 set go_execute_args
""
816 set hold_runtests $runtests
817 set runtests
"go-test.exp"
818 set dg
-do-what
-default
"link"
819 dg
-test
-keep
-output $test
"-O" "-w $DEFAULT_GOCFLAGS"
820 set output_file
"./[file rootname [file tail $test]].exe"
821 set base
"[file rootname [file tail $test]]"
823 if { [catch
"exec $output_file > $base-out.go"] != 0 } {
824 fail
"$name execution"
826 pass
"$name execution"
827 file
delete $base
-out.x
828 go
-torture
-execute "./$base-out.go"
830 # file
delete $base
-out.go
832 file
delete $output_file
833 set runtests $hold_runtests
834 } elseif
{ $test_line
== "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
835 regsub
"\\.go$" $test ".dir/a.go" file1
836 regsub
"\\.go$" $test ".dir/b.go" file2
837 errchk
"$file1" "$file2"
838 } elseif
{ $test_line
== "// # generated by cmplxdivide.c" } {
840 } elseif
{ $test_line
== "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
841 || $test_line
== "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
842 # These tests
import the same package under two different
843 # names
, which gccgo does not support.
844 } elseif
{ $test_line
== "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo FAIL || true" } {
845 # This tests whether initializers are written out
846 # statically. gccgo does not provide a way to test that
,
847 # as an initializer will be generated
for any code which
848 # has global variables which need to be registered as GC
851 clone_output
"$name: unrecognized test line: $test_line"
855 set go_execute_args
""
858 set dg
-do-what
-default $
{saved
-dg
-do-what
-default
}
859 set TORTURE_OPTIONS $saved_torture_options