From bb53bd49571e08909ab6274255ddddd6c6ffe041 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 13 May 2021 13:13:26 -0400 Subject: [PATCH] [dev.fuzz] cmd/go: fix test_fuzz_cache 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 Run-TryBot: Jay Conrod Reviewed-by: Katie Hockman --- src/cmd/go/testdata/script/test_fuzz_cache.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/testdata/script/test_fuzz_cache.txt b/src/cmd/go/testdata/script/test_fuzz_cache.txt index cb344a7158..a6c9cafada 100644 --- a/src/cmd/go/testdata/script/test_fuzz_cache.txt +++ b/src/cmd/go/testdata/script/test_fuzz_cache.txt @@ -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 -- 2.48.1