func initFuzzFlags() { … } var matchFuzz … var fuzzDuration … var minimizeDuration … var fuzzCacheDir … var isFuzzWorker … var corpusDir … const fuzzWorkerExitCode … type InternalFuzzTarget … type F … var _ … type corpusEntry … // Helper marks the calling function as a test helper function. // When printing file and line information, that function will be skipped. // Helper may be called simultaneously from multiple goroutines. func (f *F) Helper() { … } // Fail marks the function as having failed but continues execution. func (f *F) Fail() { … } // Skipped reports whether the test was skipped. func (f *F) Skipped() bool { … } // Add will add the arguments to the seed corpus for the fuzz test. This will be // a no-op if called after or within the fuzz target, and args must match the // arguments for the fuzz target. func (f *F) Add(args ...any) { … } var supportedTypes … // Fuzz runs the fuzz function, ff, for fuzz testing. If ff fails for a set of // arguments, those arguments will be added to the seed corpus. // // ff must be a function with no return value whose first argument is *T and // whose remaining arguments are the types to be fuzzed. // For example: // // f.Fuzz(func(t *testing.T, b []byte, i int) { ... }) // // The following types are allowed: []byte, string, bool, byte, rune, float32, // float64, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64. // More types may be supported in the future. // // ff must not call any *F methods, e.g. (*F).Log, (*F).Error, (*F).Skip. Use // the corresponding *T method instead. The only *F methods that are allowed in // the (*F).Fuzz function are (*F).Failed and (*F).Name. // // This function should be fast and deterministic, and its behavior should not // depend on shared state. No mutable 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. 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 beforehand. func (f *F) Fuzz(ff any) { … } func (f *F) report() { … } type fuzzResult … func (r fuzzResult) String() string { … } type fuzzCrashError … type fuzzState … type fuzzMode … const seedCorpusOnly … const fuzzCoordinator … const fuzzWorker … // runFuzzTests runs the fuzz tests matching the pattern for -run. This will // only run the (*F).Fuzz function for each seed corpus without using the // fuzzing engine to generate or mutate inputs. func runFuzzTests(deps testDeps, fuzzTests []InternalFuzzTarget, deadline time.Time) (ran, ok bool) { … } // runFuzzing runs the fuzz test matching the pattern for -fuzz. Only one such // fuzz test must match. This will run the fuzzing engine to generate and // mutate new inputs against the fuzz target. // // If fuzzing is disabled (-test.fuzz is not set), runFuzzing // returns immediately. func runFuzzing(deps testDeps, fuzzTests []InternalFuzzTarget) (ok bool) { … } // fRunner wraps a call to a fuzz test and ensures that cleanup functions are // called and status flags are set. fRunner should be called in its own // goroutine. To wait for its completion, receive from f.signal. // // fRunner is analogous to tRunner, which wraps subtests started with T.Run. // Unit tests and fuzz tests work a little differently, so for now, these // functions aren't consolidated. In particular, because there are no F.Run and // F.Parallel methods, i.e., no fuzz sub-tests or parallel fuzz tests, a few // simplifications are made. We also require that F.Fuzz, F.Skip, or F.Fail is // called. func fRunner(f *F, fn func(*F)) { … }