1 # Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
2 # Written by Ian Lance Taylor <iant@google.com>.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
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.
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
35 load_lib go-torture.exp
38 proc filecmp { file1 file2 testname } {
39 set f1 [open $file1 r]
40 set f2 [open $file2 r]
42 while { [gets $f1 line1] >= 0 } {
43 if { [gets $f2 line2] < 0 } {
44 verbose -log "output mismatch: $file2 shorter than $file1"
48 if { $line1 != $line2 } {
49 verbose -log "output mismatch comparing $file1 and $file2"
50 verbose -log "expected \"$line1\""
51 verbose -log "got \"$line2\""
56 if { [gets $f2 line2] >= 0 } {
57 verbose -log "output mismatch: $file1 shorter than $file2"
70 proc errchk { test opts } {
71 global dg-do-what-default
72 global DEFAULT_GOCFLAGS
75 set saved-dg-do-what-default ${dg-do-what-default}
76 set dg-do-what-default compile
77 set filename [file tail $test]
78 if { "$filename" == "$test" } {
79 set filename "errchk-$filename"
81 set fdin [open $test r]
82 fconfigure $fdin -encoding binary
83 set fdout [open $filename w]
84 fconfigure $fdout -encoding binary
85 while { [gets $fdin copy_line] >= 0 } {
86 if [string match "*////*" $copy_line] {
87 puts $fdout $copy_line
90 regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
91 if [string match "*dg-error*\\\[*" $out_line] {
92 set index [string first "dg-error" $out_line]
93 regsub -start $index -all "\\\\\\\[" $out_line "\\\\\\\\\\\[" out_line
95 if [string match "*dg-error*\\\]*" $out_line] {
96 set index [string first "dg-error" $out_line]
97 regsub -start $index -all "\\\\\\\]" $out_line "\\\\\\\\\\\]" out_line
99 if [string match "*dg-error*.\**" $out_line] {
100 # I worked out the right number of backslashes by
101 # experimentation, not analysis.
102 regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
104 if [string match "*dg-error*\\\[?\\\]*" $out_line] {
105 set index [string first "dg-error" $out_line]
106 regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
108 if [string match "*dg-error*\{*" $out_line] {
109 set index [string first "dg-error" $out_line]
110 regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
112 if [string match "*dg-error*\}*\}" $out_line] {
113 set index [string first "dg-error" $out_line]
114 regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
116 if [string match "*dg-error*\(*" $out_line] {
117 set index [string first "dg-error" $out_line]
118 regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
120 if [string match "*dg-error*\)*\}" $out_line] {
121 set index [string first "dg-error" $out_line]
122 regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
124 # Special case for bug332, in which the error message wants to
125 # match the file name, which is not what dg-error expects.
126 if [string match "*dg-error*bug332*" $out_line] {
127 set index [string first "dg-error" $out_line]
128 regsub -start $index "bug332" $out_line "undefined type" out_line
130 puts $fdout $out_line
135 set hold_runtests $runtests
136 set runtests "go-test.exp"
137 go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
138 set runtests $hold_runtests
140 file delete $filename
141 set dg-do-what-default ${saved-dg-do-what-default}
144 # This is an execution test which should fail.
145 proc go-execute-xfail { test } {
146 global DEFAULT_GOCFLAGS
149 set filename [file tail $test]
150 set fdin [open $test r]
151 set fdout [open $filename w]
152 puts $fdout "// { dg-do run { xfail *-*-* } }"
153 while { [gets $fdin copy_line] >= 0 } {
154 puts $fdout $copy_line
159 set hold_runtests $runtests
160 set runtests "go-test.exp"
161 go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
162 set runtests $hold_runtests
164 file delete $filename
167 # N.B. Keep in sync with libgo/configure.ac.
168 proc go-set-goarch { } {
169 global target_triplet
171 switch -glob $target_triplet {
183 if [check_effective_target_ia32] {
190 if [check_no_compiler_messages mipso32 assembly {
191 #if _MIPS_SIM != _ABIO32
196 } elseif [check_no_compiler_messages mipsn32 assembly {
197 #if _MIPS_SIM != _ABIN32
202 } elseif [check_no_compiler_messages mipsn64 assembly {
203 #if _MIPS_SIM != _ABI64
208 } elseif [check_no_compiler_messages mipso64 assembly {
209 #if _MIPS_SIM != _ABIO64
215 perror "$target_triplet: unrecognized MIPS ABI"
220 if [check_effective_target_ilp32] {
227 perror "$target_triplet: unhandled architecture"
231 verbose -log "Setting GOARCH=$goarch" 1
232 setenv GOARCH $goarch
235 proc go-gc-tests { } {
238 global GCC_UNDER_TEST
240 global TORTURE_OPTIONS
241 global dg-do-what-default
242 global go_compile_args
243 global go_execute_args
244 global target_triplet
246 # If a testcase doesn't have special options, use these.
247 global DEFAULT_GOCFLAGS
248 if ![info exists DEFAULT_GOCFLAGS] {
249 set DEFAULT_GOCFLAGS " -pedantic-errors"
253 lappend options "additional_flags=$DEFAULT_GOCFLAGS"
255 # Set GOARCH for tests that need it.
258 # Running all the torture options takes too long and, since the
259 # frontend ignores the standard options, it doesn't significantly
261 set saved_torture_options $TORTURE_OPTIONS
262 set TORTURE_OPTIONS [ list { -O2 -g }]
264 set saved-dg-do-what-default ${dg-do-what-default}
268 set tests [lsort [find $srcdir/$subdir *.go]]
269 foreach test $tests {
270 if ![runtest_file_p $runtests $test] {
274 # Skip the files in bench; they are not tests.
275 if [string match "*go.test/test/bench/*" $test] {
279 # Skip files in sub-subdirectories: they are components of
281 if [string match "*go.test/test/*/*/*" $test] {
285 set name [dg-trim-dirname $srcdir $test]
287 # Skip certain tests if target is RTEMS OS.
288 if [istarget "*-*-rtems*"] {
289 if { [string match "*go.test/test/args.go" \
291 || [string match "*go.test/test/env.go" \
293 untested "$name: uses the command-line or environment variables"
297 if { [string match "*go.test/test/stack.go" \
299 || [string match "*go.test/test/peano.go" \
301 || [string match "*go.test/test/chan/goroutines.go" \
303 untested "$name: has very high memory requirement"
308 if { [string match "*bug347*" $test] \
309 || [string match "*bug348*" $test] } {
310 # These bugs rely on runtime.Caller which currently fails.
315 if { [file tail $test] == "init1.go" } {
316 # This tests whether GC runs during init, which for gccgo
317 # it currently does not.
322 if { [file tail $test] == "closure.go" } {
323 # This tests whether function closures do any memory
324 # allocation, which for gccgo they currently do.
329 set fd [open $test r]
334 if { [gets $fd test_line] < 0 } {
336 clone_output "$test: could not read first line"
342 if { [ string match "*nacl*exit 0*" $test_line ] \
343 || [ string match "*exit 0*nacl*" $test_line ] \
344 || [ string match "*Android*exit 0*" $test_line ] \
345 || [ string match "*exit 0*Android*" $test_line ] \
346 || [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
353 if { $lines_ok == 0 } {
358 set test_line1 $test_line
360 while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
361 set lineno [expr $lineno + 1]
362 if { [eval "gets \$fd test_line$lineno"] < 0 } {
364 clone_output "$test: could not read line $lineno"
370 if { $lines_ok == 0 } {
376 set go_compile_args ""
377 set go_execute_args ""
378 if { [regexp ".*\\\$A.out (\[^|&>2\].*)\$" $test_line match progargs] } {
379 set go_execute_args $progargs
380 verbose -log "$test: go_execute_args is $go_execute_args"
381 set index [string last " $progargs" $test_line]
382 set test_line [string replace $test_line $index end]
383 } elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
384 && [getenv GCCGO_RUN_ALL_TESTS] == "" } {
385 # goroutines.go spawns by default 10000 threads, which is too much
387 if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
388 set go_execute_args 64
389 } elseif { ![is_remote host] && ![is_remote target] } {
390 # When using low ulimit -u limit, use maximum of
391 # a quarter of that limit and 10000 even when running expensive
392 # tests, otherwise parallel tests might fail after fork failures.
393 set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
394 if { [string is integer -strict $nproc] } {
395 set nproc [expr $nproc / 4]
396 if { $nproc > 10000 } { set nproc 10000 }
397 if { $nproc < 16 } { set nproc 16 }
398 set go_execute_args $nproc
401 if { "$go_execute_args" != "" } {
402 verbose -log "$test: go_execute_args is $go_execute_args"
406 if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
407 && $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
408 # 64bit.go is a special case.
409 set go_execute_args ""
410 set hold_runtests $runtests
411 set runtests "go-test.exp"
412 set dg-do-what-default "link"
413 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
414 set output_file "./[file rootname [file tail $test]].exe"
415 set base "[file rootname [file tail $test]]"
417 if { [catch "exec $output_file >$base-out.go"] != 0 } {
418 fail "$name execution"
420 pass "$name execution"
421 file delete $base-out.x
422 go-torture-execute "./$base-out.go"
424 file delete $base-out.go
426 file delete $output_file
427 set runtests $hold_runtests
428 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
429 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
430 || $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
431 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
433 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
436 "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
439 "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
442 "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
445 "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
447 # This is a vanilla execution test.
448 go-torture-execute $test
449 file delete core [glob -nocomplain core.*]
450 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
451 || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
452 || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
453 # This is an execution test for which we need to check the
455 set hold_runtests $runtests
456 set runtests "go-test.exp"
457 set dg-do-what-default "link"
458 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
459 set output_file "./[file rootname [file tail $test]].exe"
460 set base "[file rootname [file tail $test]]"
462 verbose -log "$output_file >$base.p 2>&1"
463 if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } {
464 verbose -log $catcherr
465 fail "$name execution"
466 untested "$name compare"
468 pass "$name execution"
469 regsub "\\.go$" $test ".out" expect
470 filecmp $expect $base.p "$name compare"
474 untested "$name execution"
475 untested "$name compare"
477 set runtests $hold_runtests
478 } elseif { [string match \
479 "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
481 || [string match "// \$G \$F.go && \$L \$F.\$A #*" \
483 || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
484 # This is a vanilla compile and link test.
485 set dg-do-what-default "link"
486 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
487 } elseif { [string match "// \$G \$D/\$F.go" $test_line] \
488 || [string match "// \$G \$D/\$F.go || echo BUG*" \
490 || [string match "// \$G \$D/\$F.go || echo \"Bug*" \
492 || [string match "// \$G \$D/\$F.go || echo \"Issue*" \
494 || [string match "// \$G \$F.go || echo BUG*" \
496 || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
498 || $test_line == "// echo bug395 is broken # takes 90+ seconds to break" } {
499 # This is a vanilla compile test.
500 set dg-do-what-default "assemble"
501 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
502 } elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
504 || $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
505 || $test_line == "// ! \$G \$D/\$F.go" \
506 || $test_line == "// ! \$G \$F.go" \
507 || [string match "// ! \$G \$D/\$F.go || echo BUG*" \
509 # This is a compile test which should fail.
510 set dg-do-what-default "assemble"
512 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
513 } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
515 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
517 || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
519 || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
520 && $test_line2 == "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
521 go-execute-xfail $test
522 } elseif { [string match "// errchk \$G \$F.go" $test_line] \
523 || [string match "// errchk \$G -e \$F.go" $test_line] \
524 || [string match "// errchk \$G \$D/\$F.go" $test_line] \
525 || [string match "//errchk \$G \$D/\$F.go" $test_line] \
526 || [string match "// errchk \$G -e \$D/\$F.go" \
528 || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
529 || [string match "// ! errchk \$G -e \$D/\$F.go" \
531 || [string match "// errchk \$G \$F.go || true" \
533 || [string match "// errchk \$G \$D/\$F.go || true" \
535 || [string match "// errchk \$G -e \$D/\$F.go || true" \
537 || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
540 } elseif { [string match \
541 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
544 "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
547 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
551 } elseif { [string match \
552 "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
557 set hold_runtests $runtests
558 set runtests "go-test.exp"
559 set dg-do-what-default "assemble"
560 regsub "\\.go$" $test ".dir/$name1" file1
561 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
562 regsub "\\.go$" $test ".dir/$name2" file2
563 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
564 file delete "[file rootname [file tail $file1]].o"
565 set runtests $hold_runtests
566 } elseif { [string match \
567 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
570 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
573 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
576 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
579 "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
583 } elseif { [string match \
584 "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
588 } elseif { [string match \
589 "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
593 } elseif { [string match \
594 "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
599 set hold_runtests $runtests
600 set runtests "go-test.exp"
601 set dg-do-what-default "assemble"
602 regsub "\\.go$" $test ".dir/$name1" file1
603 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
604 regsub "\\.go$" $test ".dir/$name2" file2
606 file delete "[file rootname [file tail $file1]].o"
607 set runtests $hold_runtests
608 } elseif { [string match \
609 "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
611 set hold_runtests $runtests
612 set runtests "go-test.exp"
613 set dg-do-what-default "assemble"
614 regsub "\\.go$" $test "1.go" file1
615 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
617 file delete "[file rootname [file tail $file1]].o"
618 set runtests $hold_runtests
619 } elseif { [string match \
620 "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
622 set hold_runtests $runtests
623 set runtests "go-test.exp"
624 set dg-do-what-default "assemble"
625 regsub "\\.go$" $test ".dir/bug0.go" file1
626 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
627 regsub "\\.go$" $test ".dir/bug1.go" file2
629 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
630 file delete "[file rootname [file tail $file1]].o"
631 set runtests $hold_runtests
632 } elseif { [string match \
633 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
635 set hold_runtests $runtests
636 set runtests "go-test.exp"
637 set dg-do-what-default "assemble"
638 regsub "\\.go$" $test ".dir/bug0.go" file1
639 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
640 regsub "\\.go$" $test ".dir/bug1.go" file2
641 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
642 regsub "\\.go$" $test ".dir/bug2.go" file3
644 dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
645 file delete "[file rootname [file tail $file1]].o"
646 file delete "[file rootname [file tail $file2]].o"
647 set runtests $hold_runtests
648 } elseif { [string match \
649 "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
651 set hold_runtests $runtests
652 set runtests "go-test.exp"
653 set dg-do-what-default "assemble"
654 regsub "\\.go$" $test ".dir/bug0.go" file1
655 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
656 regsub "\\.go$" $test ".dir/bug1.go" file2
657 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
658 regsub "\\.go$" $test ".dir/bug2.go" file3
660 file delete "[file rootname [file tail $file1]].o"
661 file delete "[file rootname [file tail $file2]].o"
662 set runtests $hold_runtests
663 } elseif { [string match \
664 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
667 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
670 "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
674 } elseif { [string match \
675 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
680 set hold_runtests $runtests
681 set runtests "go-test.exp"
682 set dg-do-what-default "assemble"
683 regsub "\\.go$" $test ".dir/$name1" file1
684 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
685 set ofile1 "[file rootname [file tail $file1]].o"
686 regsub "\\.go$" $test ".dir/$name2" file2
687 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
688 set ofile2 "[file rootname [file tail $file2]].o"
689 set dg-do-what-default "link"
690 set output_file "./[file rootname [file tail $test]].exe"
691 set comp_output [go_target_compile "$ofile1 $ofile2" \
692 $output_file "executable" "$options"]
693 set comp_output [go-dg-prune $target_triplet $comp_output]
694 verbose -log $comp_output
695 set result [go_load "$output_file" "" ""]
696 set status [lindex $result 0]
698 file delete $ofile1 $ofile2 $output_file
699 set runtests $hold_runtests
700 } elseif { [string match \
701 "// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
703 set hold_runtests $runtests
704 set runtests "go-test.exp"
705 set dg-do-what-default "assemble"
706 regsub "\\.go$" $test ".dir/a.go" file1
707 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
708 set ofile1 "[file rootname [file tail $file1]].o"
709 regsub "\\.go$" $test ".dir/b.go" file2
710 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
711 set ofile2 "[file rootname [file tail $file2]].o"
712 dg-test -keep-output "$test" "-O" "-w $DEFAULT_GOCFLAGS"
713 set ofile3 "[file rootname [file tail $test]].o"
714 set dg-do-what-default "link"
715 set output_file "./[file rootname [file tail $test]].exe"
716 set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
717 $output_file "executable" "$options"]
718 set comp_output [go-dg-prune $target_triplet $comp_output]
719 if [string match "" $comp_output] {
722 verbose -log $comp_output
725 file delete $ofile1 $ofile2 $ofile3 $output_file
726 set runtests $hold_runtests
727 } elseif { [string match \
728 "// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
730 set hold_runtests $runtests
731 set runtests "go-test.exp"
732 set dg-do-what-default "assemble"
733 regsub "/\[^/\]*$" $test "/embed0.go" file1
734 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
735 set ofile1 "[file rootname [file tail $file1]].o"
736 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
737 set ofile2 "[file rootname [file tail $test]].o"
738 set output_file "./[file rootname [file tail $test]].exe"
739 set comp_output [go_target_compile "$ofile1 $ofile2" \
740 $output_file "executable" "$options"]
741 set comp_output [go-dg-prune $target_triplet $comp_output]
742 if [string match "" $comp_output] {
743 set result [go_load "$output_file" "" ""]
744 set status [lindex $result 0]
747 verbose -log $comp_output
750 file delete $ofile1 $ofile2 $output_file
751 set runtests $hold_runtests
752 } elseif { [string match \
753 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
756 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
759 "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
763 } elseif { [string match \
764 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
769 set hold_runtests $runtests
770 set runtests "go-test.exp"
771 set dg-do-what-default "assemble"
772 regsub "\\.go$" $test ".dir/$name1" file1
773 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
774 set ofile1 "[file rootname [file tail $file1]].o"
775 regsub "\\.go$" $test ".dir/$name2" file2
776 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
777 set ofile2 "[file rootname [file tail $file2]].o"
778 set dg-do-what-default "link"
779 set output_file "./[file rootname [file tail $file2]].exe"
780 set comp_output [go_target_compile "$ofile1 $ofile2" \
781 $output_file "executable" "$options"]
782 set comp_output [go-dg-prune $target_triplet $comp_output]
783 if [string match "" $comp_output] {
784 set result [go_load "$output_file" "" ""]
785 set status [lindex $result 0]
788 verbose -log $comp_output
791 file delete $ofile1 $ofile2 $output_file
792 set runtests $hold_runtests
793 } elseif { [string match \
794 "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
796 set hold_runtests $runtests
797 set runtests "go-test.exp"
798 set dg-do-what-default "assemble"
799 regsub "\\.go$" $test ".dir/chanbug.go" file1
800 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
801 regsub "\\.go$" $test ".dir/chanbug2.go" file2
802 dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
803 file delete "[file rootname [file tail $file1]].o"
804 set runtests $hold_runtests
805 } elseif { [string match \
806 "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
808 set dg-do-what-default "assemble"
810 go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
811 } elseif { [string match \
812 "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
814 set hold_runtests $runtests
815 set runtests "go-test.exp"
816 set dg-do-what-default "assemble"
817 regsub "\\.go$" $test ".dir/x.go" file1
818 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
819 regsub "\\.go$" $test ".dir/y.go" file2
821 file delete "[file rootname [file tail $file1]].o"
822 set runtests $hold_runtests
823 } elseif { "$test_line" == "" || [string match "// true*" $test_line] } {
824 # Not a real test, just ignore.
825 } elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
826 && $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
827 && $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
828 && $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
829 && $test_line5 == "// \$L bug2.\$A &&" \
830 && [string match "// ./\$A.out || echo BUG*" $test_line6] } {
831 set hold_runtests $runtests
832 set runtests "go-test.exp"
833 set dg-do-what-default "assemble"
834 regsub "\\.go$" $test ".dir/bug0.go" file0
835 dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
836 set ofile0 "[file rootname [file tail $file0]].o"
837 regsub "\\.go$" $test ".dir/bug1.go" file1
838 dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
839 set ofile1 "[file rootname [file tail $file1]].o"
840 regsub "\\.go$" $test ".dir/bug2.go" file2
841 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
842 set ofile2 "[file rootname [file tail $file2]].o"
843 regsub "\\.go$" $test ".dir/bug3.go" file3
845 set output_file "./[file rootname [file tail $test]].exe"
846 set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
847 $output_file "executable" "$options"]
848 set comp-output [go-dg-prune $target_triplet $comp_output]
849 if [string match "" $comp_output] {
850 set result [go_load "$output_file" "" ""]
851 set status [lindex $result 0]
854 verbose -log $comp_output
857 file delete $ofile0 $ofile1 $ofile2 $output_file
858 set runtests $hold_runtests
859 } elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
860 || $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
861 if { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
862 set name1 "import2.go"
863 } elseif { $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
864 set name1 "recursive1.go"
866 set hold_runtests $runtests
867 set runtests "go-test.exp"
868 set dg-do-what-default "assemble"
869 regsub "/\[^/\]*$" $test "/${name1}" file1
870 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
871 set ofile1 "[file rootname [file tail $file1]].o"
872 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
874 set runtests $hold_runtests
875 } elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
876 set hold_runtests $runtests
877 set runtests "go-test.exp"
878 set dg-do-what-default "assemble"
879 regsub "/\[^/\]*$" $test "/ddd2.go" file1
880 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
881 set ofile1 "[file rootname [file tail $file1]].o"
882 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
883 set ofile2 "[file rootname [file tail $test]].o"
884 set output_file "./[file rootname [file tail $test]].exe"
885 set comp_output [go_target_compile "$ofile1 $ofile2" \
886 $output_file "executable" "$options"]
887 set comp_output [go-dg-prune $target_triplet $comp_output]
888 if [string match "" $comp_output] {
889 set result [go_load "$output_file" "" ""]
890 set status [lindex $result 0]
893 verbose -log $comp_output
896 file delete $ofile1 $ofile2 $output_file
897 set runtests $hold_runtests
898 } elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
899 regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
900 set output_file "./[file rootname [file tail $test]].o"
901 set comp_output [go_target_compile "$test $test2" \
902 $output_file "executable" "$options"]
903 set comp_output [go-dg-prune $target_triplet $comp_output]
904 if [string match "" $comp_output] {
905 set result [go_load "$output_file" "" ""]
906 set status [lindex $result 0]
909 verbose -log $comp_output
912 file delete $output_file
913 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
914 && $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
915 && $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
916 && $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
917 set go_execute_args ""
918 set hold_runtests $runtests
919 set runtests "go-test.exp"
920 set dg-do-what-default "link"
921 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
922 set output_file "./[file rootname [file tail $test]].exe"
924 if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
925 fail "$name execution 0"
927 pass "$name execution 0"
929 go-torture-execute "./tmp.go"
931 if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
932 fail "$name execution 1"
934 pass "$name execution 1"
937 if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
938 fail "$name execution 2"
940 pass "$name execution 2"
945 file delete $output_file
946 set runtests $hold_runtests
947 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
948 && $test_line2 == "// errchk \$G -e tmp.go" } {
949 set go_execute_args ""
950 set hold_runtests $runtests
951 set runtests "go-test.exp"
952 set dg-do-what-default "link"
953 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
954 set output_file "./[file rootname [file tail $test]].exe"
956 if { [catch "exec $output_file >tmp.go"] != 0 } {
957 fail "$name execution"
959 pass "$name execution"
964 file delete $output_file
965 set runtests $hold_runtests
966 } elseif { [string match \
967 "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
969 set hold_runtests $runtests
970 set runtests "go-test.exp"
971 set dg-do-what-default "assemble"
972 regsub "\\.go$" $test ".dir/p.go" file1
973 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
974 set ofile1 "[file rootname [file tail $file1]].o"
975 regsub "\\.go$" $test ".dir/main.go" file2
976 dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
977 set ofile2 "[file rootname [file tail $file2]].o"
978 set output_file "./[file rootname [file tail $test]].exe"
979 set comp_output [go_target_compile "$ofile1 $ofile2" \
980 $output_file "executable" "$options"]
981 set comp_output [go-dg-prune $target_triplet $comp_output]
982 if [string match "" $comp_output] {
984 set result [go_load "$output_file" "" ""]
985 set status [lindex $result 0]
988 verbose -log $comp_output
991 file delete $ofile1 $ofile2 $output_file
992 set runtests $hold_runtests
993 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
994 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
995 set go_execute_args ""
996 set hold_runtests $runtests
997 set runtests "go-test.exp"
998 set dg-do-what-default "link"
999 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1000 set output_file "./[file rootname [file tail $test]].exe"
1001 set base "[file rootname [file tail $test]]"
1003 if { [catch "exec $output_file > $base-out.go"] != 0 } {
1004 fail "$name execution"
1006 pass "$name execution"
1007 file delete $base-out.x
1008 go-torture-execute "./$base-out.go"
1010 file delete $base-out.go
1012 file delete $output_file
1013 set runtests $hold_runtests
1014 } elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
1015 regsub "\\.go$" $test ".dir/a.go" file1
1016 regsub "\\.go$" $test ".dir/b.go" file2
1017 errchk "$file1" "$file2"
1018 } elseif { $test_line == "// \$G \$D/\$F.go \$D/z*.go && \$L \$F.\$A && ./\$A.out" } {
1019 set dir [file dirname $test]
1020 set go_compile_args [glob $dir/z*.go]
1021 go-torture-execute $test
1022 } elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
1023 && $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
1024 && $test_line3 == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
1025 set hold_runtests $runtests
1026 set runtests "go-test.exp"
1027 set dg-do-what-default "assemble"
1028 regsub "\\.go$" $test ".dir/pkg.go" file1
1029 dg-test -keep-output $file1 "" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
1030 set ofile1 "[file rootname [file tail $file1]].o"
1031 file rename -force $ofile1 slow.o
1032 dg-test -keep-output $file1 "-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
1033 file rename -force $ofile1 fast.o
1034 set ofile2 "[file rootname [file tail $test]].o"
1035 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1036 set output_file "./[file rootname [file tail $test]].exe"
1037 set comp_output [go_target_compile "$ofile2 slow.o fast.o" \
1038 $output_file "executable" "$options"]
1039 set comp_output [go-dg-prune $target_triplet $comp_output]
1040 if [string match "" $comp_output] {
1041 set result [go_load "$output_file" "" ""]
1042 set status [lindex $result 0]
1045 verbose -log $comp_output
1048 file delete slow.o fast.o $ofile2 $output_file
1049 set runtests $hold_runtests
1050 } elseif { [string match \
1051 "// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
1053 set hold_runtests $runtests
1054 set runtests "go-test.exp"
1055 set dg-do-what-default "assemble"
1056 regsub "\\.go$" $test ".dir/pkg.go" file1
1057 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
1058 dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
1059 file delete "[file rootname [file tail $file1]].o"
1060 set runtests $hold_runtests
1061 } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
1062 && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out" } {
1063 set go_execute_args ""
1064 set hold_runtests $runtests
1065 set runtests "go-test.exp"
1066 set dg-do-what-default "link"
1067 dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
1068 set output_file "./[file rootname [file tail $test]].exe"
1069 set base "[file rootname [file tail $test]]"
1071 if { [catch "exec $output_file >$base-out.go"] != 0 } {
1072 fail "$name execution"
1074 pass "$name execution"
1075 file delete $base-out.x
1076 go-torture-execute "./$base-out.go"
1078 file delete $base-out.go
1080 file delete $output_file
1081 set runtests $hold_runtests
1082 } elseif { $test_line == "// # generated by cmplxdivide.c" } {
1084 } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
1085 || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
1086 # These tests import the same package under two different
1087 # names, which gccgo does not support.
1088 } elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
1089 # This tests whether initializers are written out
1090 # statically. gccgo does not provide a way to test that,
1091 # as an initializer will be generated for any code which
1092 # has global variables which need to be registered as GC
1094 } elseif { $test_line == "// errchk -0 \$G -m -l \$D/\$F.go" } {
1095 # This tests debug output of the gc compiler, which is
1096 # meaningless for gccgo.
1097 } elseif { $test_line == "// \[ \$O == 6 \] || errchk \$G -e \$D/\$F.go" \
1098 || $test_line == "// \[ \$O != 6 \] || errchk \$G -e \$D/\$F.go" } {
1099 # This tests specific handling of the gc compiler on types
1100 # that are too large. It is target specific in a way I
1101 # haven't bothered to check for here.
1103 clone_output "$name: unrecognized test line: $test_line"
1107 set go_compile_args ""
1108 set go_execute_args ""
1111 set dg-do-what-default ${saved-dg-do-what-default}
1112 set TORTURE_OPTIONS $saved_torture_options