From cc04ab463dd6c86ad8d22bbadba4d325fffa2131 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Wed, 23 Jun 2021 16:23:37 -0700 Subject: [dev.fuzz] testing: report T.Deadline when running seed values T.Deadline should return the test deadline, set with -timeout. When fuzz targets are run with seed values as unit tests, either with or without -fuzz, T.Deadline should work inside the fuzz function. There is no deadline when fuzzing, even if -fuzztime is set, since workers may have much shorter deadlines, and fuzz function behavior shouldn't be time-dependent anyway. Fixes #46220 Change-Id: I84aaeb9d7bfdc12bdcb6f1ab3fe67b3067ad2dfe Reviewed-on: https://go-review.googlesource.com/c/go/+/330509 Trust: Jay Conrod Trust: Katie Hockman Run-TryBot: Jay Conrod TryBot-Result: Go Bot Reviewed-by: Katie Hockman --- src/testing/fuzz.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/testing/fuzz.go') diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index fc1212b142..55e5397193 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -491,13 +491,14 @@ type fuzzContext struct { // runFuzzTargets runs the fuzz targets matching the pattern for -run. This will // only run the f.Fuzz function for each seed corpus without using the fuzzing // engine to generate or mutate inputs. -func runFuzzTargets(deps testDeps, fuzzTargets []InternalFuzzTarget) (ran, ok bool) { +func runFuzzTargets(deps testDeps, fuzzTargets []InternalFuzzTarget, deadline time.Time) (ran, ok bool) { ok = true if len(fuzzTargets) == 0 || *isFuzzWorker { return ran, ok } m := newMatcher(deps.MatchString, *match, "-test.run") tctx := newTestContext(*parallel, m) + tctx.deadline = deadline fctx := &fuzzContext{ importPath: deps.ImportPath, readCorpus: deps.ReadCorpus, -- cgit v1.3-5-g9baa