diff options
| author | Jay Conrod <jayconrod@google.com> | 2021-03-10 11:11:59 -0500 |
|---|---|---|
| committer | Jay Conrod <jayconrod@google.com> | 2021-04-09 19:52:06 +0000 |
| commit | b2b6be71f27ef74510394dad822cfe8d5e56f4f4 (patch) | |
| tree | 1ca904318f643304e26fd38ce1afdf551de15729 /src/internal/fuzz | |
| parent | 4baa39ca22c34d4c224ac69da644c85dee196474 (diff) | |
| download | go-b2b6be71f27ef74510394dad822cfe8d5e56f4f4.tar.xz | |
[dev.fuzz] testing: support T.Parallel in fuzz functions
While running the seed corpus, T.Parallel acts like it does in
subtests started with T.Run: it blocks until all other non-parallel
subtests have finished, then unblocks when the barrier chan is
closed. A semaphore (t.context.waitParallel) limits the number of
tests that run concurrently (determined by -test.parallel).
While fuzzing, T.Parallel has no effect, other than asserting that it
can't be called multiple times. We already run different inputs in
concurrent processes, but we can't run inputs concurrently in the same
process if we want to attribute crashes to specific inputs.
Change-Id: I2bac08e647e1d92ea410c83c3f3558a033fe3dd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/300449
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src/internal/fuzz')
| -rw-r--r-- | src/internal/fuzz/worker.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go index f784a04a39..22c85618be 100644 --- a/src/internal/fuzz/worker.go +++ b/src/internal/fuzz/worker.go @@ -274,18 +274,20 @@ func (w *worker) start() (err error) { // stop returns the error the process terminated with, if any (same as // w.waitErr). // -// stop must be called once after start returns successfully, even if the -// worker process terminates unexpectedly. +// stop must be called at least once after start returns successfully, even if +// the worker process terminates unexpectedly. func (w *worker) stop() error { if w.termC == nil { panic("worker was not started successfully") } select { case <-w.termC: - // Worker already terminated, perhaps unexpectedly. + // Worker already terminated. if w.client == nil { - panic("worker already stopped") + // stop already called. + return w.waitErr } + // Possible unexpected termination. w.client.Close() w.cmd = nil w.client = nil |
