From patchwork Wed Jan 25 00:05:56 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: 137690 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 9F24D1007D2 for ; Wed, 25 Jan 2012 11:06:30 +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=1328054791; h=Comment: DomainKey-Signature:Received: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=6WzAWbHB8p/L15G7DUT50NYh3Sg=; b=o1HeKPFWqQ6WpZx VfIFsd27iFqHsAaGQZ2MykAnJBusM7rxISV7dxtfautFxKa9ND6PeMyl5Tx8v+tJ Drdoqq0Z4NjKIrU0zqfA9n8hbo2TsUncKcOsLjiT9tyE4/jnxCxOG2HC3FnAZuf8 3/L5Uvcaegdq0zm5nIvHFQZtEprY= 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:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:X-Gm-Message-State:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=DrPDpzo+wDI/dtLzScUQo9ky76yrk5gr/5RJ8+CZPU9NJsFyG+eXBpX2HEFk0D HK3CljFn/vMNr0qbQsl/mdNbAeqjjzp1bVnCudTk71shGstMPmHXvDlfaW23WhLh aQmF4CbBYsEJsQ9XApHp/y769m4flV+e2yFdpS8pZcLfA=; Received: (qmail 20159 invoked by alias); 25 Jan 2012 00:06:22 -0000 Received: (qmail 20145 invoked by uid 22791); 25 Jan 2012 00:06:19 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Jan 2012 00:06:00 +0000 Received: by iabz21 with SMTP id z21so7862046iab.20 for ; Tue, 24 Jan 2012 16:05:59 -0800 (PST) Received: by 10.50.156.196 with SMTP id wg4mr2617890igb.13.1327449959001; Tue, 24 Jan 2012 16:05:59 -0800 (PST) Received: by 10.50.156.196 with SMTP id wg4mr2617876igb.13.1327449958895; Tue, 24 Jan 2012 16:05:58 -0800 (PST) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id xu6sm31048474igb.7.2012.01.24.16.05.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jan 2012 16:05:57 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Update to current Go testsuite Date: Tue, 24 Jan 2012 16:05:56 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmavDQ4L4tiEXTf7pg1Eavd4ynusr1D9RdBsaggcisUzt2OEFaYsDWv5obKW42fehDZi5Sn82M44qJrG1RM6h6TdDkufo/4/ekBapz1ZZBCNaaWXIrxoMbEz90LXKG8gSmGI0ChWb20DPFniaL9xuiCNaBfjgrqINDPEYc0Bs7oUvhXXlw= 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 I have committed a patch to update the testsuite under gcc/testsuite/go.test/test to the current Go testsuite. This overall patch is too large to include in this e-mail message. There were some changes to the testsuite driver, which I have included here. Ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian 2012-01-24 Ian Lance Taylor * go.test/go-test.exp (filecmp): New procedure. (errchk): Handle quoted square brackets. (go-gc-tests): Set go_compile_args. Handle various new test lines. Skip a few new tests. * lib/go-torture.exp (go-torture-execute): Use go_compile_args. Index: go.test/go-test.exp =================================================================== --- go.test/go-test.exp (revision 183501) +++ go.test/go-test.exp (working copy) @@ -34,6 +34,38 @@ load_lib go-dg.exp load_lib go-torture.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 @@ -56,6 +88,14 @@ proc errchk { test opts } { 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. @@ -199,6 +239,7 @@ proc go-gc-tests { } { global TOOL_OPTIONS global TORTURE_OPTIONS global dg-do-what-default + global go_compile_args global go_execute_args global target_triplet @@ -230,13 +271,10 @@ proc go-gc-tests { } { continue } - # Skip the files in bench and garbage; they are not tests. + # Skip the files in bench; they are not tests. if [string match "*go.test/test/bench/*" $test] { continue } - if [string match "*go.test/test/garbage/*" $test] { - continue - } # Skip files in sub-subdirectories: they are components of # other tests. @@ -274,6 +312,20 @@ proc go-gc-tests { } { 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 + } + set fd [open $test r] set lines_ok 1 @@ -290,7 +342,8 @@ proc go-gc-tests { } { 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 "*exit 0*Android*" $test_line ] \ + || [ string match "*\"\$GOOS\" == windows*" $test_line ] } { continue } @@ -320,8 +373,9 @@ proc go-gc-tests { } { close $fd + set go_compile_args "" set go_execute_args "" - if { [regexp ".*\\\$A.out (\[^|&>\].*)\$" $test_line match progargs] } { + 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] @@ -393,6 +447,33 @@ proc go-gc-tests { } { # 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 \$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] \ @@ -405,6 +486,10 @@ proc go-gc-tests { } { } 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*" \ @@ -452,13 +537,27 @@ proc go-gc-tests { } { errchk $test "" } elseif { [string match \ "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \ - $test_line] } { + $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/bug0.go" file1 + regsub "\\.go$" $test ".dir/$name1" file1 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" - regsub "\\.go$" $test ".dir/bug1.go" file2 + 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 @@ -650,14 +749,28 @@ proc go-gc-tests { } { 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 ] } { + $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/lib.go" file1 + 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/main.go" file2 + 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" @@ -705,7 +818,7 @@ proc go-gc-tests { } { errchk $file2 "" file delete "[file rootname [file tail $file1]].o" set runtests $hold_runtests - } elseif { [string match "// true*" $test_line] } { + } 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 &&" \ @@ -886,7 +999,7 @@ proc go-gc-tests { } { file delete $base-out.x go-torture-execute "./$base-out.go" } - # file delete $base-out.go + file delete $base-out.go } file delete $output_file set runtests $hold_runtests @@ -894,23 +1007,96 @@ proc go-gc-tests { } { 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 FAIL || true" } { + } 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 "" } Index: lib/go-torture.exp =================================================================== --- lib/go-torture.exp (revision 183501) +++ lib/go-torture.exp (working copy) @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Free Software Foundation, Inc. +# Copyright (C) 2009, 2011, 2012 Free Software Foundation, Inc. # 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 @@ -138,6 +138,7 @@ proc go-torture-execute { src } { global tool global compiler_conditional_xfail_data global TORTURE_OPTIONS + global go_compile_args global go_execute_args # Check for alternate driver. @@ -156,6 +157,9 @@ proc go-torture-execute { src } { set executable $tmpdir/[file tail [file rootname $src].x] regsub "(?q)$srcdir/" $src "" testcase + if { ! [info exists go_compile_args] } { + set go_compile_args "" + } if { ! [info exists go_execute_args] } { set go_execute_args "" } @@ -194,6 +198,9 @@ proc go-torture-execute { src } { if { $additional_flags != "" } { lappend options "additional_flags=$additional_flags" } + if { $go_compile_args != "" } { + lappend options "additional_flags=$go_compile_args" + } set comp_output [go_target_compile "$src" "$executable" executable $options] # See if we got something bad.