aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/go.test/go-test.exp
blob: 1bbbd8742e23566ebc9fdfdd6c03af21034e0646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
#   Copyright (C) 2009-2014 Free Software Foundation, Inc.
#   Written by Ian Lance Taylor <iant@google.com>.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3.  If not see
# <http://www.gnu.org/licenses/>.


# Test using the testsuite for the gc Go compiler.  In these tests the
# first line is a shell script to run.  That line expects the
# following environment variables to be set:
#   A   The file extension of the object file and the name of the executable
#   G   The name of the compiler
#   L   The name of the linker
#   F   The basename of the test
#   D   The directory of the test.
#
# Typical command lines:
# // compile
# // run
# // $G $D/$F.go && $L $F.$A && ./$A.out
# // $G $D/$F.go && $L $F.$A || echo BUG: known to fail incorrectly
# // $G $D/$F.go && echo BUG: compilation succeeds incorrectly
# // $G $D/$F.go || echo BUG: compilation should succeed

load_lib go-dg.exp
load_lib go-torture.exp
load_lib target-supports.exp

# Compare two files
proc filecmp { file1 file2 testname } {
    set f1 [open $file1 r]
    set f2 [open $file2 r]
    set ok 1
    while { [gets $f1 line1] >= 0 } {
	if { [gets $f2 line2] < 0 } {
	    verbose -log "output mismatch: $file2 shorter than $file1"
	    set ok 0
	    break
	}
	if { $line1 != $line2 } {
	    verbose -log "output mismatch comparing $file1 and $file2"
	    verbose -log "expected \"$line1\""
	    verbose -log "got      \"$line2\""
	    set ok 0
	    break
	}
    }
    if { [gets $f2 line2] >= 0 } {
	verbose -log "output mismatch: $file1 shorter than $file2"
	set ok 0
    }
    close $f1
    close $f2
    if { ! $ok } {
	fail $testname
    } else {
	pass $testname
    }
}

# Implement errchk
proc errchk { test opts } {
    global dg-do-what-default
    global DEFAULT_GOCFLAGS
    global runtests

    set saved-dg-do-what-default ${dg-do-what-default}
    set dg-do-what-default compile
    set filename [file tail $test]
    if { "$filename" == "$test" } {
	set filename "errchk-$filename"
    }
    set fdin [open $test r]
    fconfigure $fdin -encoding binary
    set fdout [open $filename w]
    fconfigure $fdout -encoding binary
    while { [gets $fdin copy_line] >= 0 } {
	if [string match "*////*" $copy_line] {
	    puts $fdout $copy_line
	    continue
	}

	# Combine quoted strings in comments, so that
	# // ERROR "first error" "second error"
	# turns into
	# // ERROR "first error|second error"
	# This format is used by the master testsuite to recognize
	# multiple errors on a single line.  We don't require that all
	# the errors be present, but we do want to accept any of them.
	set changed ""
	while { $changed != $copy_line } {
	    set changed $copy_line
	    regsub "\(// \[^\"\]*\"\[^\"\]*\)\" \"" $copy_line "\\1|" out_line
	    set copy_line $out_line
	}

	regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
	if [string match "*dg-error*\\\[*" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -start $index -all "\\\\\\\[" $out_line "\\\\\\\\\\\[" out_line
	}
	if [string match "*dg-error*\\\]*" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -start $index -all "\\\\\\\]" $out_line "\\\\\\\\\\\]" out_line
	}
	if [string match "*dg-error*.\**" $out_line] {
	    # I worked out the right number of backslashes by
	    # experimentation, not analysis.
	    regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
	}
	if [string match "*dg-error*\\\[?\\\]*" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
	}
	if [string match "*dg-error*\{*" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
	}
	if [string match "*dg-error*\}*\}" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
	}
	if [string match "*dg-error*\(*" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
	}
	if [string match "*dg-error*\)*\}" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
	}
	# Special case for bug332, in which the error message wants to
	# match the file name, which is not what dg-error expects.
	if [string match "*dg-error*bug332*" $out_line] {
	    set index [string first "dg-error" $out_line]
	    regsub -start $index "bug332" $out_line "undefined type" out_line
	}
	puts $fdout $out_line
    }
    close $fdin
    close $fdout

    set hold_runtests $runtests
    set runtests "go-test.exp"
    go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
    set runtests $hold_runtests

    file delete $filename
    set dg-do-what-default ${saved-dg-do-what-default}
}

# This is an execution test which should fail.
proc go-execute-xfail { test } {
    global DEFAULT_GOCFLAGS
    global runtests

    set filename [file tail $test]
    set fdin [open $test r]
    set fdout [open $filename w]
    puts $fdout "// { dg-do run { xfail *-*-* } }"
    while { [gets $fdin copy_line] >= 0 } {
	puts $fdout $copy_line
    }
    close $fdin
    close $fdout

    set hold_runtests $runtests
    set runtests "go-test.exp"
    go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
    set runtests $hold_runtests

    file delete $filename
}

# N.B. Keep in sync with libgo/configure.ac.
proc go-set-goarch { } {
    global target_triplet

    switch -glob $target_triplet {
	"aarch64*-*-*" {
	    set goarch "arm64"
	}
	"alpha*-*-*" {
	    set goarch "alpha"
	}
	"arm*-*-*" -
	"ep9312*-*-*" -
	"strongarm*-*-*" -
	"xscale-*-*" {
	    set goarch "arm"
	}
	"i?86-*-*" -
	"x86_64-*-*" {
	    if [check_effective_target_ia32] {
		set goarch "386"
	    } else {
		set goarch "amd64"
	    }
	}
	"mips*-*-*" {
	    if [check_no_compiler_messages mipso32 assembly {
		#if _MIPS_SIM != _ABIO32
		#error FOO
		#endif
	    }] {
		set goarch "mipso32"
	    } elseif [check_no_compiler_messages mipsn32 assembly {
		#if _MIPS_SIM != _ABIN32
		#error FOO
		#endif
	    }] {
		set goarch "mipsn32"
	    } elseif [check_no_compiler_messages mipsn64 assembly {
		#if _MIPS_SIM != _ABI64
		#error FOO
		#endif
	    }] {
		set goarch "mipsn64"
	    } elseif [check_no_compiler_messages mipso64 assembly {
		#if _MIPS_SIM != _ABIO64
		#error FOO
		#endif
	    }] {
		set goarch "mipso64"
	    } else {
		perror "$target_triplet: unrecognized MIPS ABI"
		return ""
	    }
	}
	"powerpc*-*-*" {
	    if [check_effective_target_ilp32] {
		set goarch "ppc"
	    } else {
		set goarch "ppc64"
	    }
	}
	"sparc*-*-*" {
	    if [check_effective_target_ilp32] {
		set goarch "sparc"
	    } else {
		set goarch "sparc64"
	    }
	}
	default {
	    perror "$target_triplet: unhandled architecture"
	    return ""
	}	
    }
    verbose -log "Setting GOARCH=$goarch" 1
    setenv GOARCH $goarch
}

# Take a list of files and return a lists of lists, where each list is
# the set of files in the same package.
proc go-find-packages { test name files } {
    set packages [list]
    foreach f $files {
	set fd [open $f r]
	while 1 {
	    if { [gets $fd line] < 0 } {
		close $fd
		clone_output "$test: could not read $f"
		unresolved $name
		return [list]
	    }

	    if { [regexp "^package (\\w+)" $line match package] } {
		set len [llength $packages]
		for { set i 0 } { $i < $len } { incr i } {
		    set p [lindex $packages $i]
		    if { [lindex $p 0] == $package } {
			lappend p $f
			lset packages $i $p
			break
		    }
		}
		if { $i >= $len } {
		    lappend packages [list $package $f]
		}

		close $fd
		break
	    }
	}
    }
    return $packages
}

proc go-gc-tests { } {
    global srcdir subdir
    global runtests
    global GCC_UNDER_TEST
    global TOOL_OPTIONS
    global TORTURE_OPTIONS
    global dg-do-what-default
    global go_compile_args
    global go_execute_args
    global target_triplet

    # If a testcase doesn't have special options, use these.
    global DEFAULT_GOCFLAGS
    if ![info exists DEFAULT_GOCFLAGS] {
	set DEFAULT_GOCFLAGS " -pedantic-errors"
    }

    set options ""
    lappend options "additional_flags=$DEFAULT_GOCFLAGS"

    # Set GOARCH for tests that need it.
    go-set-goarch

    # Running all the torture options takes too long and, since the
    # frontend ignores the standard options, it doesn't significantly
    # improve testing.
    set saved_torture_options $TORTURE_OPTIONS
    set TORTURE_OPTIONS [list { -O2 -g }]

    set saved-dg-do-what-default ${dg-do-what-default}

    set testdir [pwd]

    set tests [lsort [find $srcdir/$subdir *.go]]
    foreach test $tests {
	if ![runtest_file_p $runtests $test] {
	    continue
	}

	# Skip the files in bench; they are not tests.
	if [string match "*go.test/test/bench/*" $test] {
	    continue
	}

	# Skip the files in stress; they are not tests.
	if [string match "*go.test/test/stress/*" $test] {
	    continue
	}

	# Skip the files in safe; gccgo does not support safe mode.
	if [string match "*go.test/test/safe/*" $test] {
	    continue
	}

	# Skip files in sub-subdirectories: they are components of
	# other tests.
	if [string match "*go.test/test/*/*/*" $test] {
	    continue
	}

	# Skip files in *.dir subdirectories: they are components of
	# other tests.
	if [string match "*go.test/test/*.dir/*" $test] {
	    continue
	}

	set name [dg-trim-dirname $srcdir $test]

	# Skip certain tests if target is RTEMS OS.
	if [istarget "*-*-rtems*"] {
	    if { [string match "*go.test/test/args.go" $test] \
		 || [string match "*go.test/test/env.go" $test] } {
		    untested "$name: uses the command-line or environment variables"
		    continue
	    }

	    if { [string match "*go.test/test/stack.go" $test] \
		 || [string match "*go.test/test/peano.go" $test] \
		 || [string match "*go.test/test/chan/goroutines.go" $test] } {
		    untested "$name: has very high memory requirement"
		    continue
	    }
	}

	# Handle certain tests in a target-dependant way.
	if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] } {
	    if { [string match "*go.test/test/nilptr.go" $test] } {
		untested $test
		continue
	    }
	}

	if { [file tail $test] == "init1.go" } {
	    # This tests whether GC runs during init, which for gccgo
	    # it currently does not.
	    untested $name
	    continue
	}

	if { [file tail $test] == "closure.go" } {
	    # This tests whether function closures do any memory
	    # allocation, which for gccgo they currently do.
	    untested $name
	    continue
	}

	if { ( [file tail $test] == "select2.go" \
		   || [file tail $test] == "stack.go" \
		   || [file tail $test] == "peano.go" ) \
		 && ! [check_effective_target_split_stack] } {
	    # These tests fails on targets without split stack.
	    untested $name
	    continue
	}

	if [string match "*go.test/test/rotate\[0123\].go" $test] {
	    # These tests produces a temporary file that takes too long
	    # to compile--5 minutes on my laptop without optimization.
	    # When compiling without optimization it tests nothing
	    # useful, since the point of the test is to see whether
	    # the compiler generates rotate instructions.
	    untested $name
	    continue
	}

	if { [file tail $test] == "bug347.go" \
		 || [file tail $test] == "bug348.go" } {
	    # These tests don't work if the functions are inlined.
	    set TORTURE_OPTIONS [list { -O0 -g }]
	}

	set fd [open $test r]

	set lines_ok 1

	while 1 {
	    if { [gets $fd test_line] < 0 } {
		close $fd
		clone_output "$test: could not read first line"
		unresolved $name
		set lines_ok 0
		break
	    }

	    if { [ string match "*nacl*exit 0*" $test_line ] \
		     || [ string match "*exit 0*nacl*" $test_line ] \
		     || [ string match "*Android*exit 0*" $test_line ] \
		     || [ string match "*exit 0*Android*" $test_line ] \
		     || [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
		continue
	    }

	    if { [ string match "// +build *" $test_line ] } {
		if { [ string match "*[getenv GOARCH]*" $test_line ] } {
		    continue
		}
		if { [ string match "*linux*" $test_line ] } {
		    continue
		}
		if { [ string match "*!windows*" $test_line ] } {
		    continue
		}
		close $fd
		unsupported $name
		set lines_ok 0
	    }

	    break
	}

	if { $lines_ok == 0 } {
	    continue
	}

	set lineno 1
	set test_line1 $test_line

	while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
	    set lineno [expr $lineno + 1]
	    if { [eval "gets \$fd test_line$lineno"] < 0 } {
		close $fd
		clone_output "$test: could not read line $lineno"
		unresolved $name
		set lines_ok 0
		break
	    }
	}
	if { $lines_ok == 0 } {
	    continue
	}

	close $fd

	set go_compile_args ""
	set go_execute_args ""
	if { [regexp "// run (\[^|&>2\].*)\$" $test_line match progargs] \
		 && ! [string match "*.go*" "$progargs"] } {
	    set go_execute_args $progargs
	    verbose -log "$test: go_execute_args is $go_execute_args"
	    set index [string last " $progargs" $test_line]
	    set test_line [string replace $test_line $index end]
	} elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
		   && [getenv GCCGO_RUN_ALL_TESTS] == "" } {
	    # goroutines.go spawns by default 10000 threads, which is too much
	    # for many OSes.
	    if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
		set go_execute_args 64
	    } elseif { ![is_remote host] && ![is_remote target] } {
		# When using low ulimit -u limit, use maximum of
		# a quarter of that limit and 10000 even when running expensive
		# tests, otherwise parallel tests might fail after fork failures.
		set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
		if { [string is integer -strict $nproc] } {
			set nproc [expr $nproc / 4]
			if { $nproc > 10000 } { set nproc 10000 }
			if { $nproc < 16 } { set nproc 16 }
			set go_execute_args $nproc
		}
	    }
	    if { "$go_execute_args" != "" } {
		verbose -log "$test: go_execute_args is $go_execute_args"
	    }
	}

	if { $test_line == "// compile"
	     || $test_line == "// echo bug395 is broken  # takes 90+ seconds to break" } {
	    # This is a vanilla compile test.
	    set dg-do-what-default "assemble"
	    go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
	} elseif { $test_line == "// run"
		   || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
	    # This is a vanilla execution test.
	    go-torture-execute $test
	    file delete core [glob -nocomplain core.*]
	} elseif { $test_line == "// build" } {
	    # This is a vanilla compile and link test.
	    set dg-do-what-default "link"
	    go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
	} elseif { [string match "// runoutput*" $test_line] \
		       || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
			   && $test_line2 == "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
	    # Run the test to get a .go program to run.
	    set go_execute_args ""
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set files [list]
	    if { [string match "// runoutput*" $test_line] } {
		set args ""
		regsub "// runoutput\(.*\)" $test_line "\\1" args
		foreach f $args {
		    lappend files "[file dirname $test]/$f"
		}
	    }
	    set dg-do-what-default "link"
	    dg-test -keep-output $test "-O" "$files -w $DEFAULT_GOCFLAGS"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set base "[file rootname [file tail $test]]"
	    if [isnative] {
		if { [catch "exec $output_file >$base-out.go"] != 0 } {
		    fail "$name execution"
		} else {
		    pass "$name execution"
		    file delete $base-out.x
		    # Disable optimizations as some of these tests
		    # take a long time to compile.
		    set TORTURE_OPTIONS [list { -O0 -g -fno-var-tracking-assignments }]
		    go-torture-execute "./$base-out.go"
		}
		file delete $base-out.go
	    }
	    file delete $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// cmpout" \
		   || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
	    # This is an execution test for which we need to check the
	    # program output.
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "link"
	    dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set base "[file rootname [file tail $test]]"
	    if [isnative] {
		verbose -log "$output_file >$base.p 2>&1"
		if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } {
		    verbose -log $catcherr
		    fail "$name execution"
		    untested "$name compare"
		} else {
		    pass "$name execution"
		    regsub "\\.go$" $test ".out" expect
		    filecmp $expect $base.p "$name compare"
		}
		file delete $base.p
	    } else {
		untested "$name execution"
		untested "$name compare"
	    }
	    set runtests $hold_runtests
	} elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
		    $test_line] } {
	    go-execute-xfail $test
	} elseif { $test_line == "// errorcheck" } {
	    errchk $test ""
	} elseif { $test_line == "// errorcheckdir" } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dir "[file rootname $test].dir"
	    set files [lsort [glob "$dir/*.go"]]
	    set packages [go-find-packages $test $name $files]
	    if { [llength $packages] > 0 } {
		set dg-do-what-default "assemble"
		set del [list]
		set last [lindex $packages end]
		set packages [lreplace $packages end end]
		foreach p $packages {
		    dg-test -keep-output [lrange $p 1 end] "-O" "-w $DEFAULT_GOCFLAGS"
		    lappend del "[file rootname [file tail [lindex $p 1]]].o"
		}
		errchk [lindex $last 1] "[lrange $last 2 end]"
		foreach f $del {
		    file delete $f
		}
	    }
	    set runtests $hold_runtests
	} elseif { [string match "// errorcheckoutput*" $test_line] } {
	    # Run the test to get a .go program to error check.
	    set go_execute_args ""
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set files [list]
	    regsub "// errorcheckoutput\(.*\)" $test_line "\\1" args
	    foreach f $args {
		lappend files "[file dirname $test]/$f"
	    }
	    set dg-do-what-default "link"
	    dg-test -keep-output $test "-O" "$files -w $DEFAULT_GOCFLAGS"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set base "[file rootname [file tail $test]]"
	    if [isnative] {
		if { [catch "exec $output_file >$base-out.go"] != 0 } {
		    fail "$name execution"
		} else {
		    pass "$name execution"
		    errchk "$base-out.go" ""
		}
		file delete $base-out.go
	    }
	    file delete $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// compiledir" } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    set dir "[file rootname $test].dir"
	    set del {}
	    foreach f [lsort [glob "$dir/*.go"]] {
		dg-test -keep-output $f "-O" "-w $DEFAULT_GOCFLAGS"
		lappend del "[file rootname [file tail $f]].o"
	    }
	    foreach f $del {
		file delete $f
	    }
	    set runtests $hold_runtests
	} elseif { $test_line == "// rundir" } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dir "[file rootname $test].dir"
	    set files [lsort [glob "$dir/*.go"]]
	    set packages [go-find-packages $test $name $files]
	    if { [llength $packages] > 0 } {
		set dg-do-what-default "assemble"
		set del [list]
		set last [lindex $packages end]
		set packages [lreplace $packages end end]
		foreach p $packages {
		    dg-test -keep-output [lrange $p 1 end] "-O" "-w $DEFAULT_GOCFLAGS"
		    lappend del "[file rootname [file tail [lindex $p 1]]].o"
		}
		set dg-do-what-default "link"
		set go_compile_args $del
		go-torture-execute [lrange $last 1 end]
		foreach f $del {
		    file delete $f
		}
	    }
	    set runtests $hold_runtests
	} elseif { $test_line == "// rundircmpout" } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dir "[file rootname $test].dir"
	    set files [lsort [glob "$dir/*.go"]]
	    set packages [go-find-packages $test $name $files]
	    if { [llength $packages] > 0 } {
		set dg-do-what-default "assemble"
		set del [list]
		set last [lindex $packages end]
		set packages [lreplace $packages end end]
		foreach p $packages {
		    dg-test -keep-output [lrange $p 1 end] "-O" "-w $DEFAULT_GOCFLAGS"
		    lappend del "[file rootname [file tail [lindex $p 1]]].o"
		}
		set dg-do-what-default "link"
		dg-test -keep-output [lrange $last 1 end] "$del -O" "-w $DEFAULT_GOCFLAGS"
		set base "[file rootname [file tail [lindex $last 1]]]"
		set output_file "./$base.exe"
		lappend del $output_file
		if [isnative] {
		    verbose -log "$output_file >$base.p 2>&1"
		    if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } {
			verbose -log $catcherr
			fail "$name execution"
			untested "$name compare"
		    } else {
			pass "$name execution"
			regsub "\\.go$" "$test" ".out" expect
			filecmp $expect $base.p "$name compare"
		    }
		    lappend del $base.p
		}
		foreach f $del {
		    file delete $f
		}
	    }
	    set runtests $hold_runtests
	} elseif { "$test_line" == ""
		   || [string match "// true*" $test_line]
		   || [string match "// skip*" $test_line] } {
	    # Not a real test, just ignore.
	} elseif { [string match \
			"// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
			$test_line] \
		       || [string match \
			       "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
			       $test_line] } {
	    if { [string match \
		      "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
		      $test_line] } {
		set name1 "bug0.go"
		set name2 "bug1.go"
	    } elseif { [string match \
			    "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
			    $test_line] } {
		set name1 "io.go"
		set name2 "main.go"
	    }
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/$name1" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    regsub "\\.go$" $test ".dir/$name2" file2
	    errchk $file2 ""
	    file delete "[file rootname [file tail $file1]].o"
	    set runtests $hold_runtests
	} elseif { [string match \
			"// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
			$test_line ] } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test "1.go" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    errchk $test ""
	    file delete "[file rootname [file tail $file1]].o"
	    set runtests $hold_runtests
	} elseif { [string match \
			"// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
			$test_line] } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/bug0.go" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    regsub "\\.go$" $test ".dir/bug1.go" file2
	    dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
	    regsub "\\.go$" $test ".dir/bug2.go" file3
	    errchk $file3 ""
	    file delete "[file rootname [file tail $file1]].o"
	    file delete "[file rootname [file tail $file2]].o"
	    set runtests $hold_runtests
	} elseif { [string match \
			"// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
			$test_line] \
		       || [string match \
			       "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
			       $test_line] \
		       || $test_line == "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
		       || $test_line == "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
		       || $test_line == "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
	    if { [string match \
			"// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
		      $test_line] } {
		set name1 "x.go"
		set name2 "y.go"
	    } elseif { [string match \
			   "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
			    $test_line] } {
		set name1 "p.go"
		set name2 "main.go"
	    } elseif { $test_line == "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
		set name1 "p1.go"
		set name2 "main.go"
	    } elseif { $test_line == "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
		set name1 "lib.go"
		set name2 ""
	    } elseif { $test_line == "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
		set name1 "method4a.go"
		set name2 ""
	    }
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/$name1" file1
	    if { $name1 == "method4a.go" } {
		set file1 "[file dirname $test]/method4a.go"
	    }
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    regsub "\\.go$" $test ".dir/$name2" file2
	    if { $name2 == "" } {
		set file2 $test
	    }
	    dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile2 "[file rootname [file tail $file2]].o"
	    set dg-do-what-default "link"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set comp_output [go_target_compile "$ofile1 $ofile2" \
				 $output_file "executable" "$options"]
	    set comp_output [go-dg-prune $target_triplet $comp_output]
	    verbose -log $comp_output
	    set result [go_load "$output_file" "" ""]
	    set status [lindex $result 0]
	    $status $name
	    file delete $ofile1 $ofile2 $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/one.go" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    regsub "\\.go$" $test ".dir/two.go" file2
	    dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile2 "[file rootname [file tail $file2]].o"
	    dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile3 "[file rootname [file tail $test]].o"
	    set dg-do-what-default "link"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
				 $output_file "executable" "$options"]
	    set comp_output [go-dg-prune $target_triplet $comp_output]
	    verbose -log $comp_output
	    set result [go_load "$output_file" "" ""]
	    set status [lindex $result 0]
	    $status $name
	    file delete $ofile1 $ofile2 $ofile3 $output_file
	    set runtests $hold_runtests
	} elseif { [string match \
			"// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
			$test_line ] } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "/\[^/\]*$" $test "/embed0.go" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile2 "[file rootname [file tail $test]].o"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set comp_output [go_target_compile "$ofile1 $ofile2" \
				 $output_file "executable" "$options"]
	    set comp_output [go-dg-prune $target_triplet $comp_output]
	    if [string match "" $comp_output] {
		set result [go_load "$output_file" "" ""]
		set status [lindex $result 0]
		$status $name
	    } else {
		verbose -log $comp_output
		fail $name
	    }
	    file delete $ofile1 $ofile2 $output_file
	    set runtests $hold_runtests
	} elseif { [string match \
			"// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
			$test_line ] || \
		       [string match \
			    "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
			    $test_line ] } {
	    if { [string match \
		      "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
		      $test_line ] } {
		set name1 "lib.go"
		set name2 "main.go"
	    } elseif { [string match \
			    "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
			    $test_line ] } {
		set name1 "p.go"
		set name2 "main.go"
	    }
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/$name1" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    regsub "\\.go$" $test ".dir/$name2" file2
	    dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile2 "[file rootname [file tail $file2]].o"
	    set dg-do-what-default "link"
	    set output_file "./[file rootname [file tail $file2]].exe"
	    set comp_output [go_target_compile "$ofile1 $ofile2" \
				 $output_file "executable" "$options"]
	    set comp_output [go-dg-prune $target_triplet $comp_output]
	    if [string match "" $comp_output] {
		set result [go_load "$output_file" "" ""]
		set status [lindex $result 0]
		$status $name
	    } else {
		verbose -log $comp_output
		fail $name
	    }
	    file delete $ofile1 $ofile2 $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
		       && $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
		       && $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
		       && $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
		       && $test_line5 == "// \$L bug2.\$A &&" \
		       && [string match "// ./\$A.out || echo BUG*" $test_line6] } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/bug0.go" file0
	    dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
	    set ofile0 "[file rootname [file tail $file0]].o"
	    regsub "\\.go$" $test ".dir/bug1.go" file1
	    dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    regsub "\\.go$" $test ".dir/bug2.go" file2
	    dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile2 "[file rootname [file tail $file2]].o"
	    regsub "\\.go$" $test ".dir/bug3.go" file3
	    errchk $file3 ""
	    set output_file "./[file rootname [file tail $test]].exe"
	    set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
				 $output_file "executable" "$options"]
	    set comp-output [go-dg-prune $target_triplet $comp_output]
	    if [string match "" $comp_output] {
		set result [go_load "$output_file" "" ""]
		set status [lindex $result 0]
		$status $name
	    } else {
		verbose -log $comp_output
		fail $name
	    }
	    file delete $ofile0 $ofile1 $ofile2 $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
		       || $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
	    if { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
		set name1 "import2.go"
	    } elseif { $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
		set name1 "recursive1.go"
	    }
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "/\[^/\]*$" $test "/${name1}" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
	    file delete $ofile1
	    set runtests $hold_runtests
	} elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "/\[^/\]*$" $test "/ddd2.go" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile2 "[file rootname [file tail $test]].o"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set comp_output [go_target_compile "$ofile1 $ofile2" \
				 $output_file "executable" "$options"]
	    set comp_output [go-dg-prune $target_triplet $comp_output]
	    if [string match "" $comp_output] {
		set result [go_load "$output_file" "" ""]
		set status [lindex $result 0]
		$status $name
	    } else {
		verbose -log $comp_output
		fail $name
	    }
	    file delete $ofile1 $ofile2 $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// run cmplxdivide1.go" } {
	    regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
	    set output_file "./[file rootname [file tail $test]].o"
	    set comp_output [go_target_compile "$test $test2" \
				 $output_file "executable" "$options"]
	    set comp_output [go-dg-prune $target_triplet $comp_output]
	    if [string match "" $comp_output] {
		set result [go_load "$output_file" "" ""]
		set status [lindex $result 0]
		$status $name
	    } else {
		verbose -log $comp_output
		fail $name
	    }
	    file delete $output_file
	} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
		       && $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
		       && $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
		       && $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
	    set go_execute_args ""
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "link"
	    dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
	    set output_file "./[file rootname [file tail $test]].exe"
	    if [isnative] {
		if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
		    fail "$name execution 0"
		} else {
		    pass "$name execution 0"
		    file delete tmp.x
		    # Disable optimizations as this test takes a long time
		    # to compile.
		    set TORTURE_OPTIONS [list { -O0 -g -fno-var-tracking-assignments }]
		    go-torture-execute "./tmp.go"
		}
		if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
		    fail "$name execution 1"
		} else {
		    pass "$name execution 1"
		    errchk tmp.go ""
		}
		if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
		    fail "$name execution 2"
		} else {
		    pass "$name execution 2"
		    errchk tmp.go ""
		}
		file delete tmp.go
	    }
	    file delete $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
			&& $test_line2 == "// errchk \$G -e tmp.go" } {
	    set go_execute_args ""
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "link"
	    dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
	    set output_file "./[file rootname [file tail $test]].exe"
	    if [isnative] {
		if { [catch "exec $output_file >tmp.go"] != 0 } {
		    fail "$name execution"
		} else {
		    pass "$name execution"
		    file delete tmp.x
		    errchk tmp.go ""
		}
	    }
	    file delete $output_file
	    set runtests $hold_runtests
	} elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
	    regsub "\\.go$" $test ".dir/a.go" file1
	    regsub "\\.go$" $test ".dir/b.go" file2
	    errchk "$file1" "$file2"
	} elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
		       && $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
		       && $test_line3 == "// run" } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/pkg.go" file1
	    dg-test -keep-output $file1 "" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    file rename -force $ofile1 slow.o
	    dg-test -keep-output $file1 "-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
	    file rename -force $ofile1 fast.o
	    set ofile2 "[file rootname [file tail $test]].o"
	    dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
	    set output_file "./[file rootname [file tail $test]].exe"
	    set comp_output [go_target_compile "$ofile2 slow.o fast.o" \
				 $output_file "executable" "$options"]
	    set comp_output [go-dg-prune $target_triplet $comp_output]
	    if [string match "" $comp_output] {
		set result [go_load "$output_file" "" ""]
		set status [lindex $result 0]
		$status $name
	    } else {
		verbose -log $comp_output
		fail $name
	    }
	    file delete slow.o fast.o $ofile2 $output_file
	    set runtests $hold_runtests
	} elseif { [string match \
			"// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
			$test_line ] } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/pkg.go" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
	    file delete "[file rootname [file tail $file1]].o"
	    set runtests $hold_runtests
	} elseif { [string match "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
			$test_line ] } {
	    set hold_runtests $runtests
	    set runtests "go-test.exp"
	    set dg-do-what-default "assemble"
	    regsub "\\.go$" $test ".dir/one.go" file1
	    dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
	    set ofile1 "[file rootname [file tail $file1]].o"
	    regsub "\\.go$" $test ".dir/two.go" file2
	    dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
	    file delete $ofile1
	    set runtests $hold_runtests
	} elseif { $test_line == "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
		   || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
	    # These tests import the same package under two different
	    # names, which gccgo does not support.
	} elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
	    # This tests whether initializers are written out
	    # statically.  gccgo does not provide a way to test that,
	    # as an initializer will be generated for any code which
	    # has global variables which need to be registered as GC
	    # roots.
	} elseif { $test_line == "// errorcheck -0 -m"
		   || $test_line == "// errorcheck -0 -m -l" } { 
	    # This tests debug output of the gc compiler, which is
	    # meaningless for gccgo.
	} elseif { $test_line == "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
		       || $test_line == "// \[ \$A != 6 \]  || errchk \$G -e \$D/\$F.go" } {
	    # This tests specific handling of the gc compiler on types
	    # that are too large.  It is target specific in a way I
	    # haven't bothered to check for here.
	} elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
	    # This tests the gc ld -X option, which gccgo does not
	    # support.
	} 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"
		   || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
	    # This tests the gc -u option, which gccgo does not
	    # support.
	} elseif { $test_line == "// errorcheck -0 -N -d=nil" \
		       || $test_line == "// errorcheck -0 -d=nil" } {
	    # This tests gc nil pointer checks using -d=nil, which
	    # gccgo does not support.
	} else {
	    clone_output "$name: unrecognized test line: $test_line"
	    unsupported $name
	}

	set go_compile_args ""
	set go_execute_args ""
        set TORTURE_OPTIONS [list { -O2 -g }]
    }

    set dg-do-what-default ${saved-dg-do-what-default}
    set TORTURE_OPTIONS $saved_torture_options
}

go-gc-tests