diff options
author | Katie Hockman <katie@golang.org> | 2021-11-10 16:22:08 -0500 |
---|---|---|
committer | Katie Hockman <katie@golang.org> | 2021-11-12 18:48:59 +0000 |
commit | 5d24203c394e6b64c42a9f69b990d94cb6c8aad4 (patch) | |
tree | 8e523bd001a7f4d20440b332cc94863b969aa373 /src/cmd/go | |
parent | 8b66b3d49f931715c52b4ed71bc1dc935132c30f (diff) | |
download | go-5d24203c394e6b64c42a9f69b990d94cb6c8aad4.tar.gz go-5d24203c394e6b64c42a9f69b990d94cb6c8aad4.zip |
internal/fuzz: set timeout for each exec of fuzz target
This change sets a timeout of 10 seconds on each
execution of the fuzz target, both during fuzzing
and during minimization. This is not currently
customizable by the user, but issue #48157 tracks
this work.
Deadlocks will be considered non-recoverable errors,
and as such, will not be minimizable.
Fixes #48591
Change-Id: Ic86e8e9e9a0255e7860f7cbf5654e832785d1cbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/363134
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go')
4 files changed, 18 insertions, 4 deletions
diff --git a/src/cmd/go/testdata/script/test_fuzz_minimize.txt b/src/cmd/go/testdata/script/test_fuzz_minimize.txt index 462fb9a963..a6dc3f1953 100644 --- a/src/cmd/go/testdata/script/test_fuzz_minimize.txt +++ b/src/cmd/go/testdata/script/test_fuzz_minimize.txt @@ -67,7 +67,7 @@ rm testdata ! go test -fuzz=FuzzMinimizerNonrecoverable -run=FuzzMinimizerNonrecoverable -fuzztime=10000x . ! stdout '^ok' ! stdout 'minimizing' -stdout -count=1 'fuzzing process terminated unexpectedly: exit status 99' +stdout -count=1 '^\s+fuzzing process hung or terminated unexpectedly: exit status 99' stdout FAIL # Check that re-running the value causes a crash. diff --git a/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt b/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt index 4c4fa8e651..99bae1daf0 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutate_crash.txt @@ -54,9 +54,14 @@ go run check_testdata.go FuzzWithFatalf ! go test -run=FuzzWithBadExit -fuzz=FuzzWithBadExit -fuzztime=100x -fuzzminimizetime=1000x stdout 'testdata[/\\]fuzz[/\\]FuzzWithBadExit[/\\]' -stdout 'unexpectedly' +stdout '^\s+fuzzing process hung or terminated unexpectedly: exit status' go run check_testdata.go FuzzWithBadExit +! go test -run=FuzzDeadlock -fuzz=FuzzDeadlock -fuzztime=100x -fuzzminimizetime=0x +stdout 'testdata[/\\]fuzz[/\\]FuzzDeadlock[/\\]' +stdout '^\s+fuzzing process hung or terminated unexpectedly: exit status' +go run check_testdata.go FuzzDeadlock + # Running the fuzzer should find a crashing input quickly for fuzzing two types. ! go test -run=FuzzWithTwoTypes -fuzz=FuzzWithTwoTypes -fuzztime=100x -fuzzminimizetime=1000x stdout 'testdata[/\\]fuzz[/\\]FuzzWithTwoTypes[/\\]' @@ -190,6 +195,15 @@ func FuzzWithBadExit(f *testing.F) { }) } +func FuzzDeadlock(f *testing.F) { + f.Add(int(0)) + f.Fuzz(func(t *testing.T, n int) { + if n != 0 { + select {} + } + }) +} + func FuzzWithTwoTypes(f *testing.F) { f.Fuzz(func(t *testing.T, a, b []byte) { if len(a) > 0 && len(b) > 0 { diff --git a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt index 60f5787464..3764dcb915 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt @@ -12,7 +12,7 @@ # The fuzzing engine reconstructs the crashing input and saves it to testdata. ! exists want ! go test -fuzz=. -parallel=1 -fuzztime=110x -fuzzminimizetime=10x -v -stdout 'fuzzing process terminated unexpectedly' +stdout '^\s+fuzzing process hung or terminated unexpectedly: exit status' stdout 'Failing input written to testdata' # Run the fuzz target without fuzzing. The fuzz function is called with the diff --git a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt index 31d54bcb70..1051292fcb 100644 --- a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt +++ b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt @@ -25,7 +25,7 @@ stdout 'fuzzing process terminated by unexpected signal; no crash will be record # We should save a crasher. ! go test -fuzz=FuzzCrash exists testdata/fuzz/FuzzCrash -stdout 'fuzzing process terminated unexpectedly' +stdout '^\s+fuzzing process hung or terminated unexpectedly: exit status' -- go.mod -- module test |