diff options
| author | Roland Shoemaker <roland@golang.org> | 2021-05-19 11:43:58 -0700 |
|---|---|---|
| committer | Roland Shoemaker <roland@golang.org> | 2021-05-27 02:14:18 +0000 |
| commit | 5fcd18bc9bd89bad5270434f99d40e820affbd82 (patch) | |
| tree | 10df22a9eba3f771c7f4a3d8d27b18b11c011264 /src/testing/fuzz.go | |
| parent | ff0164cf736b12740bf5837111e93130da6d612c (diff) | |
| download | go-5fcd18bc9bd89bad5270434f99d40e820affbd82.tar.xz | |
[dev.fuzz] internal/fuzz,testing: treat panics as recoverable
And only log the last panic, not all of them, during minimization.
This change makes the worker processes quiet, so now the only
process that logs anything is the coordinator. This hides all of
the panics caused during minimization of an input which causes
a panic.
This change also alters the usage of tRunner such that we now
recover from recoverable panics instead of terminating the
process. This results in larger stack traces, since we include
a bit more of the trace within testing. There is a TODO to see
if it's possible to slice the stack up so that it is somewhat
more informative.
Change-Id: Ic85eabd2e70b078412fbb88adf424a8da25af876
Reviewed-on: https://go-review.googlesource.com/c/go/+/321230
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src/testing/fuzz.go')
| -rw-r--r-- | src/testing/fuzz.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index 9364b27eaf..78a0a600fa 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -8,6 +8,7 @@ import ( "errors" "flag" "fmt" + "io" "os" "path/filepath" "reflect" @@ -313,6 +314,7 @@ func (f *F) Fuzz(ff interface{}) { if e.Name != "" { testName = fmt.Sprintf("%s/%s", testName, e.Name) } + // Record the stack trace at the point of this call so that if the subtest // function - which runs in a separate stack - is marked as a helper, we can // continue walking the stack into the parent test. @@ -327,6 +329,7 @@ func (f *F) Fuzz(ff interface{}) { level: f.level + 1, creator: pc[:n], chatty: f.chatty, + fuzzing: true, }, context: f.testContext, } @@ -541,12 +544,13 @@ func runFuzzing(deps testDeps, fuzzTargets []InternalFuzzTarget) (ran, ok bool) resetCoverage: deps.ResetCoverage, snapshotCoverage: deps.SnapshotCoverage, } + root := common{w: os.Stdout} if *isFuzzWorker { + root.w = io.Discard fctx.runFuzzWorker = deps.RunFuzzWorker } else { fctx.coordinateFuzzing = deps.CoordinateFuzzing } - root := common{w: os.Stdout} if Verbose() && !*isFuzzWorker { root.chatty = newChattyPrinter(root.w) } |
