libgo/testsuite: add benchmarks and examples to list

In CL 384695 I simplified the code that built lists of benchmarks,
examples, and fuzz tests, and managed to break it. This CL corrects
the code to once again make the benchmarks available, and to run
the examples with output and the fuzz targets.

Doing this revealed a test failure in internal/fuzz on 32-bit x86:
a signalling NaN is turned into a quiet NaN on the 387 floating-point
stack that GCC uses by default. This CL skips the test.

Fixes golang/go#60826

Change-Id: I103669e11fe2c03c8c824a96d19cc459c47464ee
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/503798
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/libgo/go/internal/fuzz/encoding_test.go b/libgo/go/internal/fuzz/encoding_test.go
index 8e3800e..53fc5b8 100644
--- a/libgo/go/internal/fuzz/encoding_test.go
+++ b/libgo/go/internal/fuzz/encoding_test.go
@@ -6,6 +6,7 @@
 
 import (
 	"math"
+	"runtime"
 	"strconv"
 	"testing"
 	"unicode"
@@ -330,6 +331,14 @@
 	f.Add(math.Float64bits(math.Inf(-1)))
 
 	f.Fuzz(func(t *testing.T, u1 uint64) {
+		// The signaling NaN test fails on 32-bit x86 with gccgo,
+		// which uses the 387 floating-point stack by default.
+		// Converting a signaling NaN in and out of the stack
+		// changes the NaN to a quiet NaN.
+		if runtime.GOARCH == "386" && u1 == 0x7FF0000000000001 {
+			t.Skip("skipping signalling NaN test on 386 with gccgo")
+		}
+
 		x1 := math.Float64frombits(u1)
 
 		b := marshalCorpusFile(x1)
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index 0a0a7e1..33c98d8 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -577,13 +577,13 @@
 # Find Go benchmark/fuzz/example functions.
 # The argument is the function name prefix.
 findfuncs() {
-	pattern='$1([^a-z].*)?'
+	pattern="$1([^a-z].*)?"
 	syms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
 	if $havex; then
 	    xsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
 	    syms="$syms $xsyms"
 	fi
-        $(symtogo "$benchmarksyms")
+        symtogo "$syms"
 }
 
 # Takes an example name and puts any output into the file example.txt.
@@ -643,11 +643,13 @@
 	fi
 	if $havex; then
 	    needxtest=false
-	    if test -n "$testxsyms" -o -n "$benchmarkxsyms"; then
+	    if test -n "$testxsyms"; then
+		needxtest=true
+	    elif echo "$benchmarks" | grep '_test\.' >/dev/null; then
 		needxtest=true
 	    else
 		# Check whether any example has output.
-		for i in $(symtogo "$examplexsyms"); do
+		for i in $(echo "$examples" | grep '_test\.'); do
 		    exampleoutput $i
 		    if test -f example.txt; then
 			rm -f example.txt