Get covered lines from coverage.
Adian12138 opened this issue · 3 comments
Adian12138 commented
Hi here,
I have read PR #78 and #171. I used to think JQF-implementation is faster than jacoco but it turns to be that jqf-instrumentation record more informations. Does it mean I can get information like the covered line (in format <classname, methodname, linenumber>) using jqf-instrument? If so, what should I do to implement this? It seems that I should implement a TraceEventVisitor
to implement this.
sohah commented
Hi, could we get an answer to this question? I am new to JQF and fuzzing in general. What is the best strategy to collect exact coverage of lines of codes? Thanks!
rohanpadhye commented
Yes, there are a number of ways to get this, depending on what format you are looking for:
- Using
mvn jqf:repro with -DlogCoverage=<file>
. You can repro any saved inputs given in the-Dinput=
argument. The format of this is JQF's own, so you will figure out how to get the info you are looking for. - Run a regular repro test but use your coverage tool, e.g. JaCoCo. If you are already used to collecting coverage from JUnit tests (e.g. via
mvn test
or in an IDE like IntelliJ), then you can simply hardcode the tests to repro using the@Fuzz(repro=...)
annotation for the fuzz test methods; simply point to the input files or directories which you want to rerun deterministically viamvn test
or by clicking the "Run" button in IntelliJ. - If you want to do this programmatically, then you can extend the
Guidance
(e.g.ZestGuidance
orReproGuidance
) to override thegenerateCallback
method, which lets you specify a callback that handlesTraceEvent
s. See the implementation in ReproGuidance for an example. If you do this, make sure to still dispatch the callback of the superclass so that you can don't break existing functionality.
sohah commented
Great pointers! many thanks.