From patchwork Fri Nov 9 00:06:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 197905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 81A9B2C0098 for ; Fri, 9 Nov 2012 11:06:32 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1353024393; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=u3jSFhT +HJPM/zz7n6jUvLDnl1I=; b=gvLgTU44WTqY4KSo6lljgE8R6+n/VgUMT3BexwR N/ToRwxjJhndAJ3llvi1kov8csTTBUvW1OKd/y8HVIMZ2YOjDC9vAT87i8Ty9oNP 4qM3NUPYg0B4NfP03xfkjm421hy2Xbn5vZDnjwvi6p4bno3cQt846g9ZESrR9Kux 8duQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=c+aW3Qxr87U+HDSUdH9pTDlTk7obPBkrNtxyh+NB/znJ3xc7t7ebR568vdfXqh ek7zyhIJIyLn6meeVLVYvNRIsUmVjeokqk4iN/txB1BDIgGvCLR3tV4p3NBtKDhg qOgn+K92No97Kq2FPGwaNFjBkyL+z0nTgIo6ZhjZK9uNI=; Received: (qmail 3565 invoked by alias); 9 Nov 2012 00:06:26 -0000 Received: (qmail 3552 invoked by uid 22791); 9 Nov 2012 00:06:26 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Nov 2012 00:06:18 +0000 Received: by mail-pb0-f47.google.com with SMTP id ro12so2283216pbb.20 for ; Thu, 08 Nov 2012 16:06:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=nKHCLpx8sAYJnvJkZ6/k5kf1jvSx/ug9dzvyTpqN2ME=; b=kOcpW2bb6DkKaswIKAksqLs+VXYcRhoFmvnS/hNjElroHHnVrqv/S+7g/BQjeov5BP kbCwqeskQQTNmlm0v7agHQlDQ14bs4K4FgqADGRaO/ludH7eB3U4GBFd+0cAHR29PSpd 2Vr6wJFbd8kfhDtOEib1fAlUuczolBmMa81wUK67aUXHHKCu13Z26164jln+RZKivcG6 m3ZHcTaJpJFv3Z/t4/xqE4lfBVjyAkmU/lObTBxwR55dPxdDeGjYauT6nzk9Sa1HJczX tE+7gHgn/vmKqQrEIYC9u/iQpYak8l5WdSPKcc4rF+3aZZUg04Du+CH7nml2CAEG5GJA NXQw== Received: by 10.68.189.163 with SMTP id gj3mr14012518pbc.110.1352419577486; Thu, 08 Nov 2012 16:06:17 -0800 (PST) Received: from coign.google.com ([172.19.250.86]) by mx.google.com with ESMTPS id c8sm16895801pav.4.2012.11.08.16.06.15 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Nov 2012 16:06:16 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Update index.go in testsuite Date: Thu, 08 Nov 2012 16:06:14 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmiBVQOHmXZPYEg4QxZ6ZE4xAZLZSeGg/EZOLHIkXhvK2jYQSno6VS25z4HvUjyjZ5VrW4sMa0QALy2yQj5urMx5L6uamPc/qcX8wzggt1lx6KmW2TCd+nQ7ve5NQFLlXhpAbswaLzaSfJSNz4bAkR64t5tCJ+LjKGJGgEFrZwCa4EqR5zxDtrWQ6jgQroIgg7oUS7F X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch to the Go testsuite updates index.go to the version currently in mainline. This required adding some new support to the Go testsuite driver. This fixes PR go/55228. Ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian Index: go.test/test/index0.go =================================================================== --- go.test/test/index0.go (revision 0) +++ go.test/test/index0.go (revision 0) @@ -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 Index: go.test/test/index1.go =================================================================== --- go.test/test/index1.go (revision 0) +++ go.test/test/index1.go (revision 0) @@ -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 Index: go.test/test/index2.go =================================================================== --- go.test/test/index2.go (revision 0) +++ go.test/test/index2.go (revision 0) @@ -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 Index: go.test/test/index.go =================================================================== --- go.test/test/index.go (revision 193259) +++ go.test/test/index.go (working copy) @@ -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 stri 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 Index: go.test/go-test.exp =================================================================== --- go.test/go-test.exp (revision 193259) +++ go.test/go-test.exp (working copy) @@ -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] } {