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