diff mbox

[gccgo] Update to current version of master Go testsuite

Message ID mcry6b96r51.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Sept. 11, 2010, 12:49 a.m. UTC
gccgo uses a copy of the master Go testsuite.  I have just updated that
copy to the current master sources.  The patch is too large to include
in this message, and is largely uninteresting since it is just a copy.
It may be found at SVN revision 164210.  I have appended the parts of
the patch which are not part of the master testsuite, which are patches
to the gcc testsuite harness to run the tests.

Ian
diff mbox

Patch

Index: go.test/go-test.exp
===================================================================
--- go.test/go-test.exp	(revision 164030)
+++ go.test/go-test.exp	(working copy)
@@ -42,8 +42,13 @@  proc errchk { test } {
     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 } {
 	regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
 	if [string match "*dg-error*.\**" $out_line] {
@@ -55,7 +60,12 @@  proc errchk { test } {
 	    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
+	}
 	if [string match "*dg-error*\[.\]*" $out_line] {
+	    set index [string first "dg-error" $out_line]
 	    regsub -all "\\\[\\.\\\]" $out_line "\\\\\[.\\\\\]" out_line
 	}
 	puts $fdout $out_line
@@ -116,10 +126,13 @@  proc go-gc-tests { } {
 	    continue
 	}
 
-	# Skip the files in bench; they are not tests.
+	# Skip the files in bench and garbage; 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.
@@ -151,21 +164,35 @@  proc go-gc-tests { } {
 	}
 
 	set fd [open $test r]
-	if { [gets $fd test_line] < 0 } {
-	    close $fd
-	    clone_output "$test: could not read first line"
-	    unresolved $name
-	    continue
+
+	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 ] } {
+		continue
+	    }
+
+	    break
 	}
-	if { [gets $fd test_line2] < 0 } {
-	    close $fd
-	    clone_output "$test: could not read second line"
-	    unresolved $name
+
+	if { $lines_ok == 0 } {
 	    continue
 	}
 
-	set lines_ok 1
-	set lineno 2
+	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 } {
@@ -304,13 +331,25 @@  proc go-gc-tests { } {
 	    set runtests $hold_runtests
 	} elseif { [string match \
 			"// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
-			$test_line] } {
+			$test_line] \
+		       || [string match \
+			       "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
+			       $test_line] } {
+	    if { [string match \
+		      "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
+		      $test_line] } {
+		set name1 "p1.go"
+		set name2 "p2.go"
+	    } else {
+		set name1 "bug0.go"
+		set name2 "bug1.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_GOFLAGS"
-	    regsub "\\.go$" $test ".dir/bug1.go" file2
+	    regsub "\\.go$" $test ".dir/$name2" file2
 	    errchk $file2
 	    file delete "[file rootname [file tail $file1]].o"
 	    set runtests $hold_runtests
@@ -532,8 +571,88 @@  proc go-gc-tests { } {
 	    }
 	    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" "$DEFAULT_GOFLAGS"]
+	    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 tmp1.\$A tmp.\$A && ./tmp1.\$A &&" \
+		       && $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_GOFLAGS"
+	    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
+		    go-torture-execute "./tmp.go"
+		}
+		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_GOFLAGS"
+	    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 { $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" } {
+	    # 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.
 	} else {
-	    clone_output "Unrecognized test line: $test_line"
+	    clone_output "$name: unrecognized test line: $test_line"
 	    unsupported $name
 	}
 
Index: lib/go-torture.exp
===================================================================
--- lib/go-torture.exp	(revision 163684)
+++ lib/go-torture.exp	(working copy)
@@ -261,6 +261,14 @@  proc go-torture-execute { src } {
 	set result [go_load "$executable" "$go_execute_args" ""]
 	set status [lindex $result 0]
 	set output [lindex $result 1]
+
+	# In order to cooperate nicely with the master Go testsuite,
+	# if the output contains the string BUG, we treat the test as
+	# failing.
+	if [ string match "*BUG*" $output ] {
+	    set status "fail"
+	}
+
         if { $status == "pass" } {
 	    catch { remote_file build delete $executable }
         }