From 1c162b41c5a6233d20cf714cb46764c14c61db03 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Wed, 17 Feb 2021 14:56:47 -0500 Subject: [PATCH] [dev.fuzz] internal/fuzz: remove duplicate read from testdata We already read the seed corpus from testdata for the fuzz target, and pass that corpus to the coordinator. The coordinator doesn't need to read from testdata again. Change-Id: Ia7822e3e02b35d56f6918c7082a7b19901b36644 Reviewed-on: https://go-review.googlesource.com/c/go/+/293189 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Jay Conrod --- src/internal/fuzz/fuzz.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index 3b2baaf3a5..ef009334f7 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -49,7 +49,7 @@ func CoordinateFuzzing(ctx context.Context, parallel int, seed []CorpusEntry, co } sharedMemSize := 100 << 20 // 100 MB - corpus, err := readCorpusAndCache(seed, corpusDir, cacheDir) + corpus, err := readCache(seed, cacheDir) if err != nil { return err } @@ -262,7 +262,7 @@ type coordinator struct { errC chan error } -// readCorpusAndCache creates a combined corpus from seed values, values in the +// readCache creates a combined corpus from seed values, values in the // corpus directory (in testdata), and values in the cache (in GOCACHE/fuzz). // // TODO(jayconrod,katiehockman): if a value in the cache has the wrong type, @@ -270,16 +270,14 @@ type coordinator struct { // the same package at a different version or in a different module. // TODO(jayconrod,katiehockman): need a mechanism that can remove values that // aren't useful anymore, for example, because they have the wrong type. -func readCorpusAndCache(seed []CorpusEntry, corpusDir, cacheDir string) (corpus, error) { +func readCache(seed []CorpusEntry, cacheDir string) (corpus, error) { var c corpus c.entries = append(c.entries, seed...) - for _, dir := range []string{corpusDir, cacheDir} { - entries, err := ReadCorpus(dir) - if err != nil { - return corpus{}, err - } - c.entries = append(c.entries, entries...) + entries, err := ReadCorpus(cacheDir) + if err != nil { + return corpus{}, err } + c.entries = append(c.entries, entries...) return c, nil } -- 2.48.1