go-fuzz icon indicating copy to clipboard operation
go-fuzz copied to clipboard

Packages missing from the coverage

Open Kubuxu opened this issue 8 years ago • 4 comments

I started writing fuzzy tests for go-ipfs but I've hit quite a big wall.

The instrumentation during build process is not performed if any package if dependency tree of given package has import "C". This causes about 80% of our code to not be instrumented by go-fuzz, which means that it doesn't really try to cover our code.

Whole problem seems to be down to net package and runtime/cgo packages which do import "C".

Kubuxu avatar Sep 03 '16 21:09 Kubuxu

OK, running with CGO_ENABLED=0 seems to resolve it. Is that the official way of doing it? If yes then it would be good to recommend it by default as net dependency is quite common an it screws the coverage completely.

Kubuxu avatar Sep 03 '16 21:09 Kubuxu

CGO_ENABLED=0 is the best solution for now. Ultimately go-fuzz is integrated into Go compiler and build system, which would eliminate all these constant breakages related to cgo, vendoring, internal packages, new package naming restrictions, etc.

dvyukov avatar Sep 04 '16 08:09 dvyukov

@dvyukov Is there any bug open to track the steps required for this to be integrated upstream?

dgryski avatar Sep 04 '16 09:09 dgryski

@dgryski No, there is none. Feel free to file a one. Ideally Fuzz functions can be defined in test packages along with unit tests and benchmarks and then easily executed either in continuous coverage-guided mode, or in unit testing mode (corpus is executed once and/or a fixed number of additional random inputs). Maybe it should be integrated with testing/quick package, or maybe not.

dvyukov avatar Sep 05 '16 11:09 dvyukov