@@ -2,18 +2,20 @@ package org.utbot.summary
22
33import org.utbot.framework.plugin.api.Step
44import org.utbot.framework.plugin.api.UtConcreteExecutionFailure
5- import org.utbot.framework.plugin.api.UtSymbolicExecution
5+ import org.utbot.framework.plugin.api.UtExecution
66import org.utbot.framework.plugin.api.UtExecutionResult
77import org.utbot.framework.plugin.api.UtExecutionSuccess
88import org.utbot.framework.plugin.api.UtExplicitlyThrownException
99import org.utbot.framework.plugin.api.UtImplicitlyThrownException
10- import org.utbot.framework.plugin.api.UtOverflowFailure
1110import org.utbot.framework.plugin.api.UtMethodTestSet
11+ import org.utbot.framework.plugin.api.UtOverflowFailure
1212import org.utbot.framework.plugin.api.UtSandboxFailure
1313import org.utbot.framework.plugin.api.UtStreamConsumingFailure
14+ import org.utbot.framework.plugin.api.UtSymbolicExecution
1415import org.utbot.framework.plugin.api.UtTimeoutException
1516import org.utbot.framework.plugin.api.util.humanReadableName
1617import org.utbot.framework.plugin.api.util.isCheckedException
18+ import org.utbot.fuzzer.UtFuzzedExecution
1719import org.utbot.summary.UtSummarySettings.MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING
1820import org.utbot.summary.clustering.MatrixUniqueness
1921import org.utbot.summary.clustering.SplitSteps
@@ -29,7 +31,7 @@ class TagGenerator {
2931
3032 if (clusteredExecutions.isNotEmpty()) {
3133 val listOfSplitSteps = clusteredExecutions.map {
32- val mUniqueness = MatrixUniqueness (it.executions)
34+ val mUniqueness = MatrixUniqueness (it.executions as List < UtSymbolicExecution > )
3335 mUniqueness.splitSteps()
3436 }
3537
@@ -64,7 +66,7 @@ class TagGenerator {
6466 traceTagClusters.add(
6567 TraceTagCluster (
6668 cluster.header,
67- generateExecutionTags(cluster.executions, splitSteps),
69+ generateExecutionTags(cluster.executions as List < UtSymbolicExecution > , splitSteps),
6870 TraceTagWithoutExecution (
6971 commonStepsInCluster.toList(),
7072 cluster.executions.first().result,
@@ -88,51 +90,67 @@ private fun generateExecutionTags(executions: List<UtSymbolicExecution>, splitSt
8890
8991
9092/* *
91- * Splits executions into clusters
92- * By default there is 5 types of clusters:
93- * Success, UnexpectedFail, ExpectedCheckedThrow, ExpectedUncheckedThrow, UnexpectedUncheckedThrow
94- * These are split by the type of execution result
93+ * Splits executions with empty paths into clusters.
9594 *
96- * @return clustered executions
95+ * @return clustered executions.
9796 */
9897fun groupExecutionsWithEmptyPaths (testSet : UtMethodTestSet ): List <ExecutionCluster > {
9998 val methodExecutions = testSet.executions.filterIsInstance<UtSymbolicExecution >()
10099 val clusters = mutableListOf<ExecutionCluster >()
101- val commentPrefix = " OTHER:"
100+ val commentPrefix = " OTHER:"
102101 val commentPostfix = " for method ${testSet.method.humanReadableName} "
103102
104103 val grouped = methodExecutions.groupBy { it.result.clusterKind() }
105104
106105 val successfulExecutions = grouped[ExecutionGroup .SUCCESSFUL_EXECUTIONS ] ? : emptyList()
107106 if (successfulExecutions.isNotEmpty()) {
108107 clusters + = SuccessfulExecutionCluster (
109- " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
110- successfulExecutions.toList())
108+ " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
109+ successfulExecutions.toList()
110+ )
111111 }
112112
113- clusters + = grouped
114- .filterNot { (kind, _) -> kind == ExecutionGroup .SUCCESSFUL_EXECUTIONS }
115- .map { (suffixId, group) ->
116- FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
117- }
113+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
114+ return clusters
115+ }
116+
117+ /* *
118+ * Splits fuzzed executions into clusters.
119+ *
120+ * @return clustered executions.
121+ */
122+ fun groupFuzzedExecutions (testSet : UtMethodTestSet ): List <ExecutionCluster > {
123+ val methodExecutions = testSet.executions.filterIsInstance<UtFuzzedExecution >()
124+ val clusters = mutableListOf<ExecutionCluster >()
125+ val commentPrefix = " FUZZER:"
126+ val commentPostfix = " for method ${testSet.method.humanReadableName} "
127+
128+ val grouped = methodExecutions.groupBy { it.result.clusterKind() }
129+
130+ val successfulExecutions = grouped[ExecutionGroup .SUCCESSFUL_EXECUTIONS ] ? : emptyList()
131+ if (successfulExecutions.isNotEmpty()) {
132+ clusters + = SuccessfulExecutionCluster (
133+ " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
134+ successfulExecutions.toList()
135+ )
136+ }
137+
138+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
118139 return clusters
119140}
120141
121142/* *
122- * Splits executions produced by symbolic execution engine into clusters
123- * By default there is 5 types of clusters:
124- * Success, UnexpectedFail, ExpectedCheckedThrow, ExpectedUncheckedThrow, UnexpectedUncheckedThrow
125- * These are split by the type of execution result
143+ * Splits symbolic executions into clusters.
126144 *
127- * If Success cluster has more than MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING execution
128- * then clustering algorithm splits those into more clusters
145+ * If Success cluster has more than [ MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING] execution
146+ * then clustering algorithm splits those into more clusters.
129147 *
130- * @return clustered executions
148+ * @return clustered executions.
131149 */
132150private fun toClusterExecutions (testSet : UtMethodTestSet ): List <ExecutionCluster > {
133151 val methodExecutions = testSet.executions.filterIsInstance<UtSymbolicExecution >()
134152 val clusters = mutableListOf<ExecutionCluster >()
135- val commentPrefix = " SYMBOLIC EXECUTION:"
153+ val commentPrefix = " SYMBOLIC EXECUTION:"
136154 val commentPostfix = " for method ${testSet.method.humanReadableName} "
137155
138156 val grouped = methodExecutions.groupBy { it.result.clusterKind() }
@@ -161,11 +179,21 @@ private fun toClusterExecutions(testSet: UtMethodTestSet): List<ExecutionCluster
161179 }
162180 }
163181
164- clusters + = grouped
182+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
183+ return clusters
184+ }
185+
186+ private fun addClustersOfFailedExecutions (
187+ grouped : Map <ExecutionGroup , List <UtExecution >>,
188+ commentPrefix : String ,
189+ commentPostfix : String
190+ ): List <FailedExecutionCluster > {
191+ val clusters = grouped
165192 .filterNot { (kind, _) -> kind == ExecutionGroup .SUCCESSFUL_EXECUTIONS }
166193 .map { (suffixId, group) ->
167- FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
168- }
194+ FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
195+ }
196+
169197 return clusters
170198}
171199
@@ -197,18 +225,18 @@ private fun UtExecutionResult.clusterKind() = when (this) {
197225/* *
198226 * Structure used to represent execution cluster with header
199227 */
200- sealed class ExecutionCluster (var header : String , val executions : List <UtSymbolicExecution >)
228+ sealed class ExecutionCluster (var header : String , val executions : List <UtExecution >)
201229
202230/* *
203231 * Represents successful execution cluster
204232 */
205- private class SuccessfulExecutionCluster (header : String , executions : List <UtSymbolicExecution >) :
233+ private class SuccessfulExecutionCluster (header : String , executions : List <UtExecution >) :
206234 ExecutionCluster (header, executions)
207235
208236/* *
209237 * Represents failed execution cluster
210238 */
211- private class FailedExecutionCluster (header : String , executions : List <UtSymbolicExecution >) :
239+ private class FailedExecutionCluster (header : String , executions : List <UtExecution >) :
212240 ExecutionCluster (header, executions)
213241
214242/* *
0 commit comments