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>
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] {
-- 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