Skip to content

Commit 61da8f1

Browse files
committed
Introduce utbot-modification-analyzer, use only methods that modify fields in Fuzzer
1 parent 0d38529 commit 61da8f1

File tree

23 files changed

+152
-85
lines changed

23 files changed

+152
-85
lines changed

settings.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ rootProject.name = "utbot"
2828
include("utbot-core")
2929
include("utbot-framework")
3030
include("utbot-framework-api")
31+
include("utbot-modification-analyzer")
3132
include("utbot-intellij")
3233
include("utbot-sample")
3334
include("utbot-java-fuzzing")
@@ -86,6 +87,3 @@ if (projectType == springEdition || projectType == ultimateEdition) {
8687
include("utbot-spring-sample")
8788
include("utbot-spring-test")
8889
}
89-
90-
91-
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.utbot.framework.util
2+
3+
import org.utbot.framework.plugin.api.ExecutableId
4+
import org.utbot.framework.plugin.api.classId
5+
import org.utbot.framework.plugin.api.id
6+
import org.utbot.framework.plugin.api.util.constructorId
7+
import org.utbot.framework.plugin.api.util.methodId
8+
import soot.SootMethod
9+
10+
/**
11+
* Gets method or constructor id of SootMethod.
12+
*/
13+
val SootMethod.executableId: ExecutableId
14+
get() = when {
15+
isConstructor -> constructorId(
16+
classId = declaringClass.id,
17+
arguments = parameterTypes.map { it.classId }.toTypedArray()
18+
)
19+
else -> methodId(
20+
classId = declaringClass.id,
21+
name = name,
22+
returnType = returnType.classId,
23+
arguments = parameterTypes.map { it.classId }.toTypedArray()
24+
)
25+
}

utbot-framework-test/src/test/kotlin/org/utbot/framework/modificators/UtBotFieldModificatorsTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import org.utbot.examples.modificators.StronglyConnectedComponents
1212
import org.utbot.examples.modificators.coupling.ClassA
1313
import org.utbot.examples.modificators.coupling.ClassB
1414
import org.utbot.examples.modificators.hierarchy.InheritedModifications
15-
import org.utbot.framework.modifications.AnalysisMode
16-
import org.utbot.framework.modifications.AnalysisMode.AllModificators
17-
import org.utbot.framework.modifications.AnalysisMode.SettersAndDirectAccessors
18-
import org.utbot.framework.modifications.UtBotFieldsModificatorsSearcher
15+
import org.utbot.modifications.AnalysisMode
16+
import org.utbot.modifications.AnalysisMode.AllModificators
17+
import org.utbot.modifications.AnalysisMode.SettersAndDirectAccessors
18+
import org.utbot.modifications.UtBotFieldsModificatorsSearcher
1919
import org.utbot.framework.plugin.api.util.UtContext
2020
import org.utbot.framework.plugin.api.util.id
2121
import kotlin.reflect.KClass
@@ -193,7 +193,7 @@ internal class UtBotFieldModificatorsTest {
193193

194194
//We use sorting here to make comparing with sorted in advance expected collections easier
195195
private fun runFieldModificatorsSearch(analysisMode: AnalysisMode) =
196-
fieldsModificatorsSearcher.findModificators(analysisMode)
196+
fieldsModificatorsSearcher.getFieldToModificators(analysisMode)
197197
.map { (key, value) ->
198198
val modificatorNames = value.filterNot { it.name.startsWith("direct_set_") }.map { it.name }
199199
key.name to modificatorNames.toSortedSet()

utbot-framework/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies {
1414
api project(':utbot-summary')
1515
api project(':utbot-framework-api')
1616
api project(':utbot-rd')
17+
api project(':utbot-modification-analyzer')
1718

1819
implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: rdVersion
1920
implementation group: 'com.jetbrains.rd', name: 'rd-core', version: rdVersion

utbot-framework/src/main/kotlin/org/utbot/engine/OptionalWrapper.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import org.utbot.framework.plugin.api.UtAssembleModel
1616
import org.utbot.framework.plugin.api.UtExecutableCallModel
1717
import org.utbot.framework.plugin.api.UtNullModel
1818
import org.utbot.framework.plugin.api.UtPrimitiveModel
19-
import org.utbot.framework.plugin.api.UtStatementModel
2019
import org.utbot.framework.plugin.api.classId
2120
import org.utbot.framework.plugin.api.id
2221
import org.utbot.framework.plugin.api.util.defaultValueModel

utbot-framework/src/main/kotlin/org/utbot/engine/StreamWrappers.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import org.utbot.framework.plugin.api.UtExecutableCallModel
1313
import org.utbot.framework.plugin.api.UtModel
1414
import org.utbot.framework.plugin.api.UtNullModel
1515
import org.utbot.framework.plugin.api.UtPrimitiveModel
16-
import org.utbot.framework.plugin.api.UtStatementModel
1716
import org.utbot.framework.plugin.api.classId
1817
import org.utbot.framework.plugin.api.util.defaultValueModel
1918
import org.utbot.framework.plugin.api.util.doubleArrayClassId
2019
import org.utbot.framework.plugin.api.util.doubleClassId
2120
import org.utbot.framework.plugin.api.util.doubleStreamClassId
22-
import org.utbot.framework.plugin.api.util.id
2321
import org.utbot.framework.plugin.api.util.intArrayClassId
2422
import org.utbot.framework.plugin.api.util.intClassId
2523
import org.utbot.framework.plugin.api.util.intStreamClassId

utbot-framework/src/main/kotlin/org/utbot/framework/assemble/AssembleModelGenerator.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import org.utbot.engine.ResolvedExecution
77
import org.utbot.engine.ResolvedModels
88
import org.utbot.framework.UtSettings
99
import org.utbot.framework.codegen.util.isAccessibleFrom
10-
import org.utbot.framework.modifications.AnalysisMode.SettersAndDirectAccessors
11-
import org.utbot.framework.modifications.ConstructorAnalyzer
12-
import org.utbot.framework.modifications.ConstructorAssembleInfo
13-
import org.utbot.framework.modifications.UtBotFieldsModificatorsSearcher
10+
import org.utbot.modifications.AnalysisMode.SettersAndDirectAccessors
11+
import org.utbot.modifications.ConstructorAnalyzer
12+
import org.utbot.modifications.ConstructorAssembleInfo
13+
import org.utbot.modifications.UtBotFieldsModificatorsSearcher
1414
import org.utbot.framework.plugin.api.ClassId
1515
import org.utbot.framework.plugin.api.ConstructorId
1616
import org.utbot.framework.plugin.api.DirectFieldAccessId
@@ -490,7 +490,7 @@ class AssembleModelGenerator(private val basePackageName: String) {
490490
* Finds setters and direct accessors for fields of particular class.
491491
*/
492492
private fun findSettersAndDirectAccessors(classId: ClassId): Map<FieldId, StatementId> {
493-
val allModificatorsOfClass = modificatorsSearcher.findModificators(SettersAndDirectAccessors)
493+
val allModificatorsOfClass = modificatorsSearcher.getFieldToModificators(SettersAndDirectAccessors)
494494

495495
return allModificatorsOfClass
496496
.mapNotNull { (fieldId, possibleModificators) ->

utbot-framework/src/main/kotlin/org/utbot/framework/context/spring/SpringIntegrationTestConcreteExecutionContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class SpringIntegrationTestConcreteExecutionContext(
8787
springApplicationContext.getBeansAssignableTo(classId).map { it.beanName }
8888
},
8989
relevantRepositories = relevantRepositories
90-
).withFallback(anyObjectValueProvider(idGenerator, isSpringProject = true))
90+
).withFallback(anyObjectValueProvider(idGenerator, shouldMutateWithMethods = true))
9191

9292
return delegateContext.tryCreateValueProvider(concreteExecutor, classUnderTest, idGenerator)
9393
.except { p -> p is ObjectValueProvider }

utbot-framework/src/main/kotlin/org/utbot/framework/modifications/AnalysisUtils.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

utbot-framework/src/main/kotlin/org/utbot/framework/util/EngineUtils.kt

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,18 @@ package org.utbot.framework.util
33
import mu.KotlinLogging
44
import org.utbot.common.logException
55
import org.utbot.framework.plugin.api.util.constructor.ValueConstructor
6-
import org.utbot.framework.plugin.api.ExecutableId
76
import org.utbot.framework.plugin.api.MissingState
87
import org.utbot.framework.plugin.api.UtSymbolicExecution
98
import org.utbot.framework.plugin.api.UtModel
109
import org.utbot.framework.plugin.api.UtMethodTestSet
1110
import org.utbot.framework.plugin.api.UtMethodValueTestSet
1211
import org.utbot.framework.plugin.api.UtVoidModel
13-
import org.utbot.framework.plugin.api.classId
14-
import org.utbot.framework.plugin.api.id
15-
import org.utbot.framework.plugin.api.util.constructorId
16-
import org.utbot.framework.plugin.api.util.methodId
1712
import java.util.concurrent.atomic.AtomicInteger
18-
import soot.SootMethod
1913

2014

2115
private val logger = KotlinLogging.logger { }
2216

23-
/**
24-
* Gets method or constructor id of SootMethod.
25-
*/
26-
val SootMethod.executableId: ExecutableId
27-
get() = when {
28-
isConstructor -> constructorId(
29-
classId = declaringClass.id,
30-
arguments = parameterTypes.map { it.classId }.toTypedArray()
31-
)
32-
else -> methodId(
33-
classId = declaringClass.id,
34-
name = name,
35-
returnType = returnType.classId,
36-
arguments = parameterTypes.map { it.classId }.toTypedArray()
37-
)
38-
}
39-
40-
val instanceCounter = AtomicInteger(0)
17+
private val instanceCounter = AtomicInteger(0)
4118

4219
fun nextModelName(base: String): String = "$base${instanceCounter.incrementAndGet()}"
4320

0 commit comments

Comments
 (0)