rohanpadhye/JQF

Get covered lines from coverage.

Adian12138 opened this issue · 3 comments

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!

Yes, there are a number of ways to get this, depending on what format you are looking for:

  1. 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.
  2. 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 via mvn test or by clicking the "Run" button in IntelliJ.
  3. If you want to do this programmatically, then you can extend the Guidance (e.g. ZestGuidance or ReproGuidance) to override the generateCallback method, which lets you specify a callback that handles TraceEvents. 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.