From b178a81e1f95eea38893e6da8daa3260d3e601de Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Mon, 5 Apr 2021 11:40:12 -0400 Subject: [dev.fuzz] internal/fuzz: don't count time spent loading corpus The -fuzztime flag tells us how much time to spend fuzzing, not counting time spent running the seed corpus. We shouldn't count time spent loading the cache either. If the cache is large, the time limit may be exceeded before the coordinator starts the workers. Change-Id: If00435faa5d24aabdb9003ebb9337fa2e47f22b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/307310 Trust: Jay Conrod Trust: Katie Hockman Run-TryBot: Jay Conrod Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Katie Hockman --- src/testing/internal/testdeps/deps.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/testing') diff --git a/src/testing/internal/testdeps/deps.go b/src/testing/internal/testdeps/deps.go index 8f587b2e1d..c77aca3da8 100644 --- a/src/testing/internal/testdeps/deps.go +++ b/src/testing/internal/testdeps/deps.go @@ -137,14 +137,9 @@ func (TestDeps) CoordinateFuzzing(timeout time.Duration, parallel int, seed []fu // Fuzzing may be interrupted with a timeout or if the user presses ^C. // In either case, we'll stop worker processes gracefully and save // crashers and interesting values. - ctx, cancel := context.WithCancel(context.Background()) - if timeout > 0 { - ctx, cancel = context.WithTimeout(ctx, timeout) - } - ctx, stop := signal.NotifyContext(ctx, os.Interrupt) - defer stop() + ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() - err = fuzz.CoordinateFuzzing(ctx, parallel, seed, types, corpusDir, cacheDir) + err = fuzz.CoordinateFuzzing(ctx, timeout, parallel, seed, types, corpusDir, cacheDir) if err == ctx.Err() { return nil } @@ -158,9 +153,7 @@ func (TestDeps) RunFuzzWorker(fn func(fuzz.CorpusEntry) error) error { // If the worker is interrupted, return quickly and without error. // If only the coordinator process is interrupted, it tells each worker // process to stop by closing its "fuzz_in" pipe. - ctx, cancel := context.WithCancel(context.Background()) - ctx, stop := signal.NotifyContext(ctx, os.Interrupt) - defer stop() + ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() err := fuzz.RunFuzzWorker(ctx, fn) if err == ctx.Err() { -- cgit v1.3