-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: sub fuzz targets #46780
Comments
/cc @golang/fuzzing |
It's not clear to me exactly what this would do or how it would be used. Could you elaborate?
This is something we'd like to support eventually in any case. You wouldn't need a sub-target for it.
|
Agreed, this seems like it'd also only work when
When fuzzing a function that takes an
|
The use case is similar to table driven tests. As an example, I want to Fuzz test my input validation logic in my gRPC service. In the current approach I will have to write a top level Fuzz target for each of the request methods. In case of sub-targets, I would write it something like this, func FuzzValidate(f *testing.F) {
ff := []struct{
Name string
Seed proto.Message
Request proto.Message
}{
{...},
{...},
...
}
for _, fc := range ff {
f.Run(fc.Name, func(f *testing.F) {
// f.Parallel() to solve the fuzztime requirement
f.Fuzz(func(t *testing.T, data []byte) {
t.Parallel()
fz := fuzz.NewFromGoFuzz(data)
*r := fc.r
fz.Fuzz(&r)
r.Validate()
})
})
}
} If we were to shift the loop inside, I wouldn't know which validation logic is failing. |
@srikrsna Thanks, I think that makes sense. We'd need to nail down the exact semantics for this.
|
My assumption is that the semantics would be similar to benchmarks, won't they? |
It seems like manual testing of the triggering input would give you this information, which is generally doing to be required anyway when a new crasher is found (additionally the trace should point you to where the problem is occurring). |
The same applies for sub tests and sub benchmarks. Trace would useful to find out the exact line where the problem would be and how it can be fixed. Naming the targets will give an overview of which cases are failing. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@AlekSi If the goal is to associate a name with each seed value for output, maybe open a new issue? As I understand it, this one is about having separate fuzz targets with their own fuzz separate functions, but perhaps with shared setup code. |
Created #47413 for adding |
It would be nice to be able to define sub fuzz targets like subtests and sub-benchmarks. Example:
This would be very much useful to fuzz functions with generic but defined data structures.
The text was updated successfully, but these errors were encountered: