Package edu.berkeley.cs.jqf.fuzz.util
Class Coverage
- java.lang.Object
-
- edu.berkeley.cs.jqf.fuzz.util.Coverage
-
- All Implemented Interfaces:
ICoverage<Counter>,TraceEventVisitor
public class Coverage extends Object implements TraceEventVisitor, ICoverage<Counter>
Utility class to collect branch and function coverage- Author:
- Rohan Padhye
-
-
Constructor Summary
Constructors Constructor Description Coverage()Creates a new coverage map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the coverage map.org.eclipse.collections.api.list.primitive.IntListcomputeNewCoverage(ICoverage baseline)Returns a set of edges in this coverage that don't exist in baselineCoveragecopy()Creates a copy of an this coverage map.CountergetCounter()org.eclipse.collections.api.list.primitive.IntListgetCovered()Returns a collection of branches that are covered.intgetNonZeroCount()Returns the number of edges covered.voidhandleEvent(TraceEvent e)Updates coverage information based on emitted event.inthashCode()Returns a hash code of the edge counts in the coverage map.intnonZeroHashCode()Returns a hash code of the list of edges that have been covered at least once.intsize()Returns the size of the coverage map.StringtoString()booleanupdateBits(ICoverage that)Updates this coverage with bits from the parameter.voidvisitBranchEvent(BranchEvent b)voidvisitCallEvent(CallEvent e)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.berkeley.cs.jqf.instrument.tracing.events.TraceEventVisitor
visitAllocEvent, visitReadEvent, visitReturnEvent
-
-
-
-
Method Detail
-
copy
public Coverage copy()
Creates a copy of an this coverage map.
-
size
public int size()
Returns the size of the coverage map.
-
handleEvent
public void handleEvent(TraceEvent e)
Updates coverage information based on emitted event.This method updates its internal counters for branch and call events.
- Parameters:
e- the event to be processed
-
visitBranchEvent
public void visitBranchEvent(BranchEvent b)
- Specified by:
visitBranchEventin interfaceTraceEventVisitor
-
visitCallEvent
public void visitCallEvent(CallEvent e)
- Specified by:
visitCallEventin interfaceTraceEventVisitor
-
getNonZeroCount
public int getNonZeroCount()
Returns the number of edges covered.- Specified by:
getNonZeroCountin interfaceICoverage<Counter>- Returns:
- the number of edges with non-zero counts
-
getCovered
public org.eclipse.collections.api.list.primitive.IntList getCovered()
Returns a collection of branches that are covered.- Specified by:
getCoveredin interfaceICoverage<Counter>- Returns:
- a collection of keys that are covered
-
computeNewCoverage
public org.eclipse.collections.api.list.primitive.IntList computeNewCoverage(ICoverage baseline)
Returns a set of edges in this coverage that don't exist in baseline- Specified by:
computeNewCoveragein interfaceICoverage<Counter>- Parameters:
baseline- the baseline coverage- Returns:
- the set of edges that do not exist in
baseline
-
clear
public void clear()
Clears the coverage map.
-
updateBits
public boolean updateBits(ICoverage that)
Updates this coverage with bits from the parameter.- Specified by:
updateBitsin interfaceICoverage<Counter>- Parameters:
that- the run coverage whose bits to OR- Returns:
trueiffthatis not a subset ofthis, causingthisto change.
-
hashCode
public int hashCode()
Returns a hash code of the edge counts in the coverage map.
-
nonZeroHashCode
public int nonZeroHashCode()
Returns a hash code of the list of edges that have been covered at least once.- Specified by:
nonZeroHashCodein interfaceICoverage<Counter>- Returns:
- a hash of non-zero entries
-
toString
public String toString()
-
getCounter
public Counter getCounter()
- Specified by:
getCounterin interfaceICoverage<Counter>
-
-