]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.fuzz] internal/fuzz: remove duplicate read from testdata
authorKatie Hockman <katie@golang.org>
Wed, 17 Feb 2021 19:56:47 +0000 (14:56 -0500)
committerKatie Hockman <katie@golang.org>
Thu, 18 Feb 2021 20:18:03 +0000 (20:18 +0000)
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 <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/internal/fuzz/fuzz.go

index 3b2baaf3a5aece8d8b40d15e33ae1077365821eb..ef009334f787d741282ee908e89629709fdd20dd 100644 (file)
@@ -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
 }