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