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