]> Cypherpunks repositories - gostls13.git/commit
[dev.fuzz] cmd/go: implement -fuzztime flag and support cancellation
authorJay Conrod <jayconrod@google.com>
Thu, 17 Dec 2020 22:25:42 +0000 (17:25 -0500)
committerJay Conrod <jayconrod@google.com>
Wed, 23 Dec 2020 16:33:50 +0000 (16:33 +0000)
commita1646595e63cc0bf7f566bb9b657f826cbda22a1
tree56f50513d0ee0e56fda0125cd38c72bc12ded09a
parent3ea342eb2e2f65a02bc84e206a4e7615747df49a
[dev.fuzz] cmd/go: implement -fuzztime flag and support cancellation

fuzz.CoordinateFuzzing and RunFuzzWorker now accept a context.Context
parameter. They should terminate gracefully when the context is
cancelled. The worker should exit quickly without processing more
inputs. The coordinator should save interesting inputs to the cache.

The testing package can't import context directly, so it provides a
timeout argument to testdeps.CoordinateFuzzing instead. The testdeps
wrapper sets the timeout and installs an interrupt handler (for SIGINT
on POSIX and the equivalent on Windows) that cancels the context when
^C is pressed.

Note that on POSIX platforms, pressing ^C causes the shell to deliver
SIGINT to all processes in the active group: so 'go test', the
coordinator, and the workers should all react to that. On Windows,
pressing ^C only interrupts 'go test'. We may want to look at that
separately.

Change-Id: I924d3be2905f9685dae82ff3c047ca3d6b5e2357
Reviewed-on: https://go-review.googlesource.com/c/go/+/279487
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
14 files changed:
src/cmd/go/internal/test/flagdefs.go
src/cmd/go/internal/test/genflags.go
src/cmd/go/internal/test/testflag.go
src/cmd/go/testdata/script/test_fuzz.txt
src/cmd/go/testdata/script/test_fuzz_cache.txt
src/cmd/go/testdata/script/test_fuzz_fuzztime.txt [new file with mode: 0644]
src/cmd/go/testdata/script/test_fuzz_match.txt
src/cmd/go/testdata/script/test_fuzz_mutate.txt
src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt
src/internal/fuzz/fuzz.go
src/internal/fuzz/worker.go
src/testing/fuzz.go
src/testing/internal/testdeps/deps.go
src/testing/testing.go