diff options
| author | Katie Hockman <katie@golang.org> | 2021-06-07 17:51:51 -0400 |
|---|---|---|
| committer | Katie Hockman <katie@golang.org> | 2021-06-15 19:32:21 +0000 |
| commit | 413c125da38990720744c0d98ab65c0d5b1602da (patch) | |
| tree | 0e8e9e63f364abc3c00380e092311c621b4a1ce7 /src/testing/testing.go | |
| parent | 965b1147549ef28a407bd4e8f5efe5e7b7616f80 (diff) | |
| download | go-413c125da38990720744c0d98ab65c0d5b1602da.tar.xz | |
[dev.fuzz] testing: convert seed corpus values where possible
The types provided in f.Fuzz will be viewed as the
canonical types for fuzzing. If the type is different
for a seed corpus entry, then the testing package
will attempt to convert it. If it can't convert it,
f.Fuzz will fail.
Currently, this allows converting types that may result
in precision loss or a semantically different value.
For example, an int(-1) can be converted to uint even
though the value could be math.MaxUint64. There is a
TODO to consider improving this in the future.
Updates golang/go#45593
Change-Id: I2e752119662f46b68445d42b1ffa46dd30e9faea
Reviewed-on: https://go-review.googlesource.com/c/go/+/325702
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Diffstat (limited to 'src/testing/testing.go')
| -rw-r--r-- | src/testing/testing.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go index 82b422a414..fa92dbb005 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1463,8 +1463,9 @@ func (f matchStringOnly) RunFuzzWorker(func(corpusEntry) error) error { return e func (f matchStringOnly) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error) { return nil, errMain } -func (f matchStringOnly) ResetCoverage() {} -func (f matchStringOnly) SnapshotCoverage() {} +func (f matchStringOnly) CheckCorpus([]interface{}, []reflect.Type) error { return nil } +func (f matchStringOnly) ResetCoverage() {} +func (f matchStringOnly) SnapshotCoverage() {} // Main is an internal function, part of the implementation of the "go test" command. // It was exported because it is cross-package and predates "internal" packages. @@ -1510,6 +1511,7 @@ type testDeps interface { CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error RunFuzzWorker(func(corpusEntry) error) error ReadCorpus(string, []reflect.Type) ([]corpusEntry, error) + CheckCorpus([]interface{}, []reflect.Type) error ResetCoverage() SnapshotCoverage() } |
