-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
native go fuzzing: ignore non-fuzz tests #8285
Conversation
@pjbgf Thank you for the PR. Nice trick with Regarding the Do you have a link to an example of a co-located test that breaks the OSS-Fuzz build? |
@AdamKorcz sure, I linked the PR with the example, it has the file helmrelease_controller_test.go which contains both normal tests and fuzz tests. One of the normal test depends on the The
Removing any dependency that is not related to the Fuzz tests. |
Rebased with latest from master. |
Thank you for the elaboration. I do see the problem here. To me, there are side effects to having this var testDB dbStruct
func setupDB(name string, t *testing.T) {
testDB = NewDB(name)
}
func Fuzzer(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
// create new db
setupDB("newDB", t)
// remaining fuzzing logic below
........
})
} In general, there are reasons that projects might want to have functions with the
Option 1 is way too complex IMO, and I think it would be much simpler to let users to it themselves in the build script when they actually need it. @pjbgf Let me know what you think. |
@AdamKorcz thank you for your time reviewing this. I made some changes to align with the option 2 you mentioned above. I added a boolean parameter to The |
Co-located tests that depend on global vars break the process of building Fuzz tests. A common scenario is to have a TestMain func specified on a separate file, which defines and loads global vars to be shared across different. Those test funcs are completely irrelevant to the Fuzz tests, as the latter tend to be self-sufficient. Signed-off-by: Paulo Gomes <[email protected]>
Co-located tests that depend on global vars break the process of
building Fuzz tests.
A common scenario is to have a
TestMain
func specified on a separatefile, which defines and loads global vars to be shared across different.
Those test funcs are completely irrelevant to the Fuzz tests, as the
latter tend to be self-sufficient.
gofmt
is then used to clean-up any unused import, so that Go compileris happy.