Skip to content

Commit

Permalink
testing: document f.Fuzz requirement to not change underlying data
Browse files Browse the repository at this point in the history
Updates #48606

Change-Id: I6d555fdefccd842fb65ec8d630b4808bcb54a825
Reviewed-on: https://go-review.googlesource.com/c/go/+/353977
Trust: Katie Hockman <[email protected]>
Run-TryBot: Katie Hockman <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
  • Loading branch information
katiehockman committed Oct 5, 2021
1 parent 7ae83c8 commit 0b4d499
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/testing/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,12 @@ var supportedTypes = map[reflect.Type]bool{
// This function sould be fast and deterministic, and its behavior should not
// depend on shared state. No mutatable input arguments, or pointers to them,
// should be retained between executions of the fuzz function, as the memory
// backing them may be mutated during a subsequent invocation.
// backing them may be mutated during a subsequent invocation. ff must not
// modify the underlying data of the arguments provided by the fuzzing engine.
//
// When fuzzing, F.Fuzz does not return until a problem is found, time runs
// out (set with -fuzztime), or the test process is interrupted by a signal.
// F.Fuzz should be called exactly once unless F.Skip or F.Fail is called.
// When fuzzing, F.Fuzz does not return until a problem is found, time runs out
// (set with -fuzztime), or the test process is interrupted by a signal. F.Fuzz
// should be called exactly once, unless F.Skip or F.Fail is called beforehand.
func (f *F) Fuzz(ff interface{}) {
if f.fuzzCalled {
panic("testing: F.Fuzz called more than once")
Expand Down

0 comments on commit 0b4d499

Please sign in to comment.