rohanpadhye / JQF

JQF + Zest: Coverage-guided semantic fuzzing for Java.
BSD 2-Clause "Simplified" License
666 stars 112 forks source link

when does the method "handleEvent" in Guidance class called? #116

Closed EvanXiaa closed 3 years ago

EvanXiaa commented 4 years ago

Hello author! I tried to debug jqf with ideal but during the test the coverage is always zero. And I found the method "handleEvent" is never called in that case. Could you please tell me how could this happen? By the way, the project can work and calculate coverage when I use terminal.

rohanpadhye commented 4 years ago

JQF needs to be able to instrument classes as they are being loaded by the JVM in order to collect coverage feedback. The command-line runner uses a javaagent and special bootclasspath, whereas the Maven plugin uses a custom instrumenting class loader before running guided fuzzing.

If you want to collect coverage when running from IDEA, you will have to either set javaagend/bootclasspath or customize the classloader. I don't know the specifics of IntelliJ settings but that's a direction to consider.

Hope this helps.

carolemieux commented 4 years ago

To follow up on that; to run a particular test in IDEA with coverage enabled, you can go to Edit Configurations, choose the test you want to run, and add the VM options from the command-line runner to the configurations. Those options are

-ea -Xbootclasspath/a:"$INST_CLASSPATH"  -javaagent:${INST_JAR}  -Djanala.conf="${SCRIPT_DIR}/janala.conf"

with the environment variables defined. Refer to the command-line runner for how to set those variables appropriately.

EvanXiaa commented 4 years ago

Thank you for replying. I'll have a try. : )