OSDN Git Service

* go.test/go-test.exp (go-gc-tests): xfail test/nilptr.go runtime
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / go-test.exp
1 #   Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
2 #   Written by Ian Lance Taylor <iant@google.com>.
3
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.
8 #
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.
13 #
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/>.
17
18
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.
27 #
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
33
34 load_lib go-dg.exp
35 load_lib go-torture.exp
36
37 # Compare two files
38 proc filecmp { file1 file2 testname } {
39     set f1 [open $file1 r]
40     set f2 [open $file2 r]
41     set ok 1
42     while { [gets $f1 line1] >= 0 } {
43         if { [gets $f2 line2] < 0 } {
44             verbose -log "output mismatch: $file2 shorter than $file1"
45             set ok 0
46             break
47         }
48         if { $line1 != $line2 } {
49             verbose -log "output mismatch comparing $file1 and $file2"
50             verbose -log "expected \"$line1\""
51             verbose -log "got      \"$line2\""
52             set ok 0
53             break
54         }
55     }
56     if { [gets $f2 line2] >= 0 } {
57         verbose -log "output mismatch: $file1 shorter than $file2"
58         set ok 0
59     }
60     close $f1
61     close $f2
62     if { ! $ok } {
63         fail $testname
64     } else {
65         pass $testname
66     }
67 }
68
69 # Implement errchk
70 proc errchk { test opts } {
71     global dg-do-what-default
72     global DEFAULT_GOCFLAGS
73     global runtests
74
75     set saved-dg-do-what-default ${dg-do-what-default}
76     set dg-do-what-default compile
77     set filename [file tail $test]
78     if { "$filename" == "$test" } {
79         set filename "errchk-$filename"
80     }
81     set fdin [open $test r]
82     fconfigure $fdin -encoding binary
83     set fdout [open $filename w]
84     fconfigure $fdout -encoding binary
85     while { [gets $fdin copy_line] >= 0 } {
86         if [string match "*////*" $copy_line] {
87             puts $fdout $copy_line
88             continue
89         }
90         regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
91         if [string match "*dg-error*\\\[*" $out_line] {
92             set index [string first "dg-error" $out_line]
93             regsub -start $index -all "\\\\\\\[" $out_line "\\\\\\\\\\\[" out_line
94         }
95         if [string match "*dg-error*\\\]*" $out_line] {
96             set index [string first "dg-error" $out_line]
97             regsub -start $index -all "\\\\\\\]" $out_line "\\\\\\\\\\\]" out_line
98         }
99         if [string match "*dg-error*.\**" $out_line] {
100             # I worked out the right number of backslashes by
101             # experimentation, not analysis.
102             regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
103         }
104         if [string match "*dg-error*\\\[?\\\]*" $out_line] {
105             set index [string first "dg-error" $out_line]
106             regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
107         }
108         if [string match "*dg-error*\{*" $out_line] {
109             set index [string first "dg-error" $out_line]
110             regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
111         }
112         if [string match "*dg-error*\}*\}" $out_line] {
113             set index [string first "dg-error" $out_line]
114             regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
115         }
116         if [string match "*dg-error*\(*" $out_line] {
117             set index [string first "dg-error" $out_line]
118             regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
119         }
120         if [string match "*dg-error*\)*\}" $out_line] {
121             set index [string first "dg-error" $out_line]
122             regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
123         }
124         # Special case for bug332, in which the error message wants to
125         # match the file name, which is not what dg-error expects.
126         if [string match "*dg-error*bug332*" $out_line] {
127             set index [string first "dg-error" $out_line]
128             regsub -start $index "bug332" $out_line "undefined type" out_line
129         }
130         puts $fdout $out_line
131     }
132     close $fdin
133     close $fdout
134
135     set hold_runtests $runtests
136     set runtests "go-test.exp"
137     go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
138     set runtests $hold_runtests
139
140     file delete $filename
141     set dg-do-what-default ${saved-dg-do-what-default}
142 }
143
144 # This is an execution test which should fail.
145 proc go-execute-xfail { test } {
146     global DEFAULT_GOCFLAGS
147     global runtests
148
149     set filename [file tail $test]
150     set fdin [open $test r]
151     set fdout [open $filename w]
152     puts $fdout "// { dg-do run { xfail *-*-* } }"
153     while { [gets $fdin copy_line] >= 0 } {
154         puts $fdout $copy_line
155     }
156     close $fdin
157     close $fdout
158
159     set hold_runtests $runtests
160     set runtests "go-test.exp"
161     go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
162     set runtests $hold_runtests
163
164     file delete $filename
165 }
166
167 # N.B. Keep in sync with libgo/configure.ac.
168 proc go-set-goarch { } {
169     global target_triplet
170
171     switch -glob $target_triplet {
172         "alpha*-*-*" {
173             set goarch "alpha"
174         }
175         "arm*-*-*" -
176         "ep9312*-*-*" -
177         "strongarm*-*-*" -
178         "xscale-*-*" {
179             set goarch "arm"
180         }
181         "i?86-*-*" -
182         "x86_64-*-*" {
183             if [check_effective_target_ia32] {
184                 set goarch "386"
185             } else {
186                 set goarch "amd64"
187             }
188         }
189         "mips*-*-*" {
190             if [check_no_compiler_messages mipso32 assembly {
191                 #if _MIPS_SIM != _ABIO32
192                 #error FOO
193                 #endif
194             }] {
195                 set goarch "mipso32"
196             } elseif [check_no_compiler_messages mipsn32 assembly {
197                 #if _MIPS_SIM != _ABIN32
198                 #error FOO
199                 #endif
200             }] {
201                 set goarch "mipsn32"
202             } elseif [check_no_compiler_messages mipsn64 assembly {
203                 #if _MIPS_SIM != _ABI64
204                 #error FOO
205                 #endif
206             }] {
207                 set goarch "mipsn64"
208             } elseif [check_no_compiler_messages mipso64 assembly {
209                 #if _MIPS_SIM != _ABIO64
210                 #error FOO
211                 #endif
212             }] {
213                 set goarch "mipso64"
214             } else {
215                 perror "$target_triplet: unrecognized MIPS ABI"
216                 return ""
217             }
218         }
219         "sparc*-*-*" {
220             if [check_effective_target_ilp32] {
221                 set goarch "sparc"
222             } else {
223                 set goarch "sparc64"
224             }
225         }
226         default {
227             perror "$target_triplet: unhandled architecture"
228             return ""
229         }       
230     }
231     verbose -log "Setting GOARCH=$goarch" 1
232     setenv GOARCH $goarch
233 }
234
235 proc go-gc-tests { } {
236     global srcdir subdir
237     global runtests
238     global GCC_UNDER_TEST
239     global TOOL_OPTIONS
240     global TORTURE_OPTIONS
241     global dg-do-what-default
242     global go_compile_args
243     global go_execute_args
244     global target_triplet
245
246     # If a testcase doesn't have special options, use these.
247     global DEFAULT_GOCFLAGS
248     if ![info exists DEFAULT_GOCFLAGS] {
249         set DEFAULT_GOCFLAGS " -pedantic-errors"
250     }
251
252     set options ""
253     lappend options "additional_flags=$DEFAULT_GOCFLAGS"
254
255     # Set GOARCH for tests that need it.
256     go-set-goarch
257
258     # Running all the torture options takes too long and, since the
259     # frontend ignores the standard options, it doesn't significantly
260     # improve testing.
261     set saved_torture_options $TORTURE_OPTIONS
262     set TORTURE_OPTIONS [ list { -O2 -g }]
263
264     set saved-dg-do-what-default ${dg-do-what-default}
265
266     set testdir [pwd]
267
268     set tests [lsort [find $srcdir/$subdir *.go]]
269     foreach test $tests {
270         if ![runtest_file_p $runtests $test] {
271             continue
272         }
273
274         # Skip the files in bench; they are not tests.
275         if [string match "*go.test/test/bench/*" $test] {
276             continue
277         }
278
279         # Skip files in sub-subdirectories: they are components of
280         # other tests.
281         if [string match "*go.test/test/*/*/*" $test] {
282             continue
283         }
284
285         set name [dg-trim-dirname $srcdir $test]
286
287         # Skip certain tests if target is RTEMS OS.
288         if [istarget "*-*-rtems*"] {
289             if { [string match "*go.test/test/args.go" $test] \
290                  || [string match "*go.test/test/env.go" $test] } {
291                     untested "$name: uses the command-line or environment variables"
292                     continue
293             }
294
295             if { [string match "*go.test/test/stack.go" $test] \
296                  || [string match "*go.test/test/peano.go" $test] \
297                  || [string match "*go.test/test/chan/goroutines.go" $test] } {
298                     untested "$name: has very high memory requirement"
299                     continue
300             }
301         }
302
303         # Handle certain tests in a target-dependant way.
304         if [istarget "alpha*-*-*"] {
305             if { [string match "*go.test/test/nilptr.go" $test] } {
306                 go-execute-xfail $test
307                 continue
308             }
309         }
310
311         if { [string match "*bug347*" $test] \
312                  || [string match "*bug348*" $test] } {
313             # These bugs rely on runtime.Caller which currently fails.
314             untested $name
315             continue
316         }
317
318         if { [file tail $test] == "init1.go" } {
319             # This tests whether GC runs during init, which for gccgo
320             # it currently does not.
321             untested $name
322             continue
323         }
324
325         if { [file tail $test] == "closure.go" } {
326             # This tests whether function closures do any memory
327             # allocation, which for gccgo they currently do.
328             untested $name
329             continue
330         }
331
332         set fd [open $test r]
333
334         set lines_ok 1
335
336         while 1 {
337             if { [gets $fd test_line] < 0 } {
338                 close $fd
339                 clone_output "$test: could not read first line"
340                 unresolved $name
341                 set lines_ok 0
342                 break
343             }
344
345             if { [ string match "*nacl*exit 0*" $test_line ] \
346                      || [ string match "*exit 0*nacl*" $test_line ] \
347                      || [ string match "*Android*exit 0*" $test_line ] \
348                      || [ string match "*exit 0*Android*" $test_line ] \
349                      || [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
350                 continue
351             }
352
353             break
354         }
355
356         if { $lines_ok == 0 } {
357             continue
358         }
359
360         set lineno 1
361         set test_line1 $test_line
362
363         while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
364             set lineno [expr $lineno + 1]
365             if { [eval "gets \$fd test_line$lineno"] < 0 } {
366                 close $fd
367                 clone_output "$test: could not read line $lineno"
368                 unresolved $name
369                 set lines_ok 0
370                 break
371             }
372         }
373         if { $lines_ok == 0 } {
374             continue
375         }
376
377         close $fd
378
379         set go_compile_args ""
380         set go_execute_args ""
381         if { [regexp ".*\\\$A.out (\[^|&>2\].*)\$" $test_line match progargs] } {
382             set go_execute_args $progargs
383             verbose -log "$test: go_execute_args is $go_execute_args"
384             set index [string last " $progargs" $test_line]
385             set test_line [string replace $test_line $index end]
386         } elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
387                    && [getenv GCCGO_RUN_ALL_TESTS] == "" } {
388             # goroutines.go spawns by default 10000 threads, which is too much
389             # for many OSes.
390             if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
391                 set go_execute_args 64
392             } elseif { ![is_remote host] && ![is_remote target] } {
393                 # When using low ulimit -u limit, use maximum of
394                 # a quarter of that limit and 10000 even when running expensive
395                 # tests, otherwise parallel tests might fail after fork failures.
396                 set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
397                 if { [string is integer -strict $nproc] } {
398                         set nproc [expr $nproc / 4]
399                         if { $nproc > 10000 } { set nproc 10000 }
400                         if { $nproc < 16 } { set nproc 16 }
401                         set go_execute_args $nproc
402                 }
403             }
404             if { "$go_execute_args" != "" } {
405                 verbose -log "$test: go_execute_args is $go_execute_args"
406             }
407         }
408
409         if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
410              && $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
411             # 64bit.go is a special case.
412             set go_execute_args ""
413             set hold_runtests $runtests
414             set runtests "go-test.exp"
415             set dg-do-what-default "link"
416             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
417             set output_file "./[file rootname [file tail $test]].exe"
418             set base "[file rootname [file tail $test]]"
419             if [isnative] {
420                 if { [catch "exec $output_file >$base-out.go"] != 0 } {
421                     fail "$name execution"
422                 } else {
423                     pass "$name execution"
424                     file delete $base-out.x
425                     go-torture-execute "./$base-out.go"
426                 }
427                 file delete $base-out.go
428             }
429             file delete $output_file
430             set runtests $hold_runtests
431         } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
432                    || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
433                    || $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
434                    || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
435                    || [string match \
436                            "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
437                            $test_line]
438                    || [string match \
439                            "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
440                            $test_line]
441                    || [string match \
442                            "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
443                            $test_line]
444                    || [string match \
445                            "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
446                            $test_line]
447                    || [string match \
448                            "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
449                            $test_line] } {
450             # This is a vanilla execution test.
451             go-torture-execute $test
452             file delete core [glob -nocomplain core.*]
453         } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
454                        || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
455                        || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
456             # This is an execution test for which we need to check the
457             # program output.
458             set hold_runtests $runtests
459             set runtests "go-test.exp"
460             set dg-do-what-default "link"
461             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
462             set output_file "./[file rootname [file tail $test]].exe"
463             set base "[file rootname [file tail $test]]"
464             if [isnative] {
465                 verbose -log "$output_file >$base.p 2>&1"
466                 if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } {
467                     verbose -log $catcherr
468                     fail "$name execution"
469                     untested "$name compare"
470                 } else {
471                     pass "$name execution"
472                     regsub "\\.go$" $test ".out" expect
473                     filecmp $expect $base.p "$name compare"
474                 }
475                 #file delete $base.p
476             } else {
477                 untested "$name execution"
478                 untested "$name compare"
479             }
480             set runtests $hold_runtests
481         } elseif { [string match \
482                         "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
483                         $test_line] \
484                    || [string match "// \$G \$F.go && \$L \$F.\$A  #*" \
485                            $test_line]
486                    || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
487             # This is a vanilla compile and link test.
488             set dg-do-what-default "link"
489             go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
490         } elseif { [string match "// \$G \$D/\$F.go" $test_line] \
491                    || [string match "// \$G \$D/\$F.go || echo BUG*" \
492                            $test_line] \
493                    || [string match "// \$G \$D/\$F.go || echo \"Bug*" \
494                            $test_line] \
495                    || [string match "// \$G \$D/\$F.go || echo \"Issue*" \
496                            $test_line] \
497                    || [string match "// \$G \$F.go || echo BUG*" \
498                            $test_line] \
499                    || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
500                            $test_line] \
501                    || $test_line == "// echo bug395 is broken  # takes 90+ seconds to break" } {
502             # This is a vanilla compile test.
503             set dg-do-what-default "assemble"
504             go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
505         } elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
506                         $test_line] \
507                    || $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
508                    || $test_line == "// ! \$G \$D/\$F.go" \
509                    || $test_line == "// ! \$G \$F.go" \
510                    || [string match "// ! \$G \$D/\$F.go || echo BUG*" \
511                         $test_line] } {
512             # This is a compile test which should fail.
513             set dg-do-what-default "assemble"
514             setup_xfail "*-*-*"
515             go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
516         } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
517                         $test_line] \
518                    || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
519                         $test_line] \
520                    || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
521                         $test_line] \
522                    || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
523                        && $test_line2 == "//    ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
524             go-execute-xfail $test
525         } elseif { [string match "// errchk \$G \$F.go" $test_line] \
526                     || [string match "// errchk \$G -e \$F.go" $test_line] \
527                     || [string match "// errchk \$G \$D/\$F.go" $test_line] \
528                     || [string match "//errchk \$G \$D/\$F.go" $test_line] \
529                     || [string match "// errchk \$G -e \$D/\$F.go" \
530                             $test_line] \
531                     || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
532                     || [string match "// ! errchk \$G -e \$D/\$F.go" \
533                             $test_line] \
534                     || [string match "// errchk \$G \$F.go || true" \
535                             $test_line] \
536                     || [string match "// errchk \$G \$D/\$F.go || true" \
537                             $test_line] \
538                     || [string match "// errchk \$G -e \$D/\$F.go || true" \
539                             $test_line] \
540                     || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
541                             $test_line] } {
542             errchk $test ""
543         } elseif { [string match \
544                         "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
545                         $test_line] \
546                        || [string match \
547                                "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
548                                $test_line] } {
549             if { [string match \
550                       "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
551                       $test_line] } {
552                 set name1 "bug0.go"
553                 set name2 "bug1.go"
554             } elseif { [string match \
555                             "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
556                             $test_line] } {
557                 set name1 "one.go"
558                 set name2 "two.go"
559             }
560             set hold_runtests $runtests
561             set runtests "go-test.exp"
562             set dg-do-what-default "assemble"
563             regsub "\\.go$" $test ".dir/$name1" file1
564             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
565             regsub "\\.go$" $test ".dir/$name2" file2
566             dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
567             file delete "[file rootname [file tail $file1]].o"
568             set runtests $hold_runtests
569         } elseif { [string match \
570                         "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
571                         $test_line] \
572                        || [string match \
573                                "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
574                                $test_line] \
575                        || [string match \
576                                "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
577                                $test_line] \
578                        || [string match \
579                                "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
580                                $test_line] } {
581             if { [string match \
582                       "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
583                       $test_line] } {
584                 set name1 "bug0.go"
585                 set name2 "bug1.go"
586             } elseif { [string match \
587                             "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
588                             $test_line] } {
589                 set name1 "p1.go"
590                 set name2 "p2.go"
591             } elseif { [string match \
592                             "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
593                             $test_line] } {
594                 set name1 "b.go"
595                 set name2 "a.go"
596             } elseif { [string match \
597                             "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
598                             $test_line] } {
599                 set name1 "io.go"
600                 set name2 "main.go"
601             }
602             set hold_runtests $runtests
603             set runtests "go-test.exp"
604             set dg-do-what-default "assemble"
605             regsub "\\.go$" $test ".dir/$name1" file1
606             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
607             regsub "\\.go$" $test ".dir/$name2" file2
608             errchk $file2 ""
609             file delete "[file rootname [file tail $file1]].o"
610             set runtests $hold_runtests
611         } elseif { [string match \
612                         "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
613                         $test_line ] } {
614             set hold_runtests $runtests
615             set runtests "go-test.exp"
616             set dg-do-what-default "assemble"
617             regsub "\\.go$" $test "1.go" file1
618             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
619             errchk $test ""
620             file delete "[file rootname [file tail $file1]].o"
621             set runtests $hold_runtests
622         } elseif { [string match \
623                         "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
624                         $test_line] } {
625             set hold_runtests $runtests
626             set runtests "go-test.exp"
627             set dg-do-what-default "assemble"
628             regsub "\\.go$" $test ".dir/bug0.go" file1
629             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
630             regsub "\\.go$" $test ".dir/bug1.go" file2
631             setup_xfail "*-*-*"
632             dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
633             file delete "[file rootname [file tail $file1]].o"
634             set runtests $hold_runtests
635         } elseif { [string match \
636                         "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
637                         $test_line] } {
638             set hold_runtests $runtests
639             set runtests "go-test.exp"
640             set dg-do-what-default "assemble"
641             regsub "\\.go$" $test ".dir/bug0.go" file1
642             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
643             regsub "\\.go$" $test ".dir/bug1.go" file2
644             dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
645             regsub "\\.go$" $test ".dir/bug2.go" file3
646             setup_xfail "*-*-*"
647             dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
648             file delete "[file rootname [file tail $file1]].o"
649             file delete "[file rootname [file tail $file2]].o"
650             set runtests $hold_runtests
651         } elseif { [string match \
652                         "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
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/bug0.go" file1
658             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
659             regsub "\\.go$" $test ".dir/bug1.go" file2
660             dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
661             regsub "\\.go$" $test ".dir/bug2.go" file3
662             errchk $file3 ""
663             file delete "[file rootname [file tail $file1]].o"
664             file delete "[file rootname [file tail $file2]].o"
665             set runtests $hold_runtests
666         } elseif { [string match \
667                         "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
668                         $test_line] \
669                        || [string match \
670                                "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
671                                $test_line] } {
672             if { [string match \
673                         "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
674                       $test_line] } {
675                 set name1 "x.go"
676                 set name2 "y.go"
677             } elseif { [string match \
678                            "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
679                             $test_line] } {
680                 set name1 "p.go"
681                 set name2 "main.go"
682             }
683             set hold_runtests $runtests
684             set runtests "go-test.exp"
685             set dg-do-what-default "assemble"
686             regsub "\\.go$" $test ".dir/$name1" file1
687             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
688             set ofile1 "[file rootname [file tail $file1]].o"
689             regsub "\\.go$" $test ".dir/$name2" file2
690             dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
691             set ofile2 "[file rootname [file tail $file2]].o"
692             set dg-do-what-default "link"
693             set output_file "./[file rootname [file tail $test]].exe"
694             set comp_output [go_target_compile "$ofile1 $ofile2" \
695                                  $output_file "executable" "$options"]
696             set comp_output [go-dg-prune $target_triplet $comp_output]
697             verbose -log $comp_output
698             set result [go_load "$output_file" "" ""]
699             set status [lindex $result 0]
700             $status $name
701             file delete $ofile1 $ofile2 $output_file
702             set runtests $hold_runtests
703         } elseif { [string match \
704                         "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
705                         $test_line] } {
706             set hold_runtests $runtests
707             set runtests "go-test.exp"
708             set dg-do-what-default "assemble"
709             regsub "\\.go$" $test ".dir/a.go" file1
710             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
711             set ofile1 "[file rootname [file tail $file1]].o"
712             regsub "\\.go$" $test ".dir/b.go" file2
713             dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
714             set ofile2 "[file rootname [file tail $file2]].o"
715             dg-test -keep-output "$test" "-O" "-w $DEFAULT_GOCFLAGS"
716             set ofile3 "[file rootname [file tail $test]].o"
717             set dg-do-what-default "link"
718             set output_file "./[file rootname [file tail $test]].exe"
719             set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
720                                  $output_file "executable" "$options"]
721             set comp_output [go-dg-prune $target_triplet $comp_output]
722             if [string match "" $comp_output] {
723                 pass $name
724             } else {
725                 verbose -log $comp_output
726                 fail $name
727             }
728             file delete $ofile1 $ofile2 $ofile3 $output_file
729             set runtests $hold_runtests
730         } elseif { [string match \
731                         "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
732                         $test_line ] } {
733             set hold_runtests $runtests
734             set runtests "go-test.exp"
735             set dg-do-what-default "assemble"
736             regsub "/\[^/\]*$" $test "/embed0.go" file1
737             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
738             set ofile1 "[file rootname [file tail $file1]].o"
739             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
740             set ofile2 "[file rootname [file tail $test]].o"
741             set output_file "./[file rootname [file tail $test]].exe"
742             set comp_output [go_target_compile "$ofile1 $ofile2" \
743                                  $output_file "executable" "$options"]
744             set comp_output [go-dg-prune $target_triplet $comp_output]
745             if [string match "" $comp_output] {
746                 set result [go_load "$output_file" "" ""]
747                 set status [lindex $result 0]
748                 $status $name
749             } else {
750                 verbose -log $comp_output
751                 fail $name
752             }
753             file delete $ofile1 $ofile2 $output_file
754             set runtests $hold_runtests
755         } elseif { [string match \
756                         "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
757                         $test_line ] || \
758                        [string match \
759                             "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
760                             $test_line ] } {
761             if { [string match \
762                       "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
763                       $test_line ] } {
764                 set name1 "lib.go"
765                 set name2 "main.go"
766             } elseif { [string match \
767                             "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
768                             $test_line ] } {
769                 set name1 "p.go"
770                 set name2 "main.go"
771             }
772             set hold_runtests $runtests
773             set runtests "go-test.exp"
774             set dg-do-what-default "assemble"
775             regsub "\\.go$" $test ".dir/$name1" file1
776             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
777             set ofile1 "[file rootname [file tail $file1]].o"
778             regsub "\\.go$" $test ".dir/$name2" file2
779             dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
780             set ofile2 "[file rootname [file tail $file2]].o"
781             set dg-do-what-default "link"
782             set output_file "./[file rootname [file tail $file2]].exe"
783             set comp_output [go_target_compile "$ofile1 $ofile2" \
784                                  $output_file "executable" "$options"]
785             set comp_output [go-dg-prune $target_triplet $comp_output]
786             if [string match "" $comp_output] {
787                 set result [go_load "$output_file" "" ""]
788                 set status [lindex $result 0]
789                 $status $name
790             } else {
791                 verbose -log $comp_output
792                 fail $name
793             }
794             file delete $ofile1 $ofile2 $output_file
795             set runtests $hold_runtests
796         } elseif { [string match \
797                         "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
798                         $test_line] } {
799             set hold_runtests $runtests
800             set runtests "go-test.exp"
801             set dg-do-what-default "assemble"
802             regsub "\\.go$" $test ".dir/chanbug.go" file1
803             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
804             regsub "\\.go$" $test ".dir/chanbug2.go" file2
805             dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
806             file delete "[file rootname [file tail $file1]].o"
807             set runtests $hold_runtests
808         } elseif { [string match \
809                         "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
810                         $test_line] } {
811             set dg-do-what-default "assemble"
812             setup_xfail "*-*-*"
813             go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
814         } elseif { [string match \
815                         "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
816                         $test_line] } {
817             set hold_runtests $runtests
818             set runtests "go-test.exp"
819             set dg-do-what-default "assemble"
820             regsub "\\.go$" $test ".dir/x.go" file1
821             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
822             regsub "\\.go$" $test ".dir/y.go" file2
823             errchk $file2 ""
824             file delete "[file rootname [file tail $file1]].o"
825             set runtests $hold_runtests
826         } elseif { "$test_line" == "" || [string match "// true*" $test_line] } {
827             # Not a real test, just ignore.
828         } elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
829                        && $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
830                        && $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
831                        && $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
832                        && $test_line5 == "// \$L bug2.\$A &&" \
833                        && [string match "// ./\$A.out || echo BUG*" $test_line6] } {
834             set hold_runtests $runtests
835             set runtests "go-test.exp"
836             set dg-do-what-default "assemble"
837             regsub "\\.go$" $test ".dir/bug0.go" file0
838             dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
839             set ofile0 "[file rootname [file tail $file0]].o"
840             regsub "\\.go$" $test ".dir/bug1.go" file1
841             dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
842             set ofile1 "[file rootname [file tail $file1]].o"
843             regsub "\\.go$" $test ".dir/bug2.go" file2
844             dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
845             set ofile2 "[file rootname [file tail $file2]].o"
846             regsub "\\.go$" $test ".dir/bug3.go" file3
847             errchk $file3 ""
848             set output_file "./[file rootname [file tail $test]].exe"
849             set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
850                                  $output_file "executable" "$options"]
851             set comp-output [go-dg-prune $target_triplet $comp_output]
852             if [string match "" $comp_output] {
853                 set result [go_load "$output_file" "" ""]
854                 set status [lindex $result 0]
855                 $status $name
856             } else {
857                 verbose -log $comp_output
858                 fail $name
859             }
860             file delete $ofile0 $ofile1 $ofile2 $output_file
861             set runtests $hold_runtests
862         } elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
863                        || $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
864             if { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
865                 set name1 "import2.go"
866             } elseif { $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
867                 set name1 "recursive1.go"
868             }
869             set hold_runtests $runtests
870             set runtests "go-test.exp"
871             set dg-do-what-default "assemble"
872             regsub "/\[^/\]*$" $test "/${name1}" file1
873             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
874             set ofile1 "[file rootname [file tail $file1]].o"
875             dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
876             file delete $ofile1
877             set runtests $hold_runtests
878         } elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
879             set hold_runtests $runtests
880             set runtests "go-test.exp"
881             set dg-do-what-default "assemble"
882             regsub "/\[^/\]*$" $test "/ddd2.go" file1
883             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
884             set ofile1 "[file rootname [file tail $file1]].o"
885             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
886             set ofile2 "[file rootname [file tail $test]].o"
887             set output_file "./[file rootname [file tail $test]].exe"
888             set comp_output [go_target_compile "$ofile1 $ofile2" \
889                                  $output_file "executable" "$options"]
890             set comp_output [go-dg-prune $target_triplet $comp_output]
891             if [string match "" $comp_output] {
892                 set result [go_load "$output_file" "" ""]
893                 set status [lindex $result 0]
894                 $status $name
895             } else {
896                 verbose -log $comp_output
897                 fail $name
898             }
899             file delete $ofile1 $ofile2 $output_file
900             set runtests $hold_runtests
901         } elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
902             regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
903             set output_file "./[file rootname [file tail $test]].o"
904             set comp_output [go_target_compile "$test $test2" \
905                                  $output_file "executable" "$options"]
906             set comp_output [go-dg-prune $target_triplet $comp_output]
907             if [string match "" $comp_output] {
908                 set result [go_load "$output_file" "" ""]
909                 set status [lindex $result 0]
910                 $status $name
911             } else {
912                 verbose -log $comp_output
913                 fail $name
914             }
915             file delete $output_file
916         } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
917                        && $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
918                        && $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
919                        && $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
920             set go_execute_args ""
921             set hold_runtests $runtests
922             set runtests "go-test.exp"
923             set dg-do-what-default "link"
924             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
925             set output_file "./[file rootname [file tail $test]].exe"
926             if [isnative] {
927                 if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
928                     fail "$name execution 0"
929                 } else {
930                     pass "$name execution 0"
931                     file delete tmp.x
932                     go-torture-execute "./tmp.go"
933                 }
934                 if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
935                     fail "$name execution 1"
936                 } else {
937                     pass "$name execution 1"
938                     errchk tmp.go ""
939                 }
940                 if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
941                     fail "$name execution 2"
942                 } else {
943                     pass "$name execution 2"
944                     errchk tmp.go ""
945                 }
946                 file delete tmp.go
947             }
948             file delete $output_file
949             set runtests $hold_runtests
950         } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
951                         && $test_line2 == "// errchk \$G -e tmp.go" } {
952             set go_execute_args ""
953             set hold_runtests $runtests
954             set runtests "go-test.exp"
955             set dg-do-what-default "link"
956             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
957             set output_file "./[file rootname [file tail $test]].exe"
958             if [isnative] {
959                 if { [catch "exec $output_file >tmp.go"] != 0 } {
960                     fail "$name execution"
961                 } else {
962                     pass "$name execution"
963                     file delete tmp.x
964                     errchk tmp.go ""
965                 }
966             }
967             file delete $output_file
968             set runtests $hold_runtests
969         } elseif { [string match \
970                         "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
971                         $test_line] } {
972             set hold_runtests $runtests
973             set runtests "go-test.exp"
974             set dg-do-what-default "assemble"
975             regsub "\\.go$" $test ".dir/p.go" file1
976             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
977             set ofile1 "[file rootname [file tail $file1]].o"
978             regsub "\\.go$" $test ".dir/main.go" file2
979             dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
980             set ofile2 "[file rootname [file tail $file2]].o"
981             set output_file "./[file rootname [file tail $test]].exe"
982             set comp_output [go_target_compile "$ofile1 $ofile2" \
983                                  $output_file "executable" "$options"]
984             set comp_output [go-dg-prune $target_triplet $comp_output]
985             if [string match "" $comp_output] {
986                 setup_xfail "*-*-*"
987                 set result [go_load "$output_file" "" ""]
988                 set status [lindex $result 0]
989                 $status $name
990             } else {
991                 verbose -log $comp_output
992                 fail $name
993             }
994             file delete $ofile1 $ofile2 $output_file
995             set runtests $hold_runtests
996         } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
997                    && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
998             set go_execute_args ""
999             set hold_runtests $runtests
1000             set runtests "go-test.exp"
1001             set dg-do-what-default "link"
1002             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1003             set output_file "./[file rootname [file tail $test]].exe"
1004             set base "[file rootname [file tail $test]]"
1005             if [isnative] {
1006                 if { [catch "exec $output_file > $base-out.go"] != 0 } {
1007                     fail "$name execution"
1008                 } else {
1009                     pass "$name execution"
1010                     file delete $base-out.x
1011                     # This testcase takes long time to compile.
1012                     dg-timeout-factor list 4 { target alpha*-*-* }
1013                     go-torture-execute "./$base-out.go"
1014                     unset_timeout_vars
1015                 }
1016                 file delete $base-out.go
1017             }
1018             file delete $output_file
1019             set runtests $hold_runtests
1020         } elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1021             regsub "\\.go$" $test ".dir/a.go" file1
1022             regsub "\\.go$" $test ".dir/b.go" file2
1023             errchk "$file1" "$file2"
1024         } elseif { $test_line == "// \$G \$D/\$F.go \$D/z*.go && \$L \$F.\$A && ./\$A.out" } {
1025             set dir [file dirname $test]
1026             set go_compile_args [glob $dir/z*.go]
1027             go-torture-execute $test
1028         } elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1029                        && $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1030                        && $test_line3 == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1031             set hold_runtests $runtests
1032             set runtests "go-test.exp"
1033             set dg-do-what-default "assemble"
1034             regsub "\\.go$" $test ".dir/pkg.go" file1
1035             dg-test -keep-output $file1 "" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1036             set ofile1 "[file rootname [file tail $file1]].o"
1037             file rename -force $ofile1 slow.o
1038             dg-test -keep-output $file1 "-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1039             file rename -force $ofile1 fast.o
1040             set ofile2 "[file rootname [file tail $test]].o"
1041             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1042             set output_file "./[file rootname [file tail $test]].exe"
1043             set comp_output [go_target_compile "$ofile2 slow.o fast.o" \
1044                                  $output_file "executable" "$options"]
1045             set comp_output [go-dg-prune $target_triplet $comp_output]
1046             if [string match "" $comp_output] {
1047                 set result [go_load "$output_file" "" ""]
1048                 set status [lindex $result 0]
1049                 $status $name
1050             } else {
1051                 verbose -log $comp_output
1052                 fail $name
1053             }
1054             file delete slow.o fast.o $ofile2 $output_file
1055             set runtests $hold_runtests
1056         } elseif { [string match \
1057                         "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1058                         $test_line ] } {
1059             set hold_runtests $runtests
1060             set runtests "go-test.exp"
1061             set dg-do-what-default "assemble"
1062             regsub "\\.go$" $test ".dir/pkg.go" file1
1063             dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
1064             dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
1065             file delete "[file rootname [file tail $file1]].o"
1066             set runtests $hold_runtests
1067         } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
1068                    && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out" } {
1069             set go_execute_args ""
1070             set hold_runtests $runtests
1071             set runtests "go-test.exp"
1072             set dg-do-what-default "link"
1073             dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1074             set output_file "./[file rootname [file tail $test]].exe"
1075             set base "[file rootname [file tail $test]]"
1076             if [isnative] {
1077                 if { [catch "exec $output_file >$base-out.go"] != 0 } {
1078                     fail "$name execution"
1079                 } else {
1080                     pass "$name execution"
1081                     file delete $base-out.x
1082                     go-torture-execute "./$base-out.go"
1083                 }
1084                 file delete $base-out.go
1085             }
1086             file delete $output_file
1087             set runtests $hold_runtests
1088         } elseif { $test_line == "// # generated by cmplxdivide.c" } {
1089             # Ignore.
1090         } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1091                    || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1092             # These tests import the same package under two different
1093             # names, which gccgo does not support.
1094         } elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1095             # This tests whether initializers are written out
1096             # statically.  gccgo does not provide a way to test that,
1097             # as an initializer will be generated for any code which
1098             # has global variables which need to be registered as GC
1099             # roots.
1100         } elseif { $test_line == "// errchk -0 \$G -m -l \$D/\$F.go" } {
1101             # This tests debug output of the gc compiler, which is
1102             # meaningless for gccgo.
1103         } elseif { $test_line == "// \[ \$O == 6 \] || errchk \$G -e \$D/\$F.go" \
1104                        || $test_line == "// \[ \$O != 6 \]  || errchk \$G -e \$D/\$F.go" } {
1105             # This tests specific handling of the gc compiler on types
1106             # that are too large.  It is target specific in a way I
1107             # haven't bothered to check for here.
1108         } else {
1109             clone_output "$name: unrecognized test line: $test_line"
1110             unsupported $name
1111         }
1112
1113         set go_compile_args ""
1114         set go_execute_args ""
1115     }
1116
1117     set dg-do-what-default ${saved-dg-do-what-default}
1118     set TORTURE_OPTIONS $saved_torture_options
1119 }
1120
1121 go-gc-tests