Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1175678
squash constraint model synthesis
AbdullinAM Sep 28, 2022
d69ebc4
squash constraint model synthesis
AbdullinAM Sep 28, 2022
8d68488
resolver fix
AbdullinAM Sep 29, 2022
c6cac8d
model based post condition constructor restored
AbdullinAM Sep 29, 2022
df75f26
very primitive global timeoutfor synthesis
AbdullinAM Oct 11, 2022
e10a50e
Primitive Stream wrappers (no laziness and source mutations support) …
Damtev Sep 28, 2022
80da28b
Avoid summary duplication #985 (#1015)
onewhl Sep 28, 2022
608d56c
Fix bug in filtering Kotlin getters/setters in plugin (#1026)
volivan239 Sep 28, 2022
1f59106
Reordered the test clusters (#991)
amandelpie Sep 30, 2022
f96c118
Fix build directory for classes from Kotlin files (#1019)
volivan239 Sep 30, 2022
40bf31b
Improve choosing between simpleName and canonicalName in rendered cod…
EgorkaKulikov Sep 30, 2022
3380506
Run tests on `push` into release branches (#1045)
viktoriia-fomina Sep 30, 2022
234ace0
Fix utbot-maven compilation (#1049)
dtim Oct 1, 2022
1a0289d
Support AssertionError in SARIF report (#1032)
mmvpm Oct 3, 2022
7b417c9
Render links in the invokes part of JavaDocs (#1051)
onewhl Oct 3, 2022
0cedf7a
Improve fuzzer recursive model providers (#1039)
Markoutte Oct 3, 2022
4293d4f
IndexNotReadyException thrown in IDEA with installed UnitTestBot plug…
Vassiliy-Kudryashov Oct 3, 2022
a5d628c
Publish without workflow run number (#1053)
viktoriia-fomina Oct 3, 2022
ba08cb7
Modificators processing in AssembleModelGenerator and UtBotFieldModif…
EgorkaKulikov Oct 3, 2022
ae5b883
Gradle cache usage added #974 (#998)
bissquit Oct 4, 2022
b6d8a65
Try to fix memory leak in CgComponents (#1057)
EgorkaKulikov Oct 4, 2022
77194a3
Repeating SourceFolder fix (#1073)
Domonion Oct 4, 2022
0ff62da
Include information about triggered recursion to Javadocs (#1084)
onewhl Oct 4, 2022
e5d8b5f
Fix rendering for different IDE versions (#1087)
onewhl Oct 4, 2022
8016349
Fixed unavailable mock classes (#1066)
Damtev Oct 5, 2022
f55c96d
Engine process #2 (#1067)
Domonion Oct 5, 2022
f3af058
Remove unsat states from invokes (#1071)
CaelmBleidd Oct 5, 2022
e298169
Settings revision, 2nd iteration #977 (#1088)
Vassiliy-Kudryashov Oct 5, 2022
5a690b9
Fix soot initialization (#1090)
sergeypospelov Oct 5, 2022
cd3dcd1
Improve verification that static mocking is configured (#1091)
EgorkaKulikov Oct 5, 2022
b067af9
Fix assertions (#1096)
SBOne-Kenobi Oct 5, 2022
43efb96
Cancel test generation if compilation was not successful #1100 (#1103)
volivan239 Oct 5, 2022
bf272b6
Vassiliy kudryashov/1021 plugin support idea 20222 new (#1094)
Vassiliy-Kudryashov Oct 5, 2022
fc61391
Wrap method reference into @link tag only if the invoked method is no…
onewhl Oct 6, 2022
4ce788d
Notify and reason to the user that UtBot can't be run on the class in…
EgorkaKulikov Oct 6, 2022
0abc48b
Make snapshot version calendar-dependant (#1108)
Vassiliy-Kudryashov Oct 6, 2022
a215477
We create temporary files a lot, we have to clean it either (#1089)
Vassiliy-Kudryashov Oct 7, 2022
8280807
Get PsiClass' package by declaration in containingFile and not by its…
volivan239 Oct 7, 2022
8fb3938
Out of process bug fixes (#1109)
Domonion Oct 7, 2022
5fb1e16
Plugin setting to choose Kotlin generation doesn't work #1075 (#1110)
Vassiliy-Kudryashov Oct 7, 2022
ad150ba
Lessen thisInstance creation in parameterized test generation (#1065)
sofurihafe Oct 7, 2022
2f03687
Fix settings persistence: we save IDs, thus we should parse IDs inste…
Vassiliy-Kudryashov Oct 7, 2022
15bdfa8
Support Android Studio in utbot-intellij (#1121)
EgorkaKulikov Oct 10, 2022
166b393
Select Kotlin test src root by default when generating for Kotlin #94…
volivan239 Oct 10, 2022
c7618bb
Filter generated sources in Android Studio projects #692 (#1123)
EgorkaKulikov Oct 10, 2022
5479449
Exclude mocking javax (#1124)
SBOne-Kenobi Oct 10, 2022
06c548e
Linux engine process fix (#1126)
Domonion Oct 10, 2022
7e71d75
Android Studio troubleshooting related to Lombok improved (#1131)
EgorkaKulikov Oct 11, 2022
1a18c53
Other class is not mocked as required #747 (#1033)
Markoutte Oct 11, 2022
d1bea97
Add parameterized test generation in CI (#1114)
sofurihafe Oct 11, 2022
5181cef
Fix static mocking (#1142)
SBOne-Kenobi Oct 12, 2022
4706d1b
Added simple custom JavaDocs for the tests produced by Fuzzer (#1069)
amandelpie Oct 12, 2022
d36b988
Concrete execution fails for a static method using a static field #71…
Markoutte Oct 12, 2022
a55999d
Field assertions fixes (#920)
Damtev Oct 12, 2022
529c10d
Fix dump mode fail (#1146)
Domonion Oct 13, 2022
4470ea8
Refactor Sarif reports (#1152)
mmvpm Oct 13, 2022
d4cb666
Publish plugin and CLI for minor release (#1155)
viktoriia-fomina Oct 14, 2022
cad8133
Fixing long summarization timeouts & mics (#1151)
Domonion Oct 14, 2022
724b794
squash constraint model synthesis
AbdullinAM Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
squash constraint model synthesis
  • Loading branch information
AbdullinAM committed Sep 28, 2022
commit 1175678f49ba52b8b61ee86d9fd7bc81a3649208
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,12 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) :

protected fun saveToFile(snippet: String, outputPath: String?) =
outputPath?.let {
Files.write(it.toPath(), listOf(snippet))
val path = it.toPath()
path.toFile().parentFile?.mkdirs()
Files.write(path, listOf(snippet))
}

protected fun now(): LocalDateTime = LocalDateTime.now()

protected fun newline(): String = System.lineSeparator()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,28 @@ object UtSettings : AbstractSettings(
*/
var ignoreStaticsFromTrustedLibraries by getBooleanProperty(true)

/**
* Flag for enabling model synthesis
*/
var enableSynthesis by getBooleanProperty(false)

/**
* Flag for enabling model synthesis
*/
var enableSynthesisCache by getBooleanProperty(true)

/**
* Timeout model synthesis
*
*/
var synthesisTimeoutInMillis by getLongProperty(60000L)

/**
* Max depth for synthesis search
*
*/
var synthesisMaxDepth by getIntProperty(10)

/**
* Use the sandbox in the concrete executor.
*
Expand Down Expand Up @@ -439,7 +461,12 @@ enum class PathSelectorType {
/**
* [RandomPathSelector]
*/
RANDOM_PATH_SELECTOR
RANDOM_PATH_SELECTOR,

/**
* [ScoringPathSelector]
*/
SCORING_PATH_SELECTOR
}

enum class TestSelectionStrategyType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ class UtSymbolicExecution(
coverage: Coverage? = null,
summary: List<DocStatement>? = null,
testMethodName: String? = null,
displayName: String? = null
displayName: String? = null,
val constrainedExecution: ConstrainedExecution? = null
) : UtExecution(stateBefore, stateAfter, result, coverage, summary, testMethodName, displayName) {
/**
* By design the 'before' and 'after' states contain info about the same fields.
Expand Down Expand Up @@ -169,7 +170,12 @@ class UtSymbolicExecution(
append(")")
}

fun copy(stateAfter: EnvironmentModels, result: UtExecutionResult, coverage: Coverage): UtResult {
fun copy(
stateBefore: EnvironmentModels,
stateAfter: EnvironmentModels,
result: UtExecutionResult,
coverage: Coverage?,
): UtExecution {
return UtSymbolicExecution(
stateBefore,
stateAfter,
Expand All @@ -180,7 +186,8 @@ class UtSymbolicExecution(
coverage,
summary,
testMethodName,
displayName
displayName,
constrainedExecution
)
}
}
Expand Down Expand Up @@ -468,6 +475,80 @@ data class UtArrayModel(
}
}

/**
* Models for values with constraints
*/
sealed class UtConstraintModel(
open val variable: UtConstraintVariable
) : UtModel(variable.classId) {
abstract val utConstraints: Set<UtConstraint>
}

data class UtPrimitiveConstraintModel(
override val variable: UtConstraintVariable,
override val utConstraints: Set<UtConstraint>,
val concrete: Any? = null
) : UtConstraintModel(variable) {
}

data class UtReferenceConstraintModel(
override val variable: UtConstraintVariable,
override val utConstraints: Set<UtConstraint>,
) : UtConstraintModel(variable) {
fun isNull() = utConstraints.any {
it is UtRefEqConstraint && it.lhv == variable && it.rhv is UtConstraintNull
}
}

data class UtReferenceToConstraintModel(
override val variable: UtConstraintVariable,
val reference: UtModel,
override val utConstraints: Set<UtConstraint> = emptySet()
) : UtConstraintModel(variable)

sealed class UtElementContainerConstraintModel(
override val variable: UtConstraintVariable,
open val length: UtModel,
open val elements: Map<UtModel, UtModel>,
open val baseConstraints: Set<UtConstraint> = emptySet()
) : UtConstraintModel(variable) {
final override val utConstraints: Set<UtConstraint> get() =
baseConstraints + elements.toList().fold((length as UtConstraintModel).utConstraints) { acc, pair ->
acc +
((pair.first as? UtConstraintModel)?.utConstraints ?: emptySet()) +
((pair.second as? UtConstraintModel)?.utConstraints ?: emptySet())
}
}

data class UtArrayConstraintModel(
override val variable: UtConstraintVariable,
override val length: UtModel,
override val elements: Map<UtModel, UtModel>,
override val baseConstraints: Set<UtConstraint> = emptySet()
) : UtElementContainerConstraintModel(variable, length, elements)

data class UtListConstraintModel(
override val variable: UtConstraintVariable,
override val length: UtModel,
override val elements: Map<UtModel, UtModel>,
override val baseConstraints: Set<UtConstraint> = emptySet()
) : UtElementContainerConstraintModel(variable, length, elements)

data class UtSetConstraintModel(
override val variable: UtConstraintVariable,
override val length: UtModel,
override val elements: Map<UtModel, UtModel>,
override val baseConstraints: Set<UtConstraint> = emptySet()
) : UtElementContainerConstraintModel(variable, length, elements)

data class UtMapConstraintModel(
override val variable: UtConstraintVariable,
override val length: UtModel,
override val elements: Map<UtModel, UtModel>,
override val baseConstraints: Set<UtConstraint> = emptySet()
) : UtElementContainerConstraintModel(variable, length, elements)


/**
* Model for complex objects with assemble instructions.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ val atomicIntegerGetAndIncrement = MethodId(atomicIntegerClassId, "getAndIncreme

val iterableClassId = java.lang.Iterable::class.id
val mapClassId = java.util.Map::class.id
val setClassId = java.util.Set::class.id

val dateClassId = java.util.Date::class.id

Expand Down Expand Up @@ -357,6 +358,9 @@ val ClassId.isIterable: Boolean
val ClassId.isMap: Boolean
get() = isSubtypeOf(mapClassId)

val ClassId.isSet: Boolean
get() = isSubtypeOf(setClassId)

val ClassId.isIterableOrMap: Boolean
get() = isIterable || isMap

Expand Down Expand Up @@ -540,4 +544,4 @@ fun builtinConstructorId(classId: BuiltinClassId, vararg arguments: ClassId): Bu

fun builtinStaticMethodId(classId: ClassId, name: String, returnType: ClassId, vararg arguments: ClassId): BuiltinMethodId {
return BuiltinMethodId(classId, name, returnType, arguments.toList(), isStatic = true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class UtContext(val classLoader: ClassLoader) : ThreadContextElement<UtContext?>
fun currentContext(): UtContext? = threadLocalContextHolder.get()
fun setUtContext(context: UtContext): AutoCloseable = Cookie(context)

private fun restore(contextToRestore : UtContext?) {
private fun restore(contextToRestore: UtContext?) {
if (contextToRestore != null) {
threadLocalContextHolder.set(contextToRestore)
} else {
Expand Down
35 changes: 31 additions & 4 deletions utbot-framework/src/main/kotlin/org/utbot/engine/JimpleCreation.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
package org.utbot.engine

import soot.Local
import soot.Modifier
import soot.RefType
import soot.SootClass
import soot.SootMethod
import soot.Type
import soot.Unit
import soot.Value
import soot.jimple.AddExpr
import soot.jimple.ArrayRef
import soot.jimple.AssignStmt
import soot.jimple.DynamicInvokeExpr
import soot.jimple.GeExpr
import soot.jimple.GotoStmt
import soot.jimple.IdentityStmt
import soot.jimple.IfStmt
import soot.jimple.IntConstant
import soot.jimple.InterfaceInvokeExpr
import soot.jimple.InvokeExpr
import soot.jimple.InvokeStmt
import soot.jimple.Jimple
import soot.jimple.JimpleBody
import soot.jimple.NewArrayExpr
import soot.jimple.NewExpr
import soot.jimple.ParameterRef
import soot.jimple.ReturnStmt
import soot.jimple.ReturnVoidStmt
import soot.jimple.SpecialInvokeExpr
import soot.jimple.StaticInvokeExpr
import soot.jimple.VirtualInvokeExpr

fun SootMethod.toStaticInvokeExpr(): StaticInvokeExpr = Jimple.v().newStaticInvokeExpr(this.makeRef())
fun SootMethod.toStaticInvokeExpr(parameters: List<Value> = emptyList()): StaticInvokeExpr =
Jimple.v().newStaticInvokeExpr(this.makeRef(), parameters)

fun SootMethod.toSpecialInvoke(base: Local, parameters: List<Value> = emptyList()): SpecialInvokeExpr =
Jimple.v().newSpecialInvokeExpr(base, this.makeRef(), parameters)

fun SootMethod.toVirtualInvoke(base: Local, parameters: List<Value> = emptyList()): VirtualInvokeExpr =
Jimple.v().newVirtualInvokeExpr(base, this.makeRef(), parameters)

fun SootMethod.toInterfaceInvoke(base: Local, parameters: List<Value> = emptyList()): InterfaceInvokeExpr =
Jimple.v().newInterfaceInvokeExpr(base, this.makeRef(), parameters)

fun InvokeExpr.toInvokeStmt(): InvokeStmt = Jimple.v().newInvokeStmt(this)

Expand All @@ -36,6 +55,10 @@ fun identityStmt(local: Value, identityRef: Value): IdentityStmt = Jimple.v().ne

fun newArrayExpr(type: Type, size: Value): NewArrayExpr = Jimple.v().newNewArrayExpr(type, size)

fun newArrayRef(base: Value, index: Value): ArrayRef = Jimple.v().newArrayRef(base, index)

fun newExpr(type: RefType): NewExpr = Jimple.v().newNewExpr(type)

fun assignStmt(variable: Value, rValue: Value): AssignStmt = Jimple.v().newAssignStmt(variable, rValue)

fun intConstant(value: Int): IntConstant = IntConstant.v(value)
Expand All @@ -60,11 +83,15 @@ fun createSootMethod(
argsTypes: List<Type>,
returnType: Type,
declaringClass: SootClass,
graphBody: JimpleBody
) = SootMethod(name, argsTypes, returnType)
graphBody: JimpleBody,
isStatic: Boolean = false
) = SootMethod(name, argsTypes, returnType, Modifier.STATIC.takeIf { isStatic } ?: 0)
.also {
it.declaringClass = declaringClass
if (declaringClass.declaresMethod(it.subSignature)) {
declaringClass.removeMethod(declaringClass.getMethod(it.subSignature))
}
declaringClass.addMethod(it)
graphBody.method = it
it.activeBody = graphBody
}
}
7 changes: 4 additions & 3 deletions utbot-framework/src/main/kotlin/org/utbot/engine/Resolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import soot.Scene
import soot.ShortType
import soot.SootClass
import soot.SootField
import soot.SootMethod
import soot.Type
import soot.VoidType
import java.awt.color.ICC_ProfileRGB
Expand Down Expand Up @@ -118,7 +119,7 @@ class Resolver(
val typeRegistry: TypeRegistry,
private val typeResolver: TypeResolver,
val holder: UtSolverStatusSAT,
methodUnderTest: ExecutableId,
packageName: String,
private val softMaxArraySize: Int
) {

Expand All @@ -133,7 +134,7 @@ class Resolver(
private val instrumentation = mutableListOf<UtInstrumentation>()
private val requiredInstanceFields = mutableMapOf<Address, Set<FieldId>>()

private val assembleModelGenerator = AssembleModelGenerator(methodUnderTest.classId.packageName)
private val assembleModelGenerator = AssembleModelGenerator(packageName)

/**
* Contains FieldId of the static field which is construction at the moment and null of there is no such field.
Expand Down Expand Up @@ -1235,4 +1236,4 @@ private fun List<MockInfoEnriched>.mergeExecutables(): MockInfoEnriched {
return mockInfoEnriched.copy(executables = methodToExecutables)
}

data class ResolvedModels(val parameters: List<UtModel>, val statics: Map<FieldId, UtModel>)
data class ResolvedModels(val parameters: List<UtModel>, val statics: Map<FieldId, UtModel>)
Loading