-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Closed
Copy link
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.FrozenDueToAgeProposalfuzzIssues related to native fuzzing supportIssues related to native fuzzing support
Milestone
Description
Seed corpus entries can be added to a fuzz test by calling (*testing.F).Add. There is no way to name these seed corpus entries, so they default to "seed#{num}". When run with go test -v, it will look something like this:
--- PASS: FuzzFoo (0.00s)
--- PASS: FuzzFoo/seed#0 (0.00s)
--- PASS: FuzzFoo/seed#1 (0.00s)
--- PASS: FuzzFoo/seed#2 (0.00s)
The proposal is to allow a way to name these entries, much like you would with an execution of t.Run. This would help with error messages and debugging. We could do this a few different ways:
- Amend
f.Addto accept an optional first/last name string param. Sincef.Addtakes a[]interface{}today, this is functionality that could be added later that wouldn't break backwards compatibility.
e.g. existing fuzz tests that look like this:
func FuzzFoo(f *testing.F) {
f.Add("a3g1f3", 10)
f.Add("----", 100)
f.Add("", 0)
f.Fuzz(func(*testing.T, string, int) {})
}
would change to
func FuzzFoo(f *testing.F) {
f.Add("valid", "a3g1f3", 10)
f.Add("invalid", "----", 100)
f.Add("empty", "", 0)
f.Fuzz(func(*testing.T, string, int) {})
}
- We could add another method on
*testing.F. For example:
(*testing.F).AddNamed(string, []interface{})
Originally proposed by @dnwe
/cc @golang/fuzzing
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.FrozenDueToAgeProposalfuzzIssues related to native fuzzing supportIssues related to native fuzzing support
Type
Projects
Status
No status