OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [go-test.exp] - Blame information for rev 700

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.