@@ -2,18 +2,20 @@ package org.utbot.summary
2
2
3
3
import org.utbot.framework.plugin.api.Step
4
4
import org.utbot.framework.plugin.api.UtConcreteExecutionFailure
5
- import org.utbot.framework.plugin.api.UtSymbolicExecution
5
+ import org.utbot.framework.plugin.api.UtExecution
6
6
import org.utbot.framework.plugin.api.UtExecutionResult
7
7
import org.utbot.framework.plugin.api.UtExecutionSuccess
8
8
import org.utbot.framework.plugin.api.UtExplicitlyThrownException
9
9
import org.utbot.framework.plugin.api.UtImplicitlyThrownException
10
- import org.utbot.framework.plugin.api.UtOverflowFailure
11
10
import org.utbot.framework.plugin.api.UtMethodTestSet
11
+ import org.utbot.framework.plugin.api.UtOverflowFailure
12
12
import org.utbot.framework.plugin.api.UtSandboxFailure
13
13
import org.utbot.framework.plugin.api.UtStreamConsumingFailure
14
+ import org.utbot.framework.plugin.api.UtSymbolicExecution
14
15
import org.utbot.framework.plugin.api.UtTimeoutException
15
16
import org.utbot.framework.plugin.api.util.humanReadableName
16
17
import org.utbot.framework.plugin.api.util.isCheckedException
18
+ import org.utbot.fuzzer.UtFuzzedExecution
17
19
import org.utbot.summary.UtSummarySettings.MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING
18
20
import org.utbot.summary.clustering.MatrixUniqueness
19
21
import org.utbot.summary.clustering.SplitSteps
@@ -29,7 +31,7 @@ class TagGenerator {
29
31
30
32
if (clusteredExecutions.isNotEmpty()) {
31
33
val listOfSplitSteps = clusteredExecutions.map {
32
- val mUniqueness = MatrixUniqueness (it.executions)
34
+ val mUniqueness = MatrixUniqueness (it.executions as List < UtSymbolicExecution > )
33
35
mUniqueness.splitSteps()
34
36
}
35
37
@@ -64,7 +66,7 @@ class TagGenerator {
64
66
traceTagClusters.add(
65
67
TraceTagCluster (
66
68
cluster.header,
67
- generateExecutionTags(cluster.executions, splitSteps),
69
+ generateExecutionTags(cluster.executions as List < UtSymbolicExecution > , splitSteps),
68
70
TraceTagWithoutExecution (
69
71
commonStepsInCluster.toList(),
70
72
cluster.executions.first().result,
@@ -88,41 +90,78 @@ private fun generateExecutionTags(executions: List<UtSymbolicExecution>, splitSt
88
90
89
91
90
92
/* *
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.
94
+ *
95
+ * By default, there is 5 types of clusters:
96
+ * - Success
97
+ * - UnexpectedFail
98
+ * - ExpectedCheckedThrow
99
+ * - ExpectedUncheckedThrow
100
+ * - UnexpectedUncheckedThrow
95
101
*
96
102
* @return clustered executions
97
103
*/
98
104
fun groupExecutionsWithEmptyPaths (testSet : UtMethodTestSet ): List <ExecutionCluster > {
99
105
val methodExecutions = testSet.executions.filterIsInstance<UtSymbolicExecution >()
100
106
val clusters = mutableListOf<ExecutionCluster >()
101
- val commentPrefix = " OTHER:"
107
+ val commentPrefix = " OTHER:"
102
108
val commentPostfix = " for method ${testSet.method.humanReadableName} "
103
109
104
110
val grouped = methodExecutions.groupBy { it.result.clusterKind() }
105
111
106
112
val successfulExecutions = grouped[ExecutionGroup .SUCCESSFUL_EXECUTIONS ] ? : emptyList()
107
113
if (successfulExecutions.isNotEmpty()) {
108
114
clusters + = SuccessfulExecutionCluster (
109
- " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
110
- successfulExecutions.toList())
115
+ " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
116
+ successfulExecutions.toList()
117
+ )
111
118
}
112
119
113
- clusters + = grouped
114
- .filterNot { (kind, _) -> kind == ExecutionGroup .SUCCESSFUL_EXECUTIONS }
115
- .map { (suffixId, group) ->
116
- FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
117
- }
120
+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
121
+ return clusters
122
+ }
123
+
124
+ /* *
125
+ * Splits fuzzed executions into clusters.
126
+ *
127
+ * By default, there is 5 types of clusters:
128
+ * - Success
129
+ * - UnexpectedFail
130
+ * - ExpectedCheckedThrow
131
+ * - ExpectedUncheckedThrow
132
+ * - UnexpectedUncheckedThrow
133
+ *
134
+ * @return clustered executions
135
+ */
136
+ fun groupFuzzedExecutions (testSet : UtMethodTestSet ): List <ExecutionCluster > {
137
+ val methodExecutions = testSet.executions.filterIsInstance<UtFuzzedExecution >()
138
+ val clusters = mutableListOf<ExecutionCluster >()
139
+ val commentPrefix = " FUZZER:"
140
+ val commentPostfix = " for method ${testSet.method.humanReadableName} "
141
+
142
+ val grouped = methodExecutions.groupBy { it.result.clusterKind() }
143
+
144
+ val successfulExecutions = grouped[ExecutionGroup .SUCCESSFUL_EXECUTIONS ] ? : emptyList()
145
+ if (successfulExecutions.isNotEmpty()) {
146
+ clusters + = SuccessfulExecutionCluster (
147
+ " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
148
+ successfulExecutions.toList()
149
+ )
150
+ }
151
+
152
+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
118
153
return clusters
119
154
}
120
155
121
156
/* *
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
157
+ * Splits symbolic executions produced by symbolic execution engine into clusters.
158
+ *
159
+ * By default, there is 5 types of clusters:
160
+ * - Success
161
+ * - UnexpectedFail
162
+ * - ExpectedCheckedThrow
163
+ * - ExpectedUncheckedThrow
164
+ * - UnexpectedUncheckedThrow
126
165
*
127
166
* If Success cluster has more than MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING execution
128
167
* then clustering algorithm splits those into more clusters
@@ -132,7 +171,7 @@ fun groupExecutionsWithEmptyPaths(testSet: UtMethodTestSet): List<ExecutionClust
132
171
private fun toClusterExecutions (testSet : UtMethodTestSet ): List <ExecutionCluster > {
133
172
val methodExecutions = testSet.executions.filterIsInstance<UtSymbolicExecution >()
134
173
val clusters = mutableListOf<ExecutionCluster >()
135
- val commentPrefix = " SYMBOLIC EXECUTION:"
174
+ val commentPrefix = " SYMBOLIC EXECUTION:"
136
175
val commentPostfix = " for method ${testSet.method.humanReadableName} "
137
176
138
177
val grouped = methodExecutions.groupBy { it.result.clusterKind() }
@@ -161,11 +200,21 @@ private fun toClusterExecutions(testSet: UtMethodTestSet): List<ExecutionCluster
161
200
}
162
201
}
163
202
164
- clusters + = grouped
203
+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
204
+ return clusters
205
+ }
206
+
207
+ private fun addClustersOfFailedExecutions (
208
+ grouped : Map <ExecutionGroup , List <UtExecution >>,
209
+ commentPrefix : String ,
210
+ commentPostfix : String
211
+ ): List <FailedExecutionCluster > {
212
+ val clusters = grouped
165
213
.filterNot { (kind, _) -> kind == ExecutionGroup .SUCCESSFUL_EXECUTIONS }
166
214
.map { (suffixId, group) ->
167
- FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
168
- }
215
+ FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
216
+ }
217
+
169
218
return clusters
170
219
}
171
220
@@ -197,18 +246,18 @@ private fun UtExecutionResult.clusterKind() = when (this) {
197
246
/* *
198
247
* Structure used to represent execution cluster with header
199
248
*/
200
- sealed class ExecutionCluster (var header : String , val executions : List <UtSymbolicExecution >)
249
+ sealed class ExecutionCluster (var header : String , val executions : List <UtExecution >)
201
250
202
251
/* *
203
252
* Represents successful execution cluster
204
253
*/
205
- private class SuccessfulExecutionCluster (header : String , executions : List <UtSymbolicExecution >) :
254
+ private class SuccessfulExecutionCluster (header : String , executions : List <UtExecution >) :
206
255
ExecutionCluster (header, executions)
207
256
208
257
/* *
209
258
* Represents failed execution cluster
210
259
*/
211
- private class FailedExecutionCluster (header : String , executions : List <UtSymbolicExecution >) :
260
+ private class FailedExecutionCluster (header : String , executions : List <UtExecution >) :
212
261
ExecutionCluster (header, executions)
213
262
214
263
/* *
0 commit comments