Class ReproServerGuidance
- java.lang.Object
-
- edu.berkeley.cs.jqf.fuzz.repro.ReproServerGuidance
-
-
Field Summary
Fields Modifier and Type Field Description protected Coverage
coverage
protected File
coverageFile
protected File
inputFile
protected BufferedReader
inputFileNameReader
protected InputStream
inputFileStream
-
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.InputStream
getInput()
Returns a reference to a stream of values return from the pseudo-random number generator.void
handleResult(Result result, Throwable error)
Handles the end of a fuzzing trial.boolean
hasInput()
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:Guidance
Returns 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:Guidance
Returns 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()
returnsfalse
or has not been invoked since the last call toGuidance.getInput()
, then invoking this method may throw an IllegalStateException.- Specified by:
getInput
in interfaceGuidance
- Returns:
- a stream of bytes to be used by the input generator(s)
- Throws:
IllegalStateException
- if the lastGuidance.hasInput()
returnedfalse
GuidanceException
- 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:Guidance
Handles 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
result
isSUCCESS
, thenerror
is eithernull
or it is an instance of a throwable that is declared by the test method in itsthrows
clause.If
result
isINVALID
, thenerror
is 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
result
isFAILURE
, thenerror
is some other throwable that was thrown by the test execution but was not listed in itsthrows
clause. 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:
handleResult
in 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:Guidance
Returns a callback generator for a thread's event trace.The application under test is instrumented such that each thread generates a sequence of
TraceEvent
s 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:
generateCallBack
in interfaceGuidance
- Parameters:
thread
- the thread whose events to handle- Returns:
- a callback that handles trace events generated by that thread
-
-