]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.fuzz] cmd/go/testdata: fix flaky test
authorKatie Hockman <katie@golang.org>
Fri, 15 Jan 2021 16:26:34 +0000 (11:26 -0500)
committerKatie Hockman <katie@golang.org>
Fri, 15 Jan 2021 17:05:30 +0000 (17:05 +0000)
Change-Id: I7702aa12a1ed9bb0645af774dd584e661d7c8fa5
Reviewed-on: https://go-review.googlesource.com/c/go/+/284193
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/cmd/go/testdata/script/test_fuzz_mutator.txt

index f858dcf35469af83686735eae91ca7820ce29026..bc7edf3cc5210fc7c7af86fee1fcf360532b2ad1 100644 (file)
@@ -14,7 +14,7 @@ go run check_logs.go fuzz fuzz.worker
 ! go test -v -fuzz=Fuzz -parallel=1 -fuzztime=30s mutator_test.go
 ! stdout ok
 stdout FAIL
-stdout 'mutator found enough edge cases'
+stdout 'mutator found enough unique mutations'
 
 -- go.mod --
 module m
@@ -162,7 +162,6 @@ func checkWorkerLog(r io.Reader) error {
 package fuzz_test
 
 import (
-       "strings"
        "testing"
 )
 
@@ -175,22 +174,9 @@ func Fuzz(f *testing.F) {
        crashes := make(map[string]bool)
        // No seed corpus initiated
        f.Fuzz(func(t *testing.T, b []byte) {
-               if len(crashes) >= 150 {
-                       panic("mutator found enough edge cases")
-               }
-
-               if len(b) < 5 {
-                       return // continue
-               }
-
-               for i := 0; i < 256; i++ {
-                       s := string(byte(i))
-                       if strings.HasPrefix(string(b), s) {
-                               crashes["pre-" + s] = true
-                       }
-                       if strings.HasSuffix(string(b), s) {
-                               crashes["suffix-" + s] = true
-                       }
+               crashes[string(b)] = true
+               if len(crashes) >= 1000 {
+                       panic("mutator found enough unique mutations")
                }
        })
 }
\ No newline at end of file