URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [go-test.exp] - Rev 824
Go to most recent revision | Compare with Previous | Blame | View Log
# Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
# Written by Ian Lance Taylor <iant@google.com>.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# Test using the testsuite for the gc Go compiler. In these tests the
# first line is a shell script to run. That line expects the
# following environment variables to be set:
# A The file extension of the object file and the name of the executable
# G The name of the compiler
# L The name of the linker
# F The basename of the test
# D The directory of the test.
#
# Typical command lines:
# // $G $D/$F.go && $L $F.$A && ./$A.out
# // $G $D/$F.go && $L $F.$A || echo BUG: known to fail incorrectly
# // $G $D/$F.go && echo BUG: compilation succeeds incorrectly
# // $G $D/$F.go || echo BUG: compilation should succeed
load_lib go-dg.exp
load_lib go-torture.exp
load_lib target-supports.exp
# Compare two files
proc filecmp { file1 file2 testname } {
set f1 [open $file1 r]
set f2 [open $file2 r]
set ok 1
while { [gets $f1 line1] >= 0 } {
if { [gets $f2 line2] < 0 } {
verbose -log "output mismatch: $file2 shorter than $file1"
set ok 0
break
}
if { $line1 != $line2 } {
verbose -log "output mismatch comparing $file1 and $file2"
verbose -log "expected \"$line1\""
verbose -log "got \"$line2\""
set ok 0
break
}
}
if { [gets $f2 line2] >= 0 } {
verbose -log "output mismatch: $file1 shorter than $file2"
set ok 0
}
close $f1
close $f2
if { ! $ok } {
fail $testname
} else {
pass $testname
}
}
# Implement errchk
proc errchk { test opts } {
global dg-do-what-default
global DEFAULT_GOCFLAGS
global runtests
set saved-dg-do-what-default ${dg-do-what-default}
set dg-do-what-default compile
set filename [file tail $test]
if { "$filename" == "$test" } {
set filename "errchk-$filename"
}
set fdin [open $test r]
fconfigure $fdin -encoding binary
set fdout [open $filename w]
fconfigure $fdout -encoding binary
while { [gets $fdin copy_line] >= 0 } {
if [string match "*////*" $copy_line] {
puts $fdout $copy_line
continue
}
regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
if [string match "*dg-error*\\\[*" $out_line] {
set index [string first "dg-error" $out_line]
regsub -start $index -all "\\\\\\\[" $out_line "\\\\\\\\\\\[" out_line
}
if [string match "*dg-error*\\\]*" $out_line] {
set index [string first "dg-error" $out_line]
regsub -start $index -all "\\\\\\\]" $out_line "\\\\\\\\\\\]" out_line
}
if [string match "*dg-error*.\**" $out_line] {
# I worked out the right number of backslashes by
# experimentation, not analysis.
regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line
}
if [string match "*dg-error*\\\[?\\\]*" $out_line] {
set index [string first "dg-error" $out_line]
regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line
}
if [string match "*dg-error*\{*" $out_line] {
set index [string first "dg-error" $out_line]
regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line
}
if [string match "*dg-error*\}*\}" $out_line] {
set index [string first "dg-error" $out_line]
regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line
}
if [string match "*dg-error*\(*" $out_line] {
set index [string first "dg-error" $out_line]
regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line
}
if [string match "*dg-error*\)*\}" $out_line] {
set index [string first "dg-error" $out_line]
regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line
}
# Special case for bug332, in which the error message wants to
# match the file name, which is not what dg-error expects.
if [string match "*dg-error*bug332*" $out_line] {
set index [string first "dg-error" $out_line]
regsub -start $index "bug332" $out_line "undefined type" out_line
}
puts $fdout $out_line
}
close $fdin
close $fdout
set hold_runtests $runtests
set runtests "go-test.exp"
go-dg-runtest $filename "-fno-show-column $DEFAULT_GOCFLAGS $opts"
set runtests $hold_runtests
file delete $filename
set dg-do-what-default ${saved-dg-do-what-default}
}
# This is an execution test which should fail.
proc go-execute-xfail { test } {
global DEFAULT_GOCFLAGS
global runtests
set filename [file tail $test]
set fdin [open $test r]
set fdout [open $filename w]
puts $fdout "// { dg-do run { xfail *-*-* } }"
while { [gets $fdin copy_line] >= 0 } {
puts $fdout $copy_line
}
close $fdin
close $fdout
set hold_runtests $runtests
set runtests "go-test.exp"
go-dg-runtest $filename "-w $DEFAULT_GOCFLAGS"
set runtests $hold_runtests
file delete $filename
}
# N.B. Keep in sync with libgo/configure.ac.
proc go-set-goarch { } {
global target_triplet
switch -glob $target_triplet {
"alpha*-*-*" {
set goarch "alpha"
}
"arm*-*-*" -
"ep9312*-*-*" -
"strongarm*-*-*" -
"xscale-*-*" {
set goarch "arm"
}
"i?86-*-*" -
"x86_64-*-*" {
if [check_effective_target_ia32] {
set goarch "386"
} else {
set goarch "amd64"
}
}
"mips*-*-*" {
if [check_no_compiler_messages mipso32 assembly {
#if _MIPS_SIM != _ABIO32
#error FOO
#endif
}] {
set goarch "mipso32"
} elseif [check_no_compiler_messages mipsn32 assembly {
#if _MIPS_SIM != _ABIN32
#error FOO
#endif
}] {
set goarch "mipsn32"
} elseif [check_no_compiler_messages mipsn64 assembly {
#if _MIPS_SIM != _ABI64
#error FOO
#endif
}] {
set goarch "mipsn64"
} elseif [check_no_compiler_messages mipso64 assembly {
#if _MIPS_SIM != _ABIO64
#error FOO
#endif
}] {
set goarch "mipso64"
} else {
perror "$target_triplet: unrecognized MIPS ABI"
return ""
}
}
"sparc*-*-*" {
if [check_effective_target_ilp32] {
set goarch "sparc"
} else {
set goarch "sparc64"
}
}
default {
perror "$target_triplet: unhandled architecture"
return ""
}
}
verbose -log "Setting GOARCH=$goarch" 1
setenv GOARCH $goarch
}
proc go-gc-tests { } {
global srcdir subdir
global runtests
global GCC_UNDER_TEST
global TOOL_OPTIONS
global TORTURE_OPTIONS
global dg-do-what-default
global go_compile_args
global go_execute_args
global target_triplet
# If a testcase doesn't have special options, use these.
global DEFAULT_GOCFLAGS
if ![info exists DEFAULT_GOCFLAGS] {
set DEFAULT_GOCFLAGS " -pedantic-errors"
}
set options ""
lappend options "additional_flags=$DEFAULT_GOCFLAGS"
# Set GOARCH for tests that need it.
go-set-goarch
# Running all the torture options takes too long and, since the
# frontend ignores the standard options, it doesn't significantly
# improve testing.
set saved_torture_options $TORTURE_OPTIONS
set TORTURE_OPTIONS [ list { -O2 -g }]
set saved-dg-do-what-default ${dg-do-what-default}
set testdir [pwd]
set tests [lsort [find $srcdir/$subdir *.go]]
foreach test $tests {
if ![runtest_file_p $runtests $test] {
continue
}
# Skip the files in bench; they are not tests.
if [string match "*go.test/test/bench/*" $test] {
continue
}
# Skip files in sub-subdirectories: they are components of
# other tests.
if [string match "*go.test/test/*/*/*" $test] {
continue
}
set name [dg-trim-dirname $srcdir $test]
# Skip certain tests if target is RTEMS OS.
if [istarget "*-*-rtems*"] {
if { [string match "*go.test/test/args.go" $test] \
|| [string match "*go.test/test/env.go" $test] } {
untested "$name: uses the command-line or environment variables"
continue
}
if { [string match "*go.test/test/stack.go" $test] \
|| [string match "*go.test/test/peano.go" $test] \
|| [string match "*go.test/test/chan/goroutines.go" $test] } {
untested "$name: has very high memory requirement"
continue
}
}
# Handle certain tests in a target-dependant way.
if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] } {
if { [string match "*go.test/test/nilptr.go" $test] } {
untested $test
continue
}
}
if { [string match "*bug347*" $test] \
|| [string match "*bug348*" $test] } {
# These bugs rely on runtime.Caller which currently fails.
untested $name
continue
}
if { [file tail $test] == "init1.go" } {
# This tests whether GC runs during init, which for gccgo
# it currently does not.
untested $name
continue
}
if { [file tail $test] == "closure.go" } {
# This tests whether function closures do any memory
# allocation, which for gccgo they currently do.
untested $name
continue
}
if { ( [file tail $test] == "select2.go" \
|| [file tail $test] == "stack.go" ) \
&& ! [check_effective_target_split_stack] } {
# chan/select2.go fails on targets without split stack,
# because they allocate a large stack segment that blows
# out the memory calculations.
untested $name
continue
}
set fd [open $test r]
set lines_ok 1
while 1 {
if { [gets $fd test_line] < 0 } {
close $fd
clone_output "$test: could not read first line"
unresolved $name
set lines_ok 0
break
}
if { [ string match "*nacl*exit 0*" $test_line ] \
|| [ string match "*exit 0*nacl*" $test_line ] \
|| [ string match "*Android*exit 0*" $test_line ] \
|| [ string match "*exit 0*Android*" $test_line ] \
|| [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
continue
}
break
}
if { $lines_ok == 0 } {
continue
}
set lineno 1
set test_line1 $test_line
while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
set lineno [expr $lineno + 1]
if { [eval "gets \$fd test_line$lineno"] < 0 } {
close $fd
clone_output "$test: could not read line $lineno"
unresolved $name
set lines_ok 0
break
}
}
if { $lines_ok == 0 } {
continue
}
close $fd
set go_compile_args ""
set go_execute_args ""
if { [regexp ".*\\\$A.out (\[^|&>2\].*)\$" $test_line match progargs] } {
set go_execute_args $progargs
verbose -log "$test: go_execute_args is $go_execute_args"
set index [string last " $progargs" $test_line]
set test_line [string replace $test_line $index end]
} elseif { [string match "*go.test/test/chan/goroutines.go" $test] \
&& [getenv GCCGO_RUN_ALL_TESTS] == "" } {
# goroutines.go spawns by default 10000 threads, which is too much
# for many OSes.
if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } {
set go_execute_args 64
} elseif { ![is_remote host] && ![is_remote target] } {
# When using low ulimit -u limit, use maximum of
# a quarter of that limit and 10000 even when running expensive
# tests, otherwise parallel tests might fail after fork failures.
set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1]
if { [string is integer -strict $nproc] } {
set nproc [expr $nproc / 4]
if { $nproc > 10000 } { set nproc 10000 }
if { $nproc < 16 } { set nproc 16 }
set go_execute_args $nproc
}
}
if { "$go_execute_args" != "" } {
verbose -log "$test: go_execute_args is $go_execute_args"
}
}
if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
&& $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
# 64bit.go is a special case.
set go_execute_args ""
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "link"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set output_file "./[file rootname [file tail $test]].exe"
set base "[file rootname [file tail $test]]"
if [isnative] {
if { [catch "exec $output_file >$base-out.go"] != 0 } {
fail "$name execution"
} else {
pass "$name execution"
file delete $base-out.x
# Disable optimizations as this test takes a long time
# to compile.
set hold $TORTURE_OPTIONS
set TORTURE_OPTIONS [ list { -O0 -g }]
go-torture-execute "./$base-out.go"
set TORTURE_OPTIONS $hold
}
file delete $base-out.go
}
file delete $output_file
set runtests $hold_runtests
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
|| $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
|| $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
|| $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
|| [string match \
"// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
$test_line]
|| [string match \
"// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
$test_line]
|| [string match \
"// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
$test_line]
|| [string match \
"// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
$test_line]
|| [string match \
"// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
$test_line] } {
# This is a vanilla execution test.
go-torture-execute $test
file delete core [glob -nocomplain core.*]
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
|| $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
|| $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
# This is an execution test for which we need to check the
# program output.
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "link"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set output_file "./[file rootname [file tail $test]].exe"
set base "[file rootname [file tail $test]]"
if [isnative] {
verbose -log "$output_file >$base.p 2>&1"
if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } {
verbose -log $catcherr
fail "$name execution"
untested "$name compare"
} else {
pass "$name execution"
regsub "\\.go$" $test ".out" expect
filecmp $expect $base.p "$name compare"
}
#file delete $base.p
} else {
untested "$name execution"
untested "$name compare"
}
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
$test_line] \
|| [string match "// \$G \$F.go && \$L \$F.\$A #*" \
$test_line]
|| $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
# This is a vanilla compile and link test.
set dg-do-what-default "link"
go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
} elseif { [string match "// \$G \$D/\$F.go" $test_line] \
|| [string match "// \$G \$D/\$F.go || echo BUG*" \
$test_line] \
|| [string match "// \$G \$D/\$F.go || echo \"Bug*" \
$test_line] \
|| [string match "// \$G \$D/\$F.go || echo \"Issue*" \
$test_line] \
|| [string match "// \$G \$F.go || echo BUG*" \
$test_line] \
|| [string match "// ! \$G \$D/\$F.go && echo BUG*" \
$test_line] \
|| $test_line == "// echo bug395 is broken # takes 90+ seconds to break" } {
# This is a vanilla compile test.
set dg-do-what-default "assemble"
go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
} elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
$test_line] \
|| $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
|| $test_line == "// ! \$G \$D/\$F.go" \
|| $test_line == "// ! \$G \$F.go" \
|| [string match "// ! \$G \$D/\$F.go || echo BUG*" \
$test_line] } {
# This is a compile test which should fail.
set dg-do-what-default "assemble"
setup_xfail "*-*-*"
go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
} elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
$test_line] \
|| [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
$test_line] \
|| [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
$test_line] \
|| ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
&& $test_line2 == "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
go-execute-xfail $test
} elseif { [string match "// errchk \$G \$F.go" $test_line] \
|| [string match "// errchk \$G -e \$F.go" $test_line] \
|| [string match "// errchk \$G \$D/\$F.go" $test_line] \
|| [string match "//errchk \$G \$D/\$F.go" $test_line] \
|| [string match "// errchk \$G -e \$D/\$F.go" \
$test_line] \
|| [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
|| [string match "// ! errchk \$G -e \$D/\$F.go" \
$test_line] \
|| [string match "// errchk \$G \$F.go || true" \
$test_line] \
|| [string match "// errchk \$G \$D/\$F.go || true" \
$test_line] \
|| [string match "// errchk \$G -e \$D/\$F.go || true" \
$test_line] \
|| [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
$test_line] } {
errchk $test ""
} elseif { [string match \
"// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
$test_line] \
|| [string match \
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
$test_line] } {
if { [string match \
"// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
$test_line] } {
set name1 "bug0.go"
set name2 "bug1.go"
} elseif { [string match \
"// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
$test_line] } {
set name1 "one.go"
set name2 "two.go"
}
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/$name1" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/$name2" file2
dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
$test_line] \
|| [string match \
"// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
$test_line] \
|| [string match \
"// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
$test_line] \
|| [string match \
"// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
$test_line] } {
if { [string match \
"// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
$test_line] } {
set name1 "bug0.go"
set name2 "bug1.go"
} elseif { [string match \
"// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
$test_line] } {
set name1 "p1.go"
set name2 "p2.go"
} elseif { [string match \
"// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
$test_line] } {
set name1 "b.go"
set name2 "a.go"
} elseif { [string match \
"// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
$test_line] } {
set name1 "io.go"
set name2 "main.go"
}
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/$name1" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/$name2" file2
errchk $file2 ""
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \
$test_line ] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test "1.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
errchk $test ""
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
$test_line] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/bug0.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/bug1.go" file2
setup_xfail "*-*-*"
dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
$test_line] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/bug0.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/bug1.go" file2
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/bug2.go" file3
setup_xfail "*-*-*"
dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
file delete "[file rootname [file tail $file1]].o"
file delete "[file rootname [file tail $file2]].o"
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
$test_line] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/bug0.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/bug1.go" file2
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/bug2.go" file3
errchk $file3 ""
file delete "[file rootname [file tail $file1]].o"
file delete "[file rootname [file tail $file2]].o"
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
$test_line] \
|| [string match \
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
$test_line] } {
if { [string match \
"// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
$test_line] } {
set name1 "x.go"
set name2 "y.go"
} elseif { [string match \
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
$test_line] } {
set name1 "p.go"
set name2 "main.go"
}
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/$name1" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
regsub "\\.go$" $test ".dir/$name2" file2
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $file2]].o"
set dg-do-what-default "link"
set output_file "./[file rootname [file tail $test]].exe"
set comp_output [go_target_compile "$ofile1 $ofile2" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
verbose -log $comp_output
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
$test_line] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/a.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
regsub "\\.go$" $test ".dir/b.go" file2
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $file2]].o"
dg-test -keep-output "$test" "-O" "-w $DEFAULT_GOCFLAGS"
set ofile3 "[file rootname [file tail $test]].o"
set dg-do-what-default "link"
set output_file "./[file rootname [file tail $test]].exe"
set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
pass $name
} else {
verbose -log $comp_output
fail $name
}
file delete $ofile1 $ofile2 $ofile3 $output_file
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
$test_line ] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "/\[^/\]*$" $test "/embed0.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $test]].o"
set output_file "./[file rootname [file tail $test]].exe"
set comp_output [go_target_compile "$ofile1 $ofile2" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
} else {
verbose -log $comp_output
fail $name
}
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
$test_line ] || \
[string match \
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
$test_line ] } {
if { [string match \
"// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
$test_line ] } {
set name1 "lib.go"
set name2 "main.go"
} elseif { [string match \
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \
$test_line ] } {
set name1 "p.go"
set name2 "main.go"
}
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/$name1" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
regsub "\\.go$" $test ".dir/$name2" file2
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $file2]].o"
set dg-do-what-default "link"
set output_file "./[file rootname [file tail $file2]].exe"
set comp_output [go_target_compile "$ofile1 $ofile2" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
} else {
verbose -log $comp_output
fail $name
}
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
$test_line] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/chanbug.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/chanbug2.go" file2
dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
} elseif { [string match \
"// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
$test_line] } {
set dg-do-what-default "assemble"
setup_xfail "*-*-*"
go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
} elseif { [string match \
"// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
$test_line] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/x.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
regsub "\\.go$" $test ".dir/y.go" file2
errchk $file2 ""
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
} elseif { "$test_line" == "" || [string match "// true*" $test_line] } {
# Not a real test, just ignore.
} elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
&& $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
&& $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
&& $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \
&& $test_line5 == "// \$L bug2.\$A &&" \
&& [string match "// ./\$A.out || echo BUG*" $test_line6] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/bug0.go" file0
dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS"
set ofile0 "[file rootname [file tail $file0]].o"
regsub "\\.go$" $test ".dir/bug1.go" file1
dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
regsub "\\.go$" $test ".dir/bug2.go" file2
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $file2]].o"
regsub "\\.go$" $test ".dir/bug3.go" file3
errchk $file3 ""
set output_file "./[file rootname [file tail $test]].exe"
set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \
$output_file "executable" "$options"]
set comp-output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
} else {
verbose -log $comp_output
fail $name
}
file delete $ofile0 $ofile1 $ofile2 $output_file
set runtests $hold_runtests
} elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" \
|| $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
if { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } {
set name1 "import2.go"
} elseif { $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } {
set name1 "recursive1.go"
}
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "/\[^/\]*$" $test "/${name1}" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
file delete $ofile1
set runtests $hold_runtests
} elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "/\[^/\]*$" $test "/ddd2.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $test]].o"
set output_file "./[file rootname [file tail $test]].exe"
set comp_output [go_target_compile "$ofile1 $ofile2" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
} else {
verbose -log $comp_output
fail $name
}
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
} elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
set output_file "./[file rootname [file tail $test]].o"
set comp_output [go_target_compile "$test $test2" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
} else {
verbose -log $comp_output
fail $name
}
file delete $output_file
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \
&& $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \
&& $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \
&& $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } {
set go_execute_args ""
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "link"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set output_file "./[file rootname [file tail $test]].exe"
if [isnative] {
if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } {
fail "$name execution 0"
} else {
pass "$name execution 0"
file delete tmp.x
# Disable optimizations as this test takes a long time
# to compile.
set hold $TORTURE_OPTIONS
set TORTURE_OPTIONS [ list { -O0 -g }]
go-torture-execute "./tmp.go"
set TORTURE_OPTIONS $hold
}
if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
fail "$name execution 1"
} else {
pass "$name execution 1"
errchk tmp.go ""
}
if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } {
fail "$name execution 2"
} else {
pass "$name execution 2"
errchk tmp.go ""
}
file delete tmp.go
}
file delete $output_file
set runtests $hold_runtests
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \
&& $test_line2 == "// errchk \$G -e tmp.go" } {
set go_execute_args ""
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "link"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set output_file "./[file rootname [file tail $test]].exe"
if [isnative] {
if { [catch "exec $output_file >tmp.go"] != 0 } {
fail "$name execution"
} else {
pass "$name execution"
file delete tmp.x
errchk tmp.go ""
}
}
file delete $output_file
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
$test_line] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/p.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
regsub "\\.go$" $test ".dir/main.go" file2
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $file2]].o"
set output_file "./[file rootname [file tail $test]].exe"
set comp_output [go_target_compile "$ofile1 $ofile2" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
setup_xfail "*-*-*"
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
} else {
verbose -log $comp_output
fail $name
}
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
&& $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
set go_execute_args ""
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "link"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set output_file "./[file rootname [file tail $test]].exe"
set base "[file rootname [file tail $test]]"
if [isnative] {
if { [catch "exec $output_file > $base-out.go"] != 0 } {
fail "$name execution"
} else {
pass "$name execution"
file delete $base-out.x
# Disable optimizations as this test takes a long time
# to compile.
set hold $TORTURE_OPTIONS
set TORTURE_OPTIONS [ list { -O0 -g }]
go-torture-execute "./$base-out.go"
set TORTURE_OPTIONS $hold
}
file delete $base-out.go
}
file delete $output_file
set runtests $hold_runtests
} elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
regsub "\\.go$" $test ".dir/a.go" file1
regsub "\\.go$" $test ".dir/b.go" file2
errchk "$file1" "$file2"
} elseif { $test_line == "// \$G \$D/\$F.go \$D/z*.go && \$L \$F.\$A && ./\$A.out" } {
set dir [file dirname $test]
set go_compile_args [glob $dir/z*.go]
go-torture-execute $test
} elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
&& $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
&& $test_line3 == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/pkg.go" file1
dg-test -keep-output $file1 "" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
file rename -force $ofile1 slow.o
dg-test -keep-output $file1 "-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS"
file rename -force $ofile1 fast.o
set ofile2 "[file rootname [file tail $test]].o"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set output_file "./[file rootname [file tail $test]].exe"
set comp_output [go_target_compile "$ofile2 slow.o fast.o" \
$output_file "executable" "$options"]
set comp_output [go-dg-prune $target_triplet $comp_output]
if [string match "" $comp_output] {
set result [go_load "$output_file" "" ""]
set status [lindex $result 0]
$status $name
} else {
verbose -log $comp_output
fail $name
}
file delete slow.o fast.o $ofile2 $output_file
set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \
$test_line ] } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/pkg.go" file1
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
&& $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out" } {
set go_execute_args ""
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "link"
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
set output_file "./[file rootname [file tail $test]].exe"
set base "[file rootname [file tail $test]]"
if [isnative] {
if { [catch "exec $output_file >$base-out.go"] != 0 } {
fail "$name execution"
} else {
pass "$name execution"
file delete $base-out.x
go-torture-execute "./$base-out.go"
}
file delete $base-out.go
}
file delete $output_file
set runtests $hold_runtests
} elseif { $test_line == "// # generated by cmplxdivide.c" } {
# Ignore.
} elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
|| $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
# These tests import the same package under two different
# names, which gccgo does not support.
} elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
# This tests whether initializers are written out
# statically. gccgo does not provide a way to test that,
# as an initializer will be generated for any code which
# has global variables which need to be registered as GC
# roots.
} elseif { $test_line == "// errchk -0 \$G -m -l \$D/\$F.go" } {
# This tests debug output of the gc compiler, which is
# meaningless for gccgo.
} elseif { $test_line == "// \[ \$O == 6 \] || errchk \$G -e \$D/\$F.go" \
|| $test_line == "// \[ \$O != 6 \] || errchk \$G -e \$D/\$F.go" } {
# This tests specific handling of the gc compiler on types
# that are too large. It is target specific in a way I
# haven't bothered to check for here.
} else {
clone_output "$name: unrecognized test line: $test_line"
unsupported $name
}
set go_compile_args ""
set go_execute_args ""
}
set dg-do-what-default ${saved-dg-do-what-default}
set TORTURE_OPTIONS $saved_torture_options
}
go-gc-tests
Go to most recent revision | Compare with Previous | Blame | View Log