aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2021-08-16 15:09:05 -0700
committerJay Conrod <jayconrod@google.com>2021-08-20 20:13:57 +0000
commitf89b4c8d82c028d635eb8e685dd92dceb0027438 (patch)
tree1f1f12caaa7569e2fe1d59eede07a923a4ae6880 /src
parent4e07341afd65e4000466b6b324781e8c3565a0d9 (diff)
downloadgo-f89b4c8d82c028d635eb8e685dd92dceb0027438.tar.xz
[dev.fuzz] cmd/go: exclude additional packages from fuzzing instrumentation
Counters in these packages are incremented by background goroutines for testing and internal/fuzz. They cause some inputs to seem "interesting" when they don't directly provide new coverage. Updates golang/go#46410 Change-Id: Ibe6bb3177f3b2ba23382a1693a4c6a576f94a423 Reviewed-on: https://go-review.googlesource.com/c/go/+/342993 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/internal/test/test.go11
-rw-r--r--src/cmd/go/testdata/script/test_fuzz_cache.txt18
2 files changed, 22 insertions, 7 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index 012a75123b..75345a8223 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -831,11 +831,18 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
fuzzFlags := work.FuzzInstrumentFlags()
if testFuzz != "" && fuzzFlags != nil {
// Don't instrument packages which may affect coverage guidance but are
- // unlikely to be useful.
+ // unlikely to be useful. Most of these are used by the testing or
+ // internal/fuzz concurrently with fuzzing.
var fuzzNoInstrument = map[string]bool{
- "testing": true,
+ "context": true,
"internal/fuzz": true,
+ "reflect": true,
"runtime": true,
+ "sync": true,
+ "sync/atomic": true,
+ "syscall": true,
+ "testing": true,
+ "time": true,
}
for _, p := range load.TestPackageList(ctx, pkgOpts, pkgs) {
if fuzzNoInstrument[p.ImportPath] {
diff --git a/src/cmd/go/testdata/script/test_fuzz_cache.txt b/src/cmd/go/testdata/script/test_fuzz_cache.txt
index a6c9cafada..10e4c2926f 100644
--- a/src/cmd/go/testdata/script/test_fuzz_cache.txt
+++ b/src/cmd/go/testdata/script/test_fuzz_cache.txt
@@ -35,19 +35,27 @@ go 1.16
-- y_test.go --
package y
-import "testing"
+import (
+ "io"
+ "testing"
+)
func FuzzY(f *testing.F) {
f.Add([]byte("y"))
- f.Fuzz(func(t *testing.T, b []byte) { Y(b) })
+ f.Fuzz(func(t *testing.T, b []byte) { Y(io.Discard, b) })
}
-- y.go --
package y
-import "bytes"
+import (
+ "bytes"
+ "io"
+)
-func Y(b []byte) bool {
- return bytes.Equal(b, []byte("y"))
+func Y(w io.Writer, b []byte) {
+ if !bytes.Equal(b, []byte("y")) {
+ w.Write([]byte("not equal"))
+ }
}
-- empty/empty.go --
package empty