Class ReproServerGuidance
- java.lang.Object
-
- edu.berkeley.cs.jqf.fuzz.repro.ReproServerGuidance
-
-
Field Summary
Fields Modifier and Type Field Description protected Coveragecoverageprotected FilecoverageFileprotected FileinputFileprotected BufferedReaderinputFileNameReaderprotected InputStreaminputFileStream
-
Constructor Summary
Constructors Constructor Description ReproServerGuidance(String inPipe, String coverageFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Consumer<TraceEvent>generateCallBack(Thread thread)Returns a callback generator for a thread's event trace.InputStreamgetInput()Returns a reference to a stream of values return from the pseudo-random number generator.voidhandleResult(Result result, Throwable error)Handles the end of a fuzzing trial.booleanhasInput()Returns whether an input is ready for a new trial to be executed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.berkeley.cs.jqf.fuzz.guidance.Guidance
observeGeneratedArgs, run
-
-
-
-
Field Detail
-
coverageFile
protected File coverageFile
-
inputFileNameReader
protected BufferedReader inputFileNameReader
-
inputFile
protected File inputFile
-
inputFileStream
protected InputStream inputFileStream
-
coverage
protected Coverage coverage
-
-
Constructor Detail
-
ReproServerGuidance
public ReproServerGuidance(String inPipe, String coverageFile) throws IOException
- Throws:
IOException
-
-
Method Detail
-
hasInput
public boolean hasInput()
Description copied from interface:GuidanceReturns whether an input is ready for a new trial to be executed.This method may block until a new input stream is made ready. If this method returns
false, then JQF stops fuzzing and this guidance will not be used further.
-
getInput
public InputStream getInput() throws IllegalStateException, GuidanceException
Description copied from interface:GuidanceReturns a reference to a stream of values return from the pseudo-random number generator.This method is guaranteed to be invoked by JQF at most once after each invocation of
Guidance.hasInput()that has returnedtrue.If
Guidance.hasInput()returnsfalseor has not been invoked since the last call toGuidance.getInput(), then invoking this method may throw an IllegalStateException.- Specified by:
getInputin interfaceGuidance- Returns:
- a stream of bytes to be used by the input generator(s)
- Throws:
IllegalStateException- if the lastGuidance.hasInput()returnedfalseGuidanceException- if there was an I/O or other error in generating the input stream
-
handleResult
public void handleResult(Result result, Throwable error)
Description copied from interface:GuidanceHandles the end of a fuzzing trial.This method is guaranteed to be invoked by JQF exactly once after each invocation of
Guidance.getInput(). Therefore, it is safe to open resources such as files in a call toGuidance.getInput()and only close them inside this method.If
resultisSUCCESS, thenerroris eithernullor it is an instance of a throwable that is declared by the test method in itsthrowsclause.If
resultisINVALID, thenerroris either anAssumptionViolatedException, if the argument of anassume()statement wasfalse, or it is aGuidanceException, indicating that fuzzing was interrupted during the execution of this trial (and will not continue further).If
resultisFAILURE, thenerroris some other throwable that was thrown by the test execution but was not listed in itsthrowsclause. This is the only way to detect test errors. Assertion errors will typically fall into this category. So will other unlisted RuntimeExceptions such as NPE.- Specified by:
handleResultin interfaceGuidance- Parameters:
result- the result of the fuzzing trialerror- the error thrown during the trial, ornull
-
generateCallBack
public Consumer<TraceEvent> generateCallBack(Thread thread)
Description copied from interface:GuidanceReturns a callback generator for a thread's event trace.The application under test is instrumented such that each thread generates a sequence of
TraceEvents that may be handled by a separate callback method (though it may also be the same callback).The callback provided by this method will typically be used for collection execution information such as branch coverage, which in turn is used for constructing the next input stream.
This method is a supplier of event consumers. It is invoked once per new application thread spawned during fuzzing.
- Specified by:
generateCallBackin interfaceGuidance- Parameters:
thread- the thread whose events to handle- Returns:
- a callback that handles trace events generated by that thread
-
-