go-test.exp (go-gc-tests): Handle runoutput test type with arguments.
authorIan Lance Taylor <iant@google.com>
Fri, 9 Nov 2012 00:05:05 +0000 (00:05 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 9 Nov 2012 00:05:05 +0000 (00:05 +0000)
* go.test/go-test.exp (go-gc-tests): Handle runoutput test type
with arguments.  Handle errorcheckoutput and rundir test types.

From-SVN: r193344

gcc/testsuite/ChangeLog
gcc/testsuite/go.test/go-test.exp
gcc/testsuite/go.test/test/index.go
gcc/testsuite/go.test/test/index0.go [new file with mode: 0644]
gcc/testsuite/go.test/test/index1.go [new file with mode: 0644]
gcc/testsuite/go.test/test/index2.go [new file with mode: 0644]

index f67250981c32f4f5c7a6bf749ac915c478e4f4d8..3d81982ea9360be8001dd46a27fd9d8a902215b5 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-08  Ian Lance Taylor  <iant@google.com>
+
+       * go.test/go-test.exp (go-gc-tests): Handle runoutput test type
+       with arguments.  Handle errorcheckoutput and rundir test types.
+
 2012-11-08  Steven Bosscher  <steven@gcc.gnu.org>
 
        PR tree-optimization/55191
index b093f01c843f88dee9325f36c098ac02f9fa82d4..7451f396dcbe6fcecd93533f2f85379084d7d56e 100644 (file)
@@ -449,15 +449,23 @@ proc go-gc-tests { } {
            # This is a vanilla compile and link test.
            set dg-do-what-default "link"
            go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
-       } elseif { $test_line == "// runoutput" \
+       } elseif { [string match "// runoutput*" $test_line] \
                       || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
                           && $test_line2 == "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
            # Run the test to get a .go program to run.
            set go_execute_args ""
            set hold_runtests $runtests
            set runtests "go-test.exp"
+           set files [list]
+           if { [string match "// runoutput*" $test_line] } {
+               set args ""
+               regsub "// runoutput\(.*\)" $test_line "\\1" args
+               foreach f $args {
+                   lappend files "[file dirname $test]/$f"
+               }
+           }
            set dg-do-what-default "link"
-           dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
+           dg-test -keep-output $test "-O" "$files -w $DEFAULT_GOCFLAGS"
            set output_file "./[file rootname [file tail $test]].exe"
            set base "[file rootname [file tail $test]]"
            if [isnative] {
@@ -507,6 +515,31 @@ proc go-gc-tests { } {
            go-execute-xfail $test
        } elseif { $test_line == "// errorcheck" } {
            errchk $test ""
+       } elseif { [string match "// errorcheckoutput*" $test_line] } {
+           # Run the test to get a .go program to error check.
+           set go_execute_args ""
+           set hold_runtests $runtests
+           set runtests "go-test.exp"
+           set files [list]
+           regsub "// errorcheckoutput\(.*\)" $test_line "\\1" args
+           foreach f $args {
+               lappend files "[file dirname $test]/$f"
+           }
+           set dg-do-what-default "link"
+           dg-test -keep-output $test "-O" "$files -w $DEFAULT_GOCFLAGS"
+           set output_file "./[file rootname [file tail $test]].exe"
+           set base "[file rootname [file tail $test]]"
+           if [isnative] {
+               if { [catch "exec $output_file >$base-out.go"] != 0 } {
+                   fail "$name execution"
+               } else {
+                   pass "$name execution"
+                   errchk "$base-out.go" ""
+               }
+               file delete $base-out.go
+           }
+           file delete $output_file
+           set runtests $hold_runtests
        } elseif { $test_line == "// compiledir" } {
            set hold_runtests $runtests
            set runtests "go-test.exp"
@@ -521,6 +554,26 @@ proc go-gc-tests { } {
                file delete $f
            }
            set runtests $hold_runtests
+       } elseif { $test_line == "// rundir" } {
+           set hold_runtests $runtests
+           set runtests "go-test.exp"
+           set dg-do-what-default "assemble"
+           set dir "[file rootname $test].dir"
+           set del {}
+           set files [lsort [glob "$dir/*.go"]]
+           set last [lindex $files end]
+           set files [lreplace $files end end]
+           foreach f $files {
+               dg-test -keep-output $f "-O" "-w $DEFAULT_GOCFLAGS"
+               lappend del "[file rootname [file tail $f]].o"
+           }
+           set dg-do-what-default "link"
+           set go_compile_args $del
+           go-torture-execute $last
+           foreach f $del {
+               file delete $f
+           }
+           set runtests $hold_runtests
        } elseif { "$test_line" == ""
                   || [string match "// true*" $test_line]
                   || [string match "// skip*" $test_line] } {
index 461c2ee4184f6165d3b52a1a145018f8aa4a7edb..daab45f7a17a8ed4b33f409c6dca5c0a76a0ad2f 100644 (file)
@@ -1,27 +1,19 @@
-// $G $D/$F.go && $L $F.$A &&
-// ./$A.out -pass 0 >tmp.go && $G tmp.go && $L -o $A.out1 tmp.$A && ./$A.out1 &&
-// ./$A.out -pass 1 >tmp.go && errchk $G -e tmp.go &&
-// ./$A.out -pass 2 >tmp.go && errchk $G -e tmp.go
-// rm -f tmp.go $A.out1
-
-// NOTE: This test is not run by 'run.go' and so not run by all.bash.
-// To run this test you must use the ./run shell script.
+// skip
 
 // Copyright 2010 The Go Authors.  All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
 // Generate test of index and slice bounds checks.
-// The output is compiled and run.
+// The actual tests are index0.go, index1.go, index2.go.
 
 package main
 
 import (
        "bufio"
-       "flag"
        "fmt"
        "os"
-       "runtime"
+       "unsafe"
 )
 
 const prolog = `
@@ -155,14 +147,13 @@ func bug() {
 func main() {
 `
 
-// Passes:
+// pass variable set in index[012].go
 //     0 - dynamic checks
 //     1 - static checks of invalid constants (cannot assign to types)
 //     2 - static checks of array bounds
-var pass = flag.Int("pass", 0, "which test (0,1,2)")
 
 func testExpr(b *bufio.Writer, expr string) {
-       if *pass == 0 {
+       if pass == 0 {
                fmt.Fprintf(b, "\ttest(func(){use(%s)}, %q)\n", expr, expr)
        } else {
                fmt.Fprintf(b, "\tuse(%s)  // ERROR \"index|overflow\"\n", expr)
@@ -172,12 +163,10 @@ func testExpr(b *bufio.Writer, expr string) {
 func main() {
        b := bufio.NewWriter(os.Stdout)
 
-       flag.Parse()
-       
-       if *pass == 0 {
-               fmt.Fprint(b, "// $G $D/$F.go && $L $F.$A && ./$A.out\n\n")
+       if pass == 0 {
+               fmt.Fprint(b, "// run\n\n")
        } else {
-               fmt.Fprint(b, "// errchk $G -e $D/$F.go\n\n")
+               fmt.Fprint(b, "// errorcheck\n\n")
        }
        fmt.Fprint(b, prolog)
        
@@ -225,9 +214,10 @@ func main() {
                                // the next pass from running.
                                // So run it as a separate check.
                                thisPass = 1
-                       } else if a == "s" && n == "" && (i == "i64big" || i == "i64bigger") && runtime.GOARCH == "amd64" {
-                               // On amd64, these huge numbers do fit in an int, so they are not
-                               // rejected at compile time.
+                       } else if a == "s" && n == "" && (i == "i64big" || i == "i64bigger") && unsafe.Sizeof(int(0)) > 4 {
+                               // If int is 64 bits, these huge
+                               // numbers do fit in an int, so they
+                               // are not rejected at compile time.
                                thisPass = 0
                        } else {
                                thisPass = 2
@@ -240,7 +230,7 @@ func main() {
                }
 
                // Only print the test case if it is appropriate for this pass.
-               if thisPass == *pass {
+               if thisPass == pass {
                        pae := p+a+e+big
                        cni := c+n+i
                        
diff --git a/gcc/testsuite/go.test/test/index0.go b/gcc/testsuite/go.test/test/index0.go
new file mode 100644 (file)
index 0000000..04a1619
--- /dev/null
@@ -0,0 +1,12 @@
+// runoutput ./index.go
+
+// Copyright 2012 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Generate test of index and slice bounds checks.
+// The output is compiled and run.
+
+package main
+
+const pass = 0
diff --git a/gcc/testsuite/go.test/test/index1.go b/gcc/testsuite/go.test/test/index1.go
new file mode 100644 (file)
index 0000000..e28efa3
--- /dev/null
@@ -0,0 +1,12 @@
+// errorcheckoutput ./index.go
+
+// Copyright 2010 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Generate test of index and slice bounds checks.
+// The output is error checked.
+
+package main
+
+const pass = 1
diff --git a/gcc/testsuite/go.test/test/index2.go b/gcc/testsuite/go.test/test/index2.go
new file mode 100644 (file)
index 0000000..a7107cc
--- /dev/null
@@ -0,0 +1,12 @@
+// errorcheckoutput ./index.go
+
+// Copyright 2010 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Generate test of index and slice bounds checks.
+// The output is error checked.
+
+package main
+
+const pass = 2