From 363f2f3df99f3edd15609cc6bea2a2c6f423ce2c Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Fri, 10 Sep 2021 13:16:32 -0400 Subject: [dev.fuzz] testing: allow -fuzzminimizetime to be 0 Fixes golang/go#48321 Change-Id: I1547379eb7a703f7f3c4594d27833eb3587796a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/349089 Trust: Katie Hockman Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Jay Conrod --- src/testing/benchmark.go | 9 +++++---- src/testing/fuzz.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/testing') diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index c8571a5f5a..30fa106dd4 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -36,8 +36,9 @@ var ( ) type durationOrCountFlag struct { - d time.Duration - n int + d time.Duration + n int + allowZero bool } func (f *durationOrCountFlag) String() string { @@ -50,14 +51,14 @@ func (f *durationOrCountFlag) String() string { func (f *durationOrCountFlag) Set(s string) error { if strings.HasSuffix(s, "x") { n, err := strconv.ParseInt(s[:len(s)-1], 10, 0) - if err != nil || n <= 0 { + if err != nil || n < 0 || (!f.allowZero && n == 0) { return fmt.Errorf("invalid count") } *f = durationOrCountFlag{n: int(n)} return nil } d, err := time.ParseDuration(s) - if err != nil || d <= 0 { + if err != nil || d < 0 || (!f.allowZero && d == 0) { return fmt.Errorf("invalid duration") } *f = durationOrCountFlag{d: d} diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index 975aa87eab..d94ec35dc7 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -28,7 +28,7 @@ func initFuzzFlags() { var ( matchFuzz *string fuzzDuration durationOrCountFlag - minimizeDuration = durationOrCountFlag{d: 60 * time.Second} + minimizeDuration = durationOrCountFlag{d: 60 * time.Second, allowZero: true} fuzzCacheDir *string isFuzzWorker *bool -- cgit v1.3