@@ -13,6 +13,7 @@ import org.usvm.instrumentation.testcase.api.UTestExecutionResult
13
13
import org.usvm.instrumentation.testcase.api.UTestExecutionState
14
14
import org.usvm.instrumentation.testcase.api.UTestExecutionSuccessResult
15
15
import org.usvm.instrumentation.testcase.api.UTestExecutionTimedOutResult
16
+ import org.usvm.instrumentation.testcase.api.UTestSetStaticFieldStatement
16
17
import org.usvm.instrumentation.testcase.descriptor.Descriptor2ValueConverter
17
18
import org.usvm.instrumentation.testcase.descriptor.UTestExceptionDescriptor
18
19
import org.usvm.instrumentation.util.enclosingClass
@@ -26,6 +27,8 @@ import org.utbot.framework.plugin.api.EnvironmentModels
26
27
import org.utbot.framework.plugin.api.ExecutableId
27
28
import org.utbot.framework.plugin.api.FieldId
28
29
import org.utbot.framework.plugin.api.Instruction
30
+ import org.utbot.framework.plugin.api.MissingState
31
+ import org.utbot.framework.plugin.api.TimeoutException
29
32
import org.utbot.framework.plugin.api.UtArrayModel
30
33
import org.utbot.framework.plugin.api.UtAssembleModel
31
34
import org.utbot.framework.plugin.api.UtCompositeModel
@@ -37,6 +40,7 @@ import org.utbot.framework.plugin.api.UtExplicitlyThrownException
37
40
import org.utbot.framework.plugin.api.UtImplicitlyThrownException
38
41
import org.utbot.framework.plugin.api.UtPrimitiveModel
39
42
import org.utbot.framework.plugin.api.UtStatementCallModel
43
+ import org.utbot.framework.plugin.api.UtTimeoutException
40
44
import org.utbot.framework.plugin.api.UtVoidModel
41
45
import org.utbot.framework.plugin.api.mapper.UtModelDeepMapper
42
46
import org.utbot.framework.plugin.api.util.executableId
@@ -56,15 +60,9 @@ class JcToUtExecutionConverter(
56
60
) {
57
61
private val toValueConverter = Descriptor2ValueConverter (utContext.classLoader)
58
62
59
- private var jcToUtModelConverter: JcToUtModelConverter
60
- private var uTestProcessResult: UTestAnalysisResult
61
-
62
- init {
63
- val instToModelConverter = UTestInstToUtModelConverter (jcExecution.uTest, jcClasspath, idGenerator, utilMethodProvider)
64
- jcToUtModelConverter = JcToUtModelConverter (idGenerator, jcClasspath, instToModelConverter)
65
-
66
- uTestProcessResult = instToModelConverter.processUTest()
67
- }
63
+ private val instToModelConverter = UTestInstToUtModelConverter (jcExecution.uTest, jcClasspath, idGenerator, utilMethodProvider)
64
+ private var jcToUtModelConverter = JcToUtModelConverter (idGenerator, jcClasspath, instToModelConverter)
65
+ private var uTestProcessResult = instToModelConverter.processUTest()
68
66
69
67
fun convert (): UtExecution ? {
70
68
val coverage = convertCoverage(getTrace(jcExecution.uTestExecutionResult), jcExecution.method.enclosingType.jcClass)
@@ -108,8 +106,14 @@ class JcToUtExecutionConverter(
108
106
}
109
107
110
108
is UTestExecutionTimedOutResult -> {
111
- // TODO usvm-sbft
112
- null
109
+ logger.warn { " Timeout on ${jcExecution.method.method} " }
110
+ UtUsvmExecution (
111
+ stateBefore = constructStateBeforeFromUTest(),
112
+ stateAfter = MissingState ,
113
+ result = UtTimeoutException (TimeoutException (" Concrete execution timed out" )),
114
+ coverage = coverage,
115
+ instrumentation = uTestProcessResult.instrumentation,
116
+ )
113
117
}
114
118
} ? : return null
115
119
@@ -230,6 +234,24 @@ class JcToUtExecutionConverter(
230
234
return EnvironmentModels (thisInstance, parameters, statics, executableId)
231
235
}
232
236
237
+ private fun constructStateBeforeFromUTest (): EnvironmentModels {
238
+ val uTest = jcExecution.uTest
239
+ val method = jcExecution.method
240
+ val thisInstance =
241
+ if (method.isStatic) null
242
+ else if (method.method.isConstructor) null
243
+ else instToModelConverter.findModelByInst(uTest.callMethodExpression.instance ? : error(" Unexpected null instance expression" ))
244
+ val parameters = uTest.callMethodExpression.args.map {
245
+ instToModelConverter.findModelByInst(it)
246
+ }
247
+ val statics = uTest.initStatements.filterIsInstance<UTestSetStaticFieldStatement >()
248
+ .associate {
249
+ it.field.fieldId to instToModelConverter.findModelByInst(it.value)
250
+ }
251
+ val executableId: ExecutableId = method.method.toExecutableId(jcClasspath)
252
+ return EnvironmentModels (thisInstance, parameters, statics, executableId)
253
+ }
254
+
233
255
private fun createExecutionFailureResult (
234
256
exceptionDescriptor : UTestExceptionDescriptor ,
235
257
jcTypedMethod : JcTypedMethod ,
0 commit comments