]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.fuzz] cmd/go: fix test_fuzz_cache
authorJay Conrod <jayconrod@google.com>
Thu, 13 May 2021 17:13:26 +0000 (13:13 -0400)
committerJay Conrod <jayconrod@google.com>
Wed, 19 May 2021 16:44:18 +0000 (16:44 +0000)
This test started failing when coverage-based fuzzing was enabled.
It expects at least one file to be written to the fuzz cache. Nothing
was written because the fuzz function was trivial, and no interesting
inputs could be discovered.

This CL makes the fuzz function return different values for different
inputs, which is enough to pass.

Change-Id: I6ffd2667891cf5f3e4588133efb65f096a739c09
Reviewed-on: https://go-review.googlesource.com/c/go/+/319871
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
src/cmd/go/testdata/script/test_fuzz_cache.txt

index cb344a71587734afdab4130bb5bc5ec86649e9f3..a6c9cafada4d69f98acd69a9059d8d1f39b0860d 100644 (file)
@@ -39,7 +39,15 @@ import "testing"
 
 func FuzzY(f *testing.F) {
        f.Add([]byte("y"))
-       f.Fuzz(func(t *testing.T, b []byte) {})
+       f.Fuzz(func(t *testing.T, b []byte) { Y(b) })
+}
+-- y.go --
+package y
+
+import "bytes"
+
+func Y(b []byte) bool {
+       return bytes.Equal(b, []byte("y"))
 }
 -- empty/empty.go --
 package empty