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/testing/testing.go | |
| 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/testing/testing.go')
| -rw-r--r-- | src/testing/testing.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go index 48e9ee089f..da26dec6fb 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1039,6 +1039,12 @@ func (t *T) Parallel() { panic("testing: t.Parallel called multiple times") } t.isParallel = true + if t.parent.barrier == nil { + // T.Parallel has no effect when fuzzing. + // Multiple processes may run in parallel, but only one input can run at a + // time per process so we can attribute crashes to specific inputs. + return + } // We don't want to include the time we spend waiting for serial tests // in the test duration. Record the elapsed time thus far and reset the |
