* go.test/go-test.exp (go-gc-tests): Pass correctly formatted
[official-gcc.git] / gcc / testsuite / go.test / go-test.exp
blob28b7e40deb51bbc126ee9329152a5303a426b150
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
34 load_lib go-dg.exp
35 load_lib go-torture.exp
37 # Implement errchk
38 proc errchk { test opts } {
39 global dg-do-what-default
40 global DEFAULT_GOCFLAGS
41 global runtests
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
56 continue
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
90 puts $fdout $out_line
92 close $fdin
93 close $fdout
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
107 global runtests
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
116 close $fdin
117 close $fdout
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 {
132 "alpha*-*-*" {
133 set goarch "alpha"
135 "arm*-*-*" -
136 "ep9312*-*-*" -
137 "strongarm*-*-*" -
138 "xscale-*-*" {
139 set goarch "arm"
141 "i?86-*-*" -
142 "x86_64-*-*" {
143 if [check_effective_target_ia32] {
144 set goarch "386"
145 } else {
146 set goarch "amd64"
149 "mips*-*-*" {
150 if [check_no_compiler_messages mipso32 assembly {
151 #if _MIPS_SIM != _ABIO32
152 #error FOO
153 #endif
154 }] {
155 set goarch "mipso32"
156 } elseif [check_no_compiler_messages mipsn32 assembly {
157 #if _MIPS_SIM != _ABIN32
158 #error FOO
159 #endif
160 }] {
161 set goarch "mipsn32"
162 } elseif [check_no_compiler_messages mipsn64 assembly {
163 #if _MIPS_SIM != _ABI64
164 #error FOO
165 #endif
166 }] {
167 set goarch "mipsn64"
168 } elseif [check_no_compiler_messages mipso64 assembly {
169 #if _MIPS_SIM != _ABIO64
170 #error FOO
171 #endif
172 }] {
173 set goarch "mipso64"
174 } else {
175 perror "$target_triplet: unrecognized MIPS ABI"
176 return ""
179 "sparc*-*-*" {
180 if [check_effective_target_ilp32] {
181 set goarch "sparc"
182 } else {
183 set goarch "sparc64"
186 default {
187 perror "$target_triplet: unhandled architecture"
188 return ""
191 verbose -log "Setting GOARCH=$goarch" 1
192 setenv GOARCH $goarch
195 proc go-gc-tests { } {
196 global srcdir subdir
197 global runtests
198 global GCC_UNDER_TEST
199 global TOOL_OPTIONS
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"
211 set options ""
212 lappend options "additional_flags=$DEFAULT_GOCFLAGS"
214 # Set GOARCH for tests that need it.
215 go-set-goarch
217 # Running all the torture options takes too long and, since the
218 # frontend ignores the standard options, it doesn't significantly
219 # improve testing.
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}
225 set testdir [pwd]
227 set tests [lsort [find $srcdir/$subdir *.go]]
228 foreach test $tests {
229 if ![runtest_file_p $runtests $test] {
230 continue
233 # Skip the files in bench and garbage; they are not tests.
234 if [string match "*go.test/test/bench/*" $test] {
235 continue
237 if [string match "*go.test/test/garbage/*" $test] {
238 continue
241 # Skip files in sub-subdirectories: they are components of
242 # other tests.
243 if [string match "*go.test/test/*/*/*" $test] {
244 continue
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" \
252 $test] \
253 || [string match "*go.test/test/env.go" \
254 $test] } {
255 untested "$name: uses the command-line or environment variables"
256 continue
259 if { [string match "*go.test/test/stack.go" \
260 $test] \
261 || [string match "*go.test/test/peano.go" \
262 $test] \
263 || [string match "*go.test/test/chan/goroutines.go" \
264 $test] } {
265 untested "$name: has very high memory requirement"
266 continue
270 if { [string match "*bug347*" $test] \
271 || [string match "*bug348*" $test] } {
272 # These bugs rely on runtime.Caller which currently fails.
273 untested $name
274 continue
277 set fd [open $test r]
279 set lines_ok 1
281 while 1 {
282 if { [gets $fd test_line] < 0 } {
283 close $fd
284 clone_output "$test: could not read first line"
285 unresolved $name
286 set lines_ok 0
287 break
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 ] } {
294 continue
297 break
300 if { $lines_ok == 0 } {
301 continue
304 set lineno 1
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 } {
310 close $fd
311 clone_output "$test: could not read line $lineno"
312 unresolved $name
313 set lines_ok 0
314 break
317 if { $lines_ok == 0 } {
318 continue
321 close $fd
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
332 # for many OSes.
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]]"
362 if [isnative] {
363 if { [catch "exec $output_file >$base-out.go"] != 0 } {
364 fail "$name execution"
365 } else {
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" \
378 || [string match \
379 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
380 $test_line]
381 || [string match \
382 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
383 $test_line]
384 || [string match \
385 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
386 $test_line]
387 || [string match \
388 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
389 $test_line]
390 || [string match \
391 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
392 $test_line] } {
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*" \
398 $test_line] \
399 || [string match "// \$G \$F.go && \$L \$F.\$A #*" \
400 $test_line]
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*" \
407 $test_line] \
408 || [string match "// \$G \$F.go || echo BUG*" \
409 $test_line] \
410 || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
411 $test_line] } {
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*" \
416 $test_line] \
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*" \
421 $test_line] } {
422 # This is a compile test which should fail.
423 set dg-do-what-default "assemble"
424 setup_xfail "*-*-*"
425 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
426 } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
427 $test_line] \
428 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
429 $test_line] \
430 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
431 $test_line] \
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" \
440 $test_line] \
441 || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
442 || [string match "// ! errchk \$G -e \$D/\$F.go" \
443 $test_line] \
444 || [string match "// errchk \$G \$F.go || true" \
445 $test_line] \
446 || [string match "// errchk \$G \$D/\$F.go || true" \
447 $test_line] \
448 || [string match "// errchk \$G -e \$D/\$F.go || true" \
449 $test_line] \
450 || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
451 $test_line] } {
452 errchk $test ""
453 } elseif { [string match \
454 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
455 $test_line] } {
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" \
467 $test_line] \
468 || [string match \
469 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
470 $test_line] \
471 || [string match \
472 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
473 $test_line] \
474 || [string match \
475 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
476 $test_line] } {
477 if { [string match \
478 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
479 $test_line] } {
480 set name1 "bug0.go"
481 set name2 "bug1.go"
482 } elseif { [string match \
483 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
484 $test_line] } {
485 set name1 "p1.go"
486 set name2 "p2.go"
487 } elseif { [string match \
488 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
489 $test_line] } {
490 set name1 "b.go"
491 set name2 "a.go"
492 } elseif { [string match \
493 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
494 $test_line] } {
495 set name1 "io.go"
496 set name2 "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
504 errchk $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" \
509 $test_line ] } {
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"
515 errchk $test ""
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*" \
520 $test_line] } {
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
527 setup_xfail "*-*-*"
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*" \
533 $test_line] } {
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
542 setup_xfail "*-*-*"
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" \
549 $test_line] } {
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
558 errchk $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" \
564 $test_line] \
565 || [string match \
566 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
567 $test_line] } {
568 if { [string match \
569 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
570 $test_line] } {
571 set name1 "x.go"
572 set name2 "y.go"
573 } elseif { [string match \
574 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
575 $test_line] } {
576 set name1 "p.go"
577 set name2 "main.go"
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]
596 $status $name
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" \
601 $test_line] } {
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] {
619 pass $name
620 } else {
621 verbose -log $comp_output
622 fail $name
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" \
628 $test_line ] } {
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]
644 $status $name
645 } else {
646 verbose -log $comp_output
647 fail $name
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*" \
653 $test_line ] } {
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]
671 $status $name
672 } else {
673 verbose -log $comp_output
674 fail $name
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" \
680 $test_line] } {
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' *" \
692 $test_line] } {
693 set dg-do-what-default "assemble"
694 setup_xfail "*-*-*"
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" \
698 $test_line] } {
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
705 errchk $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
729 errchk $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]
737 $status $name
738 } else {
739 verbose -log $comp_output
740 fail $name
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"
752 file delete $ofile1
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]
770 $status $name
771 } else {
772 verbose -log $comp_output
773 fail $name
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]
786 $status $name
787 } else {
788 verbose -log $comp_output
789 fail $name
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"
802 if [isnative] {
803 if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
804 fail "$name execution 0"
805 } else {
806 pass "$name execution 0"
807 file delete tmp.x
808 go-torture-execute "./tmp.go"
810 if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
811 fail "$name execution 1"
812 } else {
813 pass "$name execution 1"
814 errchk tmp.go ""
816 if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
817 fail "$name execution 2"
818 } else {
819 pass "$name execution 2"
820 errchk tmp.go ""
822 file delete tmp.go
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"
834 if [isnative] {
835 if { [catch "exec $output_file >tmp.go"] != 0 } {
836 fail "$name execution"
837 } else {
838 pass "$name execution"
839 file delete tmp.x
840 errchk tmp.go ""
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*" \
847 $test_line] } {
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] {
862 setup_xfail "*-*-*"
863 set result [go_load "$output_file" "" ""]
864 set status [lindex $result 0]
865 $status $name
866 } else {
867 verbose -log $comp_output
868 fail $name
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]]"
881 if [isnative] {
882 if { [catch "exec $output_file > $base-out.go"] != 0 } {
883 fail "$name execution"
884 } else {
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" } {
898 # Ignore.
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
908 # roots.
909 } else {
910 clone_output "$name: unrecognized test line: $test_line"
911 unsupported $name
914 set go_execute_args ""
917 set dg-do-what-default ${saved-dg-do-what-default}
918 set TORTURE_OPTIONS $saved_torture_options
921 go-gc-tests