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 void
clear()
Clears the coverage map.org.eclipse.collections.api.list.primitive.IntList
computeNewCoverage(ICoverage baseline)
Returns a set of edges in this coverage that don't exist in baselineCoverage
copy()
Creates a copy of an this coverage map.Counter
getCounter()
org.eclipse.collections.api.list.primitive.IntList
getCovered()
Returns a collection of branches that are covered.int
getNonZeroCount()
Returns the number of edges covered.void
handleEvent(TraceEvent e)
Updates coverage information based on emitted event.int
hashCode()
Returns a hash code of the edge counts in the coverage map.int
nonZeroHashCode()
Returns a hash code of the list of edges that have been covered at least once.int
size()
Returns the size of the coverage map.String
toString()
boolean
updateBits(ICoverage that)
Updates this coverage with bits from the parameter.void
visitBranchEvent(BranchEvent b)
void
visitCallEvent(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:
visitBranchEvent
in interfaceTraceEventVisitor
-
visitCallEvent
public void visitCallEvent(CallEvent e)
- Specified by:
visitCallEvent
in interfaceTraceEventVisitor
-
getNonZeroCount
public int getNonZeroCount()
Returns the number of edges covered.- Specified by:
getNonZeroCount
in 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:
getCovered
in 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:
computeNewCoverage
in 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:
updateBits
in interfaceICoverage<Counter>
- Parameters:
that
- the run coverage whose bits to OR- Returns:
true
iffthat
is not a subset ofthis
, causingthis
to 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:
nonZeroHashCode
in interfaceICoverage<Counter>
- Returns:
- a hash of non-zero entries
-
toString
public String toString()
-
getCounter
public Counter getCounter()
- Specified by:
getCounter
in interfaceICoverage<Counter>
-
-