Class ReproGuidance
- All Implemented Interfaces:
Guidance
- Direct Known Subclasses:
DiffFuzzReproGuidance
- Author:
- Rohan Padhye
-
Constructor Summary
ConstructorsConstructorDescriptionReproGuidance(File[] inputFiles, File traceDir) Constructs an instance of ReproGuidance with a list of input files to replay and a directory where the trace events may be logged.ReproGuidance(File inputFile, File traceDir) Constructs an instance of ReproGuidance with a single input file or with a directory of input files to replay, and a directory where the trace events may be logged. -
Method Summary
Modifier and TypeMethodDescriptiongenerateCallBack(Thread thread) Returns a callback that can log trace events or code coverage info.Retyrns the set of branches covered by this repro.Returns a reference to the coverage statistics.getInput()Returns an input stream corresponding to the next input file.voidhandleResult(Result result, Throwable error) Logs the end of run in the log files, if any.booleanhasInput()Returnstrueif there are more input files to replay.voidjacocoCheckpoint(File classFile, File csvDir) voidobserveGeneratedArgs(Object[] args) Callback for observing actual arguments passed to the test method.This method is only invoked during optional observability logging to provide the type of guidance used for input generation.voidsetStopOnFailure(boolean value) Configure whether the repro execution should stop as soon as the first failure is encountered.
-
Constructor Details
-
ReproGuidance
Constructs an instance of ReproGuidance with a list of input files to replay and a directory where the trace events may be logged.- Parameters:
inputFiles- a list of input filestraceDir- an optional directory, which if non-null will be the destination for log files containing event traces- Throws:
IOException
-
ReproGuidance
Constructs an instance of ReproGuidance with a single input file or with a directory of input files to replay, and a directory where the trace events may be logged.- Parameters:
inputFile- an input file or directory of input filestraceDir- an optional directory, which if non-null will be the destination for log files containing event traces- Throws:
FileNotFoundException- if `inputFile` is not a valid file or directoryIOException
-
-
Method Details
-
setStopOnFailure
public void setStopOnFailure(boolean value) Configure whether the repro execution should stop as soon as the first failure is encountered.- Parameters:
value- whether to stop the repro on failure
-
getInput
Returns an input stream corresponding to the next input file. -
hasInput
public boolean hasInput()Returnstrueif there are more input files to replay. -
observeGeneratedArgs
Description copied from interface:GuidanceCallback for observing actual arguments passed to the test method.This method is invoked exactly once after each call to
Guidance.getInput(). The arguments to this callback are the structured inputs that are produced by junit-quickcheck generators, which in turn decode the bytes produced byGuidance.getInput().This method is useful for logging the generated args or for calculating the size of the generated args. The default implementation does nothing.
- Specified by:
observeGeneratedArgsin interfaceGuidance- Parameters:
args- an array of arguments that will be passed to the test method; the size of this array is equal to the number of formal parameters to the test method
-
observeGuidance
Description copied from interface:GuidanceThis method is only invoked during optional observability logging to provide the type of guidance used for input generation.
- Specified by:
observeGuidancein interfaceGuidance
-
handleResult
Logs the end of run in the log files, if any.- Specified by:
handleResultin interfaceGuidance- Parameters:
result- the result of the fuzzing trialerror- the error thrown during the trial, ornull
-
generateCallBack
Returns a callback that can log trace events or code coverage info.If the system property
jqf.repro.logUniqueBrancheswas set totrue, then the callback collects coverage info into the setbranchesCoveredInCurrentRun, which can be accessed usinggetBranchesCovered().Otherwise, if the
traceDirwas non-null during the construction of this Guidance instance, then one log file per thread of execution is created in this directory. The callbacks generated by this method write trace event descriptions in sequence to their own thread's log files.If neither of the above are true, the returned callback simply updates a total coverage map (see
getCoverage().- Specified by:
generateCallBackin interfaceGuidance- Parameters:
thread- the thread whose events to handle- Returns:
- a callback to log code coverage or execution traces
-
getCoverage
Returns a reference to the coverage statistics.- Returns:
- a reference to the coverage statistics
-
getBranchesCovered
Retyrns the set of branches covered by this repro.This set will only be non-empty if the system property
jqf.repro.logUniqueBrancheswas set totruebefore the guidance instance was constructed.The format of each element in this set is a custom format that strives to be both human and machine readable.
A branch is only logged for inputs that execute successfully. In particular, branches are not recorded for failing runs or for runs that violate assumptions.
- Returns:
- the set of branches covered by this repro
-
jacocoCheckpoint
-