]> Cypherpunks repositories - gostls13.git/commit
[dev.fuzz] internal/fuzz: rework default test behavior before fuzzing
authorKatie Hockman <katie@golang.org>
Mon, 13 Sep 2021 16:23:43 +0000 (12:23 -0400)
committerKatie Hockman <katie@golang.org>
Thu, 16 Sep 2021 13:37:34 +0000 (13:37 +0000)
commit5ed7dd0650cf32edd000d2268df961e2b825aab4
tree0c99214585ec74b8820671203e940ce9a4cec8d0
parent4304cf62e9ba6a85e37d5fec33cfa580ce7ac6d1
[dev.fuzz] internal/fuzz: rework default test behavior before fuzzing

This change refactors some of the code to support skipping a run
of the seed corpus by the go command before runFuzzing occurs.
Previously, the go command would run all seed corpus for all targets
that match the provided `run` argument. This will be redundant when
fuzzing a target. Now, the seed corpus is only run by targets other than
the one that's about to be fuzzed, and the worker handles running and
reporting issues with the seed corpus.

Part of the logic that needed close inspection is what to do if a
failure occurs during a testing-only or coverage-only fail. If the input
is already in the seed corpus, the fuzzing engine shouldn't add it. If
the input is currently in the cache, then it should be written to
testdata. In all cases, if an error occurs, we need to report this to
the user with enough information for them to debug it.

This uncovered some issues with our code when fuzzing without
instrumentation, and when -run=None was provided. There are some logic
fixes in this change, and some small refactors.

Fixes golang/go#48327
Fixes golang/go#48296

Change-Id: I9ce2be0219c5b09277ddd308df8bc5a46d4558fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/349630
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/testdata/script/test_fuzz_mutator.txt
src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt [new file with mode: 0644]
src/internal/fuzz/coverage.go
src/internal/fuzz/fuzz.go
src/internal/fuzz/worker.go
src/testing/fuzz.go