diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index fb6ae4d678..46be8c841b 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -2,7 +2,7 @@ object Versions { const val ksmt = "0.5.3" const val collections = "0.3.5" const val coroutines = "1.6.4" - const val jcdb = "1.0.0" + const val jcdb = "1.1.3" const val mockk = "1.13.4" const val junitParams = "5.9.3" diff --git a/usvm-core/src/main/kotlin/org/usvm/Context.kt b/usvm-core/src/main/kotlin/org/usvm/Context.kt index f73a2126c9..2b920cb82a 100644 --- a/usvm-core/src/main/kotlin/org/usvm/Context.kt +++ b/usvm-core/src/main/kotlin/org/usvm/Context.kt @@ -17,6 +17,7 @@ import org.usvm.memory.UInputArrayRegion import org.usvm.memory.UInputFieldRegion import org.usvm.memory.splitUHeapRef import org.usvm.solver.USolverBase +import org.usvm.types.UTypeSystem @Suppress("LeakingThis") open class UContext( @@ -91,8 +92,8 @@ open class UContext( lhs is UConcreteHeapRef && rhs is UConcreteHeapRef -> mkBool(lhs == rhs) // unfolding else -> { - val (concreteRefsLhs, symbolicRefLhs) = splitUHeapRef(lhs) - val (concreteRefsRhs, symbolicRefRhs) = splitUHeapRef(rhs) + val (concreteRefsLhs, symbolicRefLhs) = splitUHeapRef(lhs, ignoreNullRefs = false) + val (concreteRefsRhs, symbolicRefRhs) = splitUHeapRef(rhs, ignoreNullRefs = false) val concreteRefLhsToGuard = concreteRefsLhs.associate { it.expr.address to it.guard } diff --git a/usvm-core/src/main/kotlin/org/usvm/Expressions.kt b/usvm-core/src/main/kotlin/org/usvm/Expressions.kt index 493494db4a..34dd437b52 100644 --- a/usvm-core/src/main/kotlin/org/usvm/Expressions.kt +++ b/usvm-core/src/main/kotlin/org/usvm/Expressions.kt @@ -138,6 +138,28 @@ class UNullRef internal constructor( } } +// We split all addresses into three parts: +// * input values: [Int.MIN_VALUE..0), +// * null value: [0] +// * allocated values: (0..[Int.MAX_VALUE] + +/** + * A constant corresponding to `null`. + */ +const val NULL_ADDRESS = 0 + +/** + * A constant corresponding to the first input address in any decoded model. + * Input addresses takes this semi-interval: [[Int.MIN_VALUE]..0) + */ +const val INITIAL_INPUT_ADDRESS = NULL_ADDRESS - 1 +/** + * A constant corresponding to the first allocated address in any symbolic memory. + * Input addresses takes this semi-interval: (0..[Int.MAX_VALUE]) + */ +const val INITIAL_CONCRETE_ADDRESS = NULL_ADDRESS + 1 + + //endregion //region LValues @@ -342,6 +364,10 @@ class UIndexedMethodReturnValue<Method, Sort : USort> internal constructor( //region Subtyping Expressions +/** + * Means **either** [ref] is [UNullRef] **or** [ref] !is [UNullRef] and [ref] <: [type]. Thus, the actual type + * inheritance is checked only on non-null refs. + */ class UIsExpr<Type> internal constructor( ctx: UContext, val ref: UHeapRef, @@ -358,7 +384,7 @@ class UIsExpr<Type> internal constructor( override fun print(printer: ExpressionPrinter) { - TODO("Not yet implemented") + printer.append("($ref instance of $type)") } override fun internEquals(other: Any): Boolean = structurallyEqual(other, { ref }, { type }) @@ -372,4 +398,4 @@ class UIsExpr<Type> internal constructor( val UBoolExpr.isFalse get() = this == ctx.falseExpr val UBoolExpr.isTrue get() = this == ctx.trueExpr -//endregion \ No newline at end of file +//endregion diff --git a/usvm-core/src/main/kotlin/org/usvm/State.kt b/usvm-core/src/main/kotlin/org/usvm/State.kt index 57ca6a628e..a48d6c55c6 100644 --- a/usvm-core/src/main/kotlin/org/usvm/State.kt +++ b/usvm-core/src/main/kotlin/org/usvm/State.kt @@ -20,8 +20,6 @@ abstract class UState<Type, Field, Method, Statement>( open var models: List<UModelBase<Field, Type>>, open var path: PersistentList<Statement> ) { - open val ctx: UContext = ctx - /** * Deterministic state id. * TODO: Can be replaced with overridden hashCode @@ -74,7 +72,7 @@ private fun <T : UState<Type, Field, *, *>, Type, Field> forkIfSat( return null } - val solver = state.ctx.solver<Field, Type, Any?>() + val solver = satisfiedCondition.uctx.solver<Field, Type, Any?>() val satResult = solver.check(pathConstraints, useSoftConstraints = true) return when (satResult) { @@ -133,7 +131,7 @@ fun <T : UState<Type, Field, *, *>, Type, Field> fork( holdsInModel.isTrue } - val notCondition = state.ctx.mkNot(condition) + val notCondition = condition.uctx.mkNot(condition) val (posState, negState) = when { trueModels.isNotEmpty() && falseModels.isNotEmpty() -> { diff --git a/usvm-core/src/main/kotlin/org/usvm/StepScope.kt b/usvm-core/src/main/kotlin/org/usvm/StepScope.kt index f1989f1b9d..f49fc15c7f 100644 --- a/usvm-core/src/main/kotlin/org/usvm/StepScope.kt +++ b/usvm-core/src/main/kotlin/org/usvm/StepScope.kt @@ -50,7 +50,7 @@ class StepScope<T : UState<Type, Field, *, *>, Type, Field>( * Forks on a [condition], performing [blockOnTrueState] on a state satisfying [condition] and * [blockOnFalseState] on a state satisfying [condition].not(). * - * If the [condition], sets underlying state to `null`. + * If the [condition] is unsatisfiable, sets underlying state to `null`. * * @return `null` if the [condition] is unsatisfiable. */ diff --git a/usvm-core/src/main/kotlin/org/usvm/TypeSystem.kt b/usvm-core/src/main/kotlin/org/usvm/TypeSystem.kt deleted file mode 100644 index a15fd23cf9..0000000000 --- a/usvm-core/src/main/kotlin/org/usvm/TypeSystem.kt +++ /dev/null @@ -1,19 +0,0 @@ -package org.usvm - -interface UTypeSystem<Type> { - - /** - * Returns true if t <: u. - */ - fun isSupertype(u: Type, t: Type): Boolean - - /** - * Returns true if [t] can be supertype for some type together with some incomparable type u. - */ - fun isMultipleInheritanceAllowedFor(t: Type): Boolean - - /** - * Returns true if there is no type u distinct from [t] and subtyping [t]. - */ - fun isFinal(t: Type): Boolean -} diff --git a/usvm-core/src/main/kotlin/org/usvm/UComponents.kt b/usvm-core/src/main/kotlin/org/usvm/UComponents.kt index 83cef85967..3dc40355bf 100644 --- a/usvm-core/src/main/kotlin/org/usvm/UComponents.kt +++ b/usvm-core/src/main/kotlin/org/usvm/UComponents.kt @@ -1,6 +1,7 @@ package org.usvm import org.usvm.solver.USolverBase +import org.usvm.types.UTypeSystem /** * Provides core USVM components tuned for specific language. diff --git a/usvm-core/src/main/kotlin/org/usvm/constraints/EqualityConstraints.kt b/usvm-core/src/main/kotlin/org/usvm/constraints/EqualityConstraints.kt index 87b516ad69..67660eb74e 100644 --- a/usvm-core/src/main/kotlin/org/usvm/constraints/EqualityConstraints.kt +++ b/usvm-core/src/main/kotlin/org/usvm/constraints/EqualityConstraints.kt @@ -36,11 +36,11 @@ class UEqualityConstraints private constructor( equalReferences.subscribe(::rename) } - var isContradiction = false + var isContradicting = false private set private fun contradiction() { - isContradiction = true + isContradicting = true equalReferences.clear() mutableDistinctReferences.clear() mutableReferenceDisequalities.clear() @@ -89,8 +89,8 @@ class UEqualityConstraints private constructor( /** * Adds an assertion that [ref1] is always equal to [ref2]. */ - fun addReferenceEquality(ref1: UHeapRef, ref2: UHeapRef) { - if (isContradiction) { + fun makeEqual(ref1: UHeapRef, ref2: UHeapRef) { + if (isContradicting) { return } @@ -125,7 +125,7 @@ class UEqualityConstraints private constructor( mutableReferenceDisequalities.remove(from) fromDiseqs.forEach { mutableReferenceDisequalities[it]?.remove(from) - addReferenceDisequality(to, it) + makeNonEqual(to, it) } } @@ -142,7 +142,7 @@ class UEqualityConstraints private constructor( } } else if (containsNullableDisequality(from, to)) { // If x === y, nullable disequality can hold only if both references are null - addReferenceEquality(to, nullRepr) + makeEqual(to, nullRepr) } else { val removedFrom = mutableNullableDisequalities.remove(from) removedFrom?.forEach { @@ -210,8 +210,8 @@ class UEqualityConstraints private constructor( /** * Adds an assertion that [ref1] is never equal to [ref2]. */ - fun addReferenceDisequality(ref1: UHeapRef, ref2: UHeapRef) { - if (isContradiction) { + fun makeNonEqual(ref1: UHeapRef, ref2: UHeapRef) { + if (isContradicting) { return } @@ -233,7 +233,7 @@ class UEqualityConstraints private constructor( * Adds an assertion that [ref1] is never equal to [ref2] or both are null. */ fun makeNonEqualOrBothNull(ref1: UHeapRef, ref2: UHeapRef) { - if (isContradiction) { + if (isContradicting) { return } @@ -242,7 +242,7 @@ class UEqualityConstraints private constructor( if (repr1 == repr2) { // In this case, (repr1 != repr2) || (repr1 == null && repr2 == null) is equivalent to (repr1 == null). - addReferenceEquality(repr1, ctx.nullRef) + makeEqual(repr1, ctx.nullRef) return } @@ -284,9 +284,9 @@ class UEqualityConstraints private constructor( * Note that current subscribers get unsubscribed! */ fun clone(): UEqualityConstraints { - if (isContradiction) { + if (isContradicting) { val result = UEqualityConstraints(ctx, DisjointSets(), mutableSetOf(), mutableMapOf(), mutableMapOf()) - result.isContradiction = true + result.isContradicting = true return result } diff --git a/usvm-core/src/main/kotlin/org/usvm/constraints/PathConstraints.kt b/usvm-core/src/main/kotlin/org/usvm/constraints/PathConstraints.kt index 49fa5ed871..40a2cb9451 100644 --- a/usvm-core/src/main/kotlin/org/usvm/constraints/PathConstraints.kt +++ b/usvm-core/src/main/kotlin/org/usvm/constraints/PathConstraints.kt @@ -41,8 +41,8 @@ open class UPathConstraints<Type> private constructor( constructor(ctx: UContext) : this(ctx, persistentSetOf()) open val isFalse: Boolean - get() = equalityConstraints.isContradiction || - typeConstraints.isContradiction || + get() = equalityConstraints.isContradicting || + typeConstraints.isContradicting || logicalConstraints.singleOrNull() is UFalse @Suppress("UNCHECKED_CAST") @@ -54,9 +54,9 @@ open class UPathConstraints<Type> private constructor( constraint == trueExpr || constraint in logicalConstraints -> {} constraint is UEqExpr<*> && isSymbolicHeapRef(constraint.lhs) && isSymbolicHeapRef(constraint.rhs) -> - equalityConstraints.addReferenceEquality(constraint.lhs as UHeapRef, constraint.rhs as UHeapRef) + equalityConstraints.makeEqual(constraint.lhs as UHeapRef, constraint.rhs as UHeapRef) - constraint is UIsExpr<*> -> typeConstraints.cast(constraint.ref, constraint.type as Type) + constraint is UIsExpr<*> -> typeConstraints.addSupertype(constraint.ref, constraint.type as Type) constraint is UAndExpr -> constraint.args.forEach(::plusAssign) @@ -67,12 +67,17 @@ open class UPathConstraints<Type> private constructor( isSymbolicHeapRef(notConstraint.lhs) && isSymbolicHeapRef(notConstraint.rhs) -> { require(notConstraint.rhs.sort == addressSort) - equalityConstraints.addReferenceDisequality( + equalityConstraints.makeNonEqual( notConstraint.lhs as UHeapRef, notConstraint.rhs as UHeapRef ) } + notConstraint is UIsExpr<*> -> typeConstraints.excludeSupertype( + notConstraint.ref, + notConstraint.type as Type + ) + notConstraint in logicalConstraints -> contradiction(ctx) notConstraint is UOrExpr -> notConstraint.args.forEach { plusAssign(ctx.mkNot(it)) } diff --git a/usvm-core/src/main/kotlin/org/usvm/constraints/TypeConstraints.kt b/usvm-core/src/main/kotlin/org/usvm/constraints/TypeConstraints.kt index 75330620ec..9625e4f4bb 100644 --- a/usvm-core/src/main/kotlin/org/usvm/constraints/TypeConstraints.kt +++ b/usvm-core/src/main/kotlin/org/usvm/constraints/TypeConstraints.kt @@ -1,33 +1,27 @@ package org.usvm.constraints +import org.usvm.NULL_ADDRESS import org.usvm.UBoolExpr import org.usvm.UConcreteHeapAddress import org.usvm.UConcreteHeapRef import org.usvm.UHeapRef -import org.usvm.UTypeSystem +import org.usvm.UNullRef +import org.usvm.memory.map +import org.usvm.model.UModel +import org.usvm.model.UTypeModel +import org.usvm.solver.USatResult +import org.usvm.solver.USolverResult +import org.usvm.solver.UUnsatResult +import org.usvm.types.USingleTypeStream +import org.usvm.types.UTypeRegion +import org.usvm.types.UTypeStream +import org.usvm.types.UTypeSystem import org.usvm.uctx interface UTypeEvaluator<Type> { fun evalIs(ref: UHeapRef, type: Type): UBoolExpr } -class UTypeModel<Type>( - private val typeSystem: UTypeSystem<Type>, - private val typeByAddr: Map<UConcreteHeapAddress, Type>, -) : UTypeEvaluator<Type> { - fun typeOf(address: UConcreteHeapAddress): Type = typeByAddr.getValue(address) - - override fun evalIs(ref: UHeapRef, type: Type): UBoolExpr = - when (ref) { - is UConcreteHeapRef -> { - val holds = typeSystem.isSupertype(type, typeOf(ref.address)) - if (holds) ref.ctx.trueExpr else ref.ctx.falseExpr - } - - else -> throw IllegalArgumentException("Expecting concrete ref, but got $ref") - } -} - /** * A mutable collection of type constraints. Represents a conjunction of constraints of four kinds: * 1. x <: T, i.e. object referenced in x inherits T (supertype constraints for x) @@ -35,7 +29,7 @@ class UTypeModel<Type>( * 3. x </: T, i.e. object referenced in x does not inherit T (notSupertype constraints for x) * 4. T </: x, i.e. object referenced in x is not inherited by T (notSubtype constraints for x) * - * Adding subtype constraint for x is done via [cast] method. + * Adding subtype constraint for x is done via [addSupertype] method. * TODO: The API for rest type constraints will be added later. * * Manages allocated objects separately from input ones. Indeed, we know the type of an allocated object @@ -44,46 +38,56 @@ class UTypeModel<Type>( class UTypeConstraints<Type>( private val typeSystem: UTypeSystem<Type>, private val equalityConstraints: UEqualityConstraints, - private val concreteTypes: MutableMap<UConcreteHeapAddress, Type> = mutableMapOf(), - private val symbolicTypes: MutableMap<UHeapRef, UTypeRegion<Type>> = mutableMapOf(), + private val concreteRefToType: MutableMap<UConcreteHeapAddress, Type> = mutableMapOf(), + private val symbolicRefToTypeRegion: MutableMap<UHeapRef, UTypeRegion<Type>> = mutableMapOf(), ) : UTypeEvaluator<Type> { init { equalityConstraints.subscribe(::intersectConstraints) } /** - * Returns if current type and equality constraints are unsatisfiable (syntactically). + * Returns true if the current type and equality constraints are unsatisfiable (syntactically). */ - var isContradiction = false + var isContradicting = false private set + private val topTypeRegion by lazy { + UTypeRegion( + typeSystem, + typeSystem.topTypeStream() + ) + } + private fun contradiction() { - isContradiction = true + isContradicting = true } /** * Binds concrete heap address [ref] to its [type]. */ fun allocate(ref: UConcreteHeapAddress, type: Type) { - concreteTypes[ref] = type + concreteRefToType[ref] = type } private operator fun get(symbolicRef: UHeapRef) = - symbolicTypes[equalityConstraints.equalReferences.find(symbolicRef)] ?: UTypeRegion(typeSystem) + symbolicRefToTypeRegion[equalityConstraints.equalReferences.find(symbolicRef)] ?: topTypeRegion + private operator fun set(symbolicRef: UHeapRef, value: UTypeRegion<Type>) { - symbolicTypes[equalityConstraints.equalReferences.find(symbolicRef)] = value + symbolicRefToTypeRegion[equalityConstraints.equalReferences.find(symbolicRef)] = value } /** - * Constraints type of [ref] to be a subtype of [type]. - * If it is impossible within current type and equality constraints, - * then type constraints become contradicting (@see [isContradiction]). + * Constraints **either** the [ref] is null **or** the [ref] isn't null and the type of the [ref] to + * be a subtype of the [type]. If it is impossible within current type and equality constraints, + * then type constraints become contradicting (@see [isContradicting]). */ - fun cast(ref: UHeapRef, type: Type) { + fun addSupertype(ref: UHeapRef, type: Type) { when (ref) { + is UNullRef -> return + is UConcreteHeapRef -> { - val concreteType = concreteTypes.getValue(ref.address) + val concreteType = concreteRefToType.getValue(ref.address) if (!typeSystem.isSupertype(type, concreteType)) { contradiction() } @@ -93,10 +97,11 @@ class UTypeConstraints<Type>( val constraints = this[ref] val newConstraints = constraints.addSupertype(type) if (newConstraints.isContradicting) { - contradiction() + // the only left option here is to be equal to null + equalityConstraints.makeEqual(ref, ref.uctx.nullRef) } else { // Inferring new symbolic disequalities here - for ((key, value) in symbolicTypes.entries) { + for ((key, value) in symbolicRefToTypeRegion.entries) { // TODO: cache intersections? if (key != ref && value.intersect(newConstraints).isEmpty) { // If we have two inputs of incomparable reference types, then they are either non equal, @@ -110,32 +115,223 @@ class UTypeConstraints<Type>( } } - private fun intersectConstraints(ref1: UHeapRef, ref2: UHeapRef) { - this[ref1] = this[ref1].intersect(this[ref2]) - } - - override fun evalIs(ref: UHeapRef, type: Type): UBoolExpr { + /** + * Constraints **both** the type of the [ref] to be a not subtype of the [type] and the [ref] not equals null. + * If it is impossible within current type and equality constraints, + * then type constraints become contradicting (@see [isContradicting]). + */ + fun excludeSupertype(ref: UHeapRef, type: Type) { when (ref) { + is UNullRef -> contradiction() // the [ref] can't be equal to null + is UConcreteHeapRef -> { - val concreteType = concreteTypes.getValue(ref.address) - return if (typeSystem.isSupertype(type, concreteType)) ref.ctx.trueExpr else ref.ctx.falseExpr + val concreteType = concreteRefToType.getValue(ref.address) + if (typeSystem.isSupertype(type, concreteType)) { + contradiction() + } } else -> { val constraints = this[ref] - - if (constraints.addSupertype(type).isContradicting) { - return ref.ctx.falseExpr + val newConstraints = constraints.excludeSupertype(type) + equalityConstraints.makeNonEqual(ref, ref.uctx.nullRef) + if (newConstraints.isContradicting || equalityConstraints.isContradicting) { + // the [ref] can't be equal to null + contradiction() + } else { + // Inferring new symbolic disequalities here + for ((key, value) in symbolicRefToTypeRegion.entries) { + // TODO: cache intersections? + if (key != ref && value.intersect(newConstraints).isEmpty) { + // If we have two inputs of incomparable reference types, then they are non equal + equalityConstraints.makeNonEqual(ref, key) + } + } + this[ref] = newConstraints } + } + } + } - return ref.uctx.mkIsExpr(ref, type) + /** + * @return a type stream corresponding to the [ref]. + */ + internal fun readTypeStream(ref: UHeapRef): UTypeStream<Type> = + when (ref) { + is UConcreteHeapRef -> { + val concreteType = concreteRefToType[ref.address] + val typeStream = if (concreteType == null) { + typeSystem.topTypeStream() + } else { + USingleTypeStream(typeSystem, concreteType) + } + typeStream } + + is UNullRef -> error("Null ref should be handled explicitly earlier") + else -> this[ref].typeStream } + + private fun intersectConstraints(ref1: UHeapRef, ref2: UHeapRef) { + this[ref1] = this[ref1].intersect(this[ref2]) } + /** + * Evaluates the [ref] <: [type] in the current [UTypeConstraints]. Always returns true on null references. + */ + override fun evalIs(ref: UHeapRef, type: Type): UBoolExpr = + ref.map( + concreteMapper = { concreteRef -> + val concreteType = concreteRefToType.getValue(concreteRef.address) + if (typeSystem.isSupertype(type, concreteType)) { + concreteRef.ctx.trueExpr + } else { + concreteRef.ctx.falseExpr + } + }, + symbolicMapper = mapper@{ symbolicRef -> + if (symbolicRef == symbolicRef.uctx.nullRef) { + // accordingly to the [UIsExpr] specification, [nullRef] always satisfies the [type] + return@mapper symbolicRef.ctx.trueExpr + } + val typeRegion = this[symbolicRef] + + if (typeRegion.addSupertype(type).isContradicting) { + symbolicRef.ctx.falseExpr + } else { + symbolicRef.uctx.mkIsExpr(symbolicRef, type) + } + }, + ignoreNullRefs = false + ) + + /** * Creates a mutable copy of these constraints connected to new instance of [equalityConstraints]. */ fun clone(equalityConstraints: UEqualityConstraints) = - UTypeConstraints(typeSystem, equalityConstraints, concreteTypes.toMutableMap(), symbolicTypes.toMutableMap()) + UTypeConstraints( + typeSystem, + equalityConstraints, + concreteRefToType.toMutableMap(), + symbolicRefToTypeRegion.toMutableMap() + ) + + /** + * Checks if the [model] satisfies this [UTypeConstraints]. + * + * Checking works as follows: + * 1. Groups symbolic references into clusters by their concrete interpretation in the [model] and filters out nulls + * 2. For each cluster processes symbolic references one by one and intersects their type regions + * 3. If the current region became empty, then we found a conflicting group, so add reference disequality + * 4. If no conflicting references were found, builds a type model + * + * Example: + * ``` + * a <: T1 | T2 + * b <: T2 | T3 + * c <: T3 | T1 + * d <: T1 | T2 + * e <: T2 + * cluster: (a, b, c, d, e) + * ``` + * Suppose we have the single cluster, so we process it as follows: + * + * 1. Peek `a`. The current region is empty, so it becomes `T1 | T2`. Potential conflicting refs = `{a}`. + * 2. Peek `b`. The current region becomes `T2`. Potential conflicting refs = `{a, b}`. + * 3. Peek `c`. The intersection of the current region with `T3 | T1` is empty, so we add the following constraint: + * `a != c || b != c || a == null || b == null || c == null`. The region becomes `T3 | T1`. + * Potential conflicting refs = `{c}. + * 4. Peek `d`. The current region becomes `T1`. Potential conflicting refs = `{c, d}`. + * 5. Peek `e`. The intersection of the current region with `T2` is empty, so we add the following constraint: + * `c != e || d != e || c == null || d == null || e == null`. + * + * @return The result of verification: + * * [UTypeModel] if the [model] satisfies this [UTypeConstraints] + * * [UUnsatResult] if no model satisfying this [UTypeConstraints] exists + * * [UTypeUnsatResult] with reference disequalities constraints if the [model] + * doesn't satisfy this [UTypeConstraints], but other model may satisfy + */ + fun verify(model: UModel): USolverResult<UTypeModel<Type>> { + // firstly, group symbolic references by their interpretations in the [model] + val concreteRefToTypeRegions = symbolicRefToTypeRegion + .entries + .groupBy { (key, _) -> (model.eval(key) as UConcreteHeapRef).address } + .filter { it.key != NULL_ADDRESS } // we don't want to evaluate types of nulls + + val bannedRefEqualities = mutableListOf<UBoolExpr>() + + // then for each group check conflicting types + val concreteToRegionWithCluster = concreteRefToTypeRegions.mapValues { (_, cluster) -> + var currentRegion: UTypeRegion<Type>? = null + val potentialConflictingRefs = mutableListOf<UHeapRef>() + + for ((heapRef, region) in cluster) { + if (currentRegion == null) { // process the first element + currentRegion = region + potentialConflictingRefs.add(heapRef) + } else { + var nextRegion = currentRegion.intersect(region) // add [heapRef] to the current region + if (nextRegion.isEmpty) { + // conflict detected, so it's impossible for [potentialConflictingRefs] + // to have the common type with [heapRef], therefore they can't be equal or + // some of them equals null + val disjunct = mutableListOf<UBoolExpr>() + with(heapRef.uctx) { + // can't be equal to heapRef + potentialConflictingRefs.mapTo(disjunct) { it.neq(heapRef) } + // some of them is null + potentialConflictingRefs.mapTo(disjunct) { it.eq(nullRef) } + disjunct += heapRef.eq(nullRef) + } + bannedRefEqualities += heapRef.ctx.mkOr(disjunct) + + // start a new group + nextRegion = region + potentialConflictingRefs.clear() + potentialConflictingRefs.add(heapRef) + } else if (nextRegion == region) { + // the current [heapRef] gives the same region as the potentialConflictingRefs, so it's better + // to keep only the [heapRef] to minimize the disequalities amount in the result disjunction + potentialConflictingRefs.clear() + potentialConflictingRefs.add(heapRef) + } else if (nextRegion != currentRegion) { + // no conflict detected, but the current region became smaller + potentialConflictingRefs.add(heapRef) + } + + currentRegion = nextRegion + } + } + checkNotNull(currentRegion) + + currentRegion to cluster + } + + // if there were some conflicts, return constraints on reference equalities + if (bannedRefEqualities.isNotEmpty()) { + return UTypeUnsatResult(bannedRefEqualities) + } + + // otherwise, return the type assignment + val allConcreteRefToType = concreteToRegionWithCluster.mapValues { (_, regionToCluster) -> + val (region, cluster) = regionToCluster + val typeStream = region.typeStream + if (typeStream.isEmpty) { + // the only way to reach here is when some of the clusters consists of a single reference + // because if the cluster is bigger, then we called region.isEmpty previously at least once + check(cluster.size == 1) + return UUnsatResult() + } + + typeStream + } + + val typeModel = UTypeModel(typeSystem, allConcreteRefToType) + return USatResult(typeModel) + } } + +class UTypeUnsatResult<Type>( + val referenceDisequalitiesDisjuncts: List<UBoolExpr>, +) : UUnsatResult<UTypeModel<Type>>() diff --git a/usvm-core/src/main/kotlin/org/usvm/memory/Heap.kt b/usvm-core/src/main/kotlin/org/usvm/memory/Heap.kt index aac494706d..3361f29f35 100644 --- a/usvm-core/src/main/kotlin/org/usvm/memory/Heap.kt +++ b/usvm-core/src/main/kotlin/org/usvm/memory/Heap.kt @@ -3,6 +3,7 @@ package org.usvm.memory import io.ksmt.utils.asExpr import kotlinx.collections.immutable.PersistentMap import kotlinx.collections.immutable.persistentMapOf +import org.usvm.INITIAL_CONCRETE_ADDRESS import org.usvm.UBoolExpr import org.usvm.UConcreteHeapAddress import org.usvm.UConcreteHeapRef @@ -74,16 +75,6 @@ typealias USymbolicHeap<Field, ArrayType> = UHeap<UHeapRef, UExpr<out USort>, US class UAddressCounter { private var lastAddress = INITIAL_CONCRETE_ADDRESS fun freshAddress(): UConcreteHeapAddress = lastAddress++ - - companion object { - // We split all addresses into three parts: - // * input values: [Int.MIN_VALUE..0), - // * null value: [0] - // * allocated values: (0..Int.MAX_VALUE] - const val NULL_ADDRESS = 0 - const val INITIAL_INPUT_ADDRESS = NULL_ADDRESS - 1 - const val INITIAL_CONCRETE_ADDRESS = NULL_ADDRESS + 1 - } } class URegionHeap<Field, ArrayType>( diff --git a/usvm-core/src/main/kotlin/org/usvm/memory/HeapRefSplitting.kt b/usvm-core/src/main/kotlin/org/usvm/memory/HeapRefSplitting.kt index 6911eeb171..445c500224 100644 --- a/usvm-core/src/main/kotlin/org/usvm/memory/HeapRefSplitting.kt +++ b/usvm-core/src/main/kotlin/org/usvm/memory/HeapRefSplitting.kt @@ -6,9 +6,11 @@ import org.usvm.UConcreteHeapRef import org.usvm.UExpr import org.usvm.UHeapRef import org.usvm.UIteExpr +import org.usvm.UNullRef import org.usvm.USort import org.usvm.USymbolicHeapRef import org.usvm.isFalse +import org.usvm.uctx data class GuardedExpr<out T>( val expr: T, @@ -38,11 +40,17 @@ internal data class SplitHeapRefs( * leafs in the [ref] ite. Otherwise, it will contain an ite with the guard protecting from bubbled up concrete refs. * * @param initialGuard an initial value for the accumulated guard. + * @param ignoreNullRefs if true, then null references will be ignored. It means that all leafs with nulls + * considered unsatisfiable, so we assume their guards equal to false, and they won't be added to the result. */ -internal fun splitUHeapRef(ref: UHeapRef, initialGuard: UBoolExpr = ref.ctx.trueExpr): SplitHeapRefs { +internal fun splitUHeapRef( + ref: UHeapRef, + initialGuard: UBoolExpr = ref.ctx.trueExpr, + ignoreNullRefs: Boolean = true, +): SplitHeapRefs { val concreteHeapRefs = mutableListOf<GuardedExpr<UConcreteHeapRef>>() - val symbolicHeapRef = filter(ref, initialGuard) { guarded -> + val symbolicHeapRef = filter(ref, initialGuard, ignoreNullRefs) { guarded -> if (guarded.expr is UConcreteHeapRef) { @Suppress("UNCHECKED_CAST") concreteHeapRefs += (guarded as GuardedExpr<UConcreteHeapRef>) @@ -64,12 +72,15 @@ internal fun splitUHeapRef(ref: UHeapRef, initialGuard: UBoolExpr = ref.ctx.true * heap refs from the [ref] if it's ite. * * @param initialGuard the initial value fot the guard to be passed to [blockOnConcrete] and [blockOnSymbolic]. + * @param ignoreNullRefs if true, then null references will be ignored. It means that all leafs with nulls + * considered unsatisfiable, so we assume their guards equal to false. */ internal inline fun withHeapRef( ref: UHeapRef, initialGuard: UBoolExpr, crossinline blockOnConcrete: (GuardedExpr<UConcreteHeapRef>) -> Unit, crossinline blockOnSymbolic: (GuardedExpr<UHeapRef>) -> Unit, + ignoreNullRefs: Boolean = true, ) { if (initialGuard.isFalse) { return @@ -77,9 +88,13 @@ internal inline fun withHeapRef( when (ref) { is UConcreteHeapRef -> blockOnConcrete(ref with initialGuard) + is UNullRef -> if (!ignoreNullRefs) { + blockOnSymbolic(ref with initialGuard) + } + is USymbolicHeapRef -> blockOnSymbolic(ref with initialGuard) is UIteExpr<UAddressSort> -> { - val (concreteHeapRefs, symbolicHeapRef) = splitUHeapRef(ref, initialGuard) + val (concreteHeapRefs, symbolicHeapRef) = splitUHeapRef(ref, initialGuard, ignoreNullRefs) symbolicHeapRef?.let { (ref, guard) -> blockOnSymbolic(ref with guard) } concreteHeapRefs.onEach { (ref, guard) -> blockOnConcrete(ref with guard) } @@ -98,12 +113,22 @@ private const val DONE = 2 * Reassembles [this] non-recursively with applying [concreteMapper] on [UConcreteHeapRef] and * [symbolicMapper] on [USymbolicHeapRef]. Respects [UIteExpr], so the structure of the result expression will be * the same as [this] is, but implicit simplifications may occur. + * + * @param ignoreNullRefs if true, then null references will be ignored. It means that all leafs with nulls + * considered unsatisfiable, so we assume their guards equal to false. If [ignoreNullRefs] is true and [this] is + * [UNullRef], throws an [IllegalArgumentException]. */ internal inline fun <Sort : USort> UHeapRef.map( crossinline concreteMapper: (UConcreteHeapRef) -> UExpr<Sort>, crossinline symbolicMapper: (USymbolicHeapRef) -> UExpr<Sort>, + ignoreNullRefs: Boolean = true, ): UExpr<Sort> = when (this) { is UConcreteHeapRef -> concreteMapper(this) + is UNullRef -> { + require(!ignoreNullRefs) { "Got nullRef on the top!" } + symbolicMapper(this) + } + is USymbolicHeapRef -> symbolicMapper(this) is UIteExpr<UAddressSort> -> { /** @@ -115,21 +140,37 @@ internal inline fun <Sort : USort> UHeapRef.map( nodeToChild.add(this to LEFT_CHILD) + while (nodeToChild.isNotEmpty()) { val (ref, state) = nodeToChild.removeLast() when (ref) { is UConcreteHeapRef -> completelyMapped += concreteMapper(ref) is USymbolicHeapRef -> completelyMapped += symbolicMapper(ref) is UIteExpr<UAddressSort> -> { + when (state) { LEFT_CHILD -> { - nodeToChild += ref to RIGHT_CHILD - nodeToChild += ref.trueBranch to LEFT_CHILD + when { + ignoreNullRefs && ref.trueBranch == uctx.nullRef -> { + nodeToChild += ref.falseBranch to LEFT_CHILD + } + + ignoreNullRefs && ref.falseBranch == uctx.nullRef -> { + nodeToChild += ref.trueBranch to LEFT_CHILD + } + + else -> { + nodeToChild += ref to RIGHT_CHILD + nodeToChild += ref.trueBranch to LEFT_CHILD + } + } } + RIGHT_CHILD -> { nodeToChild += ref to DONE nodeToChild += ref.falseBranch to LEFT_CHILD } + DONE -> { // we firstly process the left child of [cur], so it will be under the top of the stack // the top of the stack will be the right child @@ -160,6 +201,7 @@ internal inline fun <Sort : USort> UHeapRef.map( internal inline fun filter( ref: UHeapRef, initialGuard: UBoolExpr, + ignoreNullRefs: Boolean, crossinline predicate: (GuardedExpr<UHeapRef>) -> Boolean, ): GuardedExpr<UHeapRef>? = with(ref.ctx) { when (ref) { @@ -179,15 +221,29 @@ internal inline fun filter( when (cur) { is UIteExpr<UAddressSort> -> when (state) { LEFT_CHILD -> { - nodeToChild += guarded to RIGHT_CHILD - val leftGuard = mkAnd(guardFromTop, cur.condition, flat = false) - nodeToChild += (cur.trueBranch with leftGuard) to LEFT_CHILD + when { + ignoreNullRefs && cur.trueBranch == cur.uctx.nullRef -> { + nodeToChild += (cur.falseBranch with guardFromTop) to LEFT_CHILD + } + + ignoreNullRefs && cur.falseBranch == cur.uctx.nullRef -> { + nodeToChild += (cur.trueBranch with guardFromTop) to LEFT_CHILD + } + + else -> { + nodeToChild += guarded to RIGHT_CHILD + val leftGuard = mkAnd(guardFromTop, cur.condition, flat = false) + nodeToChild += (cur.trueBranch with leftGuard) to LEFT_CHILD + } + } } + RIGHT_CHILD -> { nodeToChild += guarded to DONE val guardRhs = mkAnd(guardFromTop, !cur.condition, flat = false) nodeToChild += (cur.falseBranch with guardRhs) to LEFT_CHILD } + DONE -> { // we firstly process the left child of [cur], so it will be under the top of the stack // the top of the stack will be the right child @@ -202,7 +258,7 @@ internal inline fun filter( /** *``` * cur.condition | guard = ( cur.condition -> lhs.guard) && - / \ (!cur.condition -> rhs.guard) + * / \ (!cur.condition -> rhs.guard) * / \ * / \ * / \ @@ -213,14 +269,17 @@ internal inline fun filter( val guard = mkAnd(leftPart, rightPart, flat = false) mkIte(cur.condition, lhs.expr, rhs.expr) with guard } + lhs != null -> { val guard = mkAnd(cur.condition, lhs.guard, flat = false) lhs.expr with guard } + rhs != null -> { val guard = mkAnd(!cur.condition, rhs.guard, flat = false) rhs.expr with guard } + else -> null } completelyMapped += next @@ -234,6 +293,10 @@ internal inline fun filter( completelyMapped.single()?.withAlso(initialGuard) } - else -> (ref with initialGuard).takeIf(predicate) + else -> if (ref != ref.uctx.nullRef || !ignoreNullRefs) { + (ref with initialGuard).takeIf(predicate) + } else { + null + } } } \ No newline at end of file diff --git a/usvm-core/src/main/kotlin/org/usvm/memory/Memory.kt b/usvm-core/src/main/kotlin/org/usvm/memory/Memory.kt index 7555e860ed..61278fe7ca 100644 --- a/usvm-core/src/main/kotlin/org/usvm/memory/Memory.kt +++ b/usvm-core/src/main/kotlin/org/usvm/memory/Memory.kt @@ -16,6 +16,7 @@ import org.usvm.URegisterLValue import org.usvm.USizeExpr import org.usvm.USort import org.usvm.constraints.UTypeConstraints +import org.usvm.types.UTypeStream interface UReadOnlyMemory<LValue, RValue> { /** @@ -24,7 +25,14 @@ interface UReadOnlyMemory<LValue, RValue> { fun read(lvalue: LValue): RValue } -interface UMemory<LValue, RValue, SizeT, HeapRef, Type> : UReadOnlyMemory<LValue, RValue> { +interface UReadOnlyTypedMemory<LValue, RValue, HeapRef, Type> : UReadOnlyMemory<LValue, RValue> { + /** + * @return a type stream corresponding to the [ref]. + */ + fun typeStreamOf(ref: HeapRef): UTypeStream<Type> +} + +interface UMemory<LValue, RValue, SizeT, HeapRef, Type> : UReadOnlyTypedMemory<LValue, RValue, HeapRef, Type> { /** * Writes [rvalue] into memory cell referenced by [lvalue]. */ @@ -74,7 +82,7 @@ interface UMemory<LValue, RValue, SizeT, HeapRef, Type> : UReadOnlyMemory<LValue ) } -typealias UReadOnlySymbolicMemory = UReadOnlyMemory<ULValue, UExpr<out USort>> +typealias UReadOnlySymbolicMemory<Type> = UReadOnlyTypedMemory<ULValue, UExpr<out USort>, UHeapRef, Type> typealias USymbolicMemory<Type> = UMemory<ULValue, UExpr<out USort>, USizeExpr, UHeapRef, Type> @Suppress("MemberVisibilityCanBePrivate") @@ -152,4 +160,7 @@ open class UMemoryBase<Field, Type, Method>( fun clone(typeConstraints: UTypeConstraints<Type>): UMemoryBase<Field, Type, Method> = UMemoryBase(ctx, typeConstraints, stack.clone(), heap.toMutableHeap(), mocker) + + override fun typeStreamOf(ref: UHeapRef): UTypeStream<Type> = + types.readTypeStream(ref) } diff --git a/usvm-core/src/main/kotlin/org/usvm/memory/MemoryRegions.kt b/usvm-core/src/main/kotlin/org/usvm/memory/MemoryRegions.kt index bd98587e3e..f93f7a7d2c 100644 --- a/usvm-core/src/main/kotlin/org/usvm/memory/MemoryRegions.kt +++ b/usvm-core/src/main/kotlin/org/usvm/memory/MemoryRegions.kt @@ -126,7 +126,8 @@ data class USymbolicMemoryRegion<out RegionId : URegionId<Key, Sort, RegionId>, value.asExpr(sort.uctx.addressSort), initialGuard = guard, blockOnConcrete = { (ref, guard) -> newUpdates = newUpdates.write(key, ref.asExpr(sort), guard) }, - blockOnSymbolic = { (ref, guard) -> newUpdates = newUpdates.write(key, ref.asExpr(sort), guard) } + blockOnSymbolic = { (ref, guard) -> newUpdates = newUpdates.write(key, ref.asExpr(sort), guard) }, + ignoreNullRefs = false ) newUpdates diff --git a/usvm-core/src/main/kotlin/org/usvm/model/EagerModels.kt b/usvm-core/src/main/kotlin/org/usvm/model/EagerModels.kt index bea794311a..6a170d5a80 100644 --- a/usvm-core/src/main/kotlin/org/usvm/model/EagerModels.kt +++ b/usvm-core/src/main/kotlin/org/usvm/model/EagerModels.kt @@ -2,6 +2,7 @@ package org.usvm.model import io.ksmt.utils.asExpr import io.ksmt.utils.sampleValue +import org.usvm.INITIAL_INPUT_ADDRESS import org.usvm.UBoolExpr import org.usvm.UComposer import org.usvm.UConcreteHeapRef @@ -13,7 +14,6 @@ import org.usvm.UMockSymbol import org.usvm.USizeExpr import org.usvm.USizeSort import org.usvm.USort -import org.usvm.memory.UAddressCounter import org.usvm.memory.UReadOnlyMemoryRegion import org.usvm.memory.URegistersStackEvaluator import org.usvm.memory.USymbolicArrayIndex @@ -77,7 +77,7 @@ class UHeapEagerModel<Field, ArrayType>( // All the expressions in the model are interpreted, therefore, they must // have concrete addresses. Moreover, the model knows only about input values // which have addresses less or equal than INITIAL_INPUT_ADDRESS - require(ref is UConcreteHeapRef && ref.address <= UAddressCounter.INITIAL_INPUT_ADDRESS) + require(ref is UConcreteHeapRef && ref.address <= INITIAL_INPUT_ADDRESS) @Suppress("UNCHECKED_CAST") val region = resolvedInputFields.getOrElse(field) { @@ -97,7 +97,7 @@ class UHeapEagerModel<Field, ArrayType>( // All the expressions in the model are interpreted, therefore, they must // have concrete addresses. Moreover, the model knows only about input values // which have addresses less or equal than INITIAL_INPUT_ADDRESS - require(ref is UConcreteHeapRef && ref.address <= UAddressCounter.INITIAL_INPUT_ADDRESS) + require(ref is UConcreteHeapRef && ref.address <= INITIAL_INPUT_ADDRESS) val key = ref to index @@ -114,7 +114,7 @@ class UHeapEagerModel<Field, ArrayType>( // All the expressions in the model are interpreted, therefore, they must // have concrete addresses. Moreover, the model knows only about input values // which have addresses less or equal than INITIAL_INPUT_ADDRESS - require(ref is UConcreteHeapRef && ref.address <= UAddressCounter.INITIAL_INPUT_ADDRESS) + require(ref is UConcreteHeapRef && ref.address <= INITIAL_INPUT_ADDRESS) val region = resolvedInputLengths.getOrElse<ArrayType, UReadOnlyMemoryRegion<UHeapRef, USizeSort>>(arrayType) { // sampleValue here is important diff --git a/usvm-core/src/main/kotlin/org/usvm/model/LazyModelDecoder.kt b/usvm-core/src/main/kotlin/org/usvm/model/LazyModelDecoder.kt index 33491ba616..8af8d64149 100644 --- a/usvm-core/src/main/kotlin/org/usvm/model/LazyModelDecoder.kt +++ b/usvm-core/src/main/kotlin/org/usvm/model/LazyModelDecoder.kt @@ -3,13 +3,12 @@ package org.usvm.model import io.ksmt.expr.KExpr import io.ksmt.solver.KModel import io.ksmt.sort.KUninterpretedSort +import org.usvm.INITIAL_INPUT_ADDRESS +import org.usvm.NULL_ADDRESS import org.usvm.UAddressSort import org.usvm.UConcreteHeapRef import org.usvm.UContext import org.usvm.UExpr -import org.usvm.constraints.UTypeModel -import org.usvm.memory.UAddressCounter.Companion.INITIAL_INPUT_ADDRESS -import org.usvm.memory.UAddressCounter.Companion.NULL_ADDRESS import org.usvm.memory.UMemoryBase import org.usvm.solver.UExprTranslator @@ -52,20 +51,18 @@ open class ULazyModelDecoder<Field, Type, Method>( * equivalence classes of addresses and work with their number in the future. */ private fun buildMapping(model: KModel): AddressesMapping { - // Translated null has to be equal to evaluated null, because it is of KUninterpretedSort and translatedNullRef - // defined as mkUninterpretedSortValue(addressSort, 0). - check(translatedNullRef === model.eval(translatedNullRef, isComplete = true)) + val interpreterdNullRef = model.eval(translatedNullRef, isComplete = true) val result = mutableMapOf<KExpr<KUninterpretedSort>, UConcreteHeapRef>() - // Except the null value, it has the NULL_ADDRESS - result[translatedNullRef] = ctx.mkConcreteHeapRef(NULL_ADDRESS) + // The null value has the NULL_ADDRESS + result[interpreterdNullRef] = ctx.mkConcreteHeapRef(NULL_ADDRESS) val universe = model.uninterpretedSortUniverse(ctx.addressSort) ?: return result // All the numbers are enumerated from the INITIAL_INPUT_ADDRESS to the Int.MIN_VALUE var counter = INITIAL_INPUT_ADDRESS for (interpretedAddress in universe) { - if (interpretedAddress == translatedNullRef) { + if (interpretedAddress == interpreterdNullRef) { continue } result[interpretedAddress] = ctx.mkConcreteHeapRef(counter--) @@ -86,7 +83,7 @@ open class ULazyModelDecoder<Field, Type, Method>( val stack = decodeStack(model, addressesMapping) val heap = decodeHeap(model, addressesMapping) - val types = UTypeModel<Type>(ctx.typeSystem(), typeByAddr = emptyMap()) + val types = UTypeModel<Type>(ctx.typeSystem(), typeStreamByAddr = emptyMap()) val mocks = decodeMocker(model, addressesMapping) return UModelBase(ctx, stack, heap, types, mocks) diff --git a/usvm-core/src/main/kotlin/org/usvm/model/LazyModels.kt b/usvm-core/src/main/kotlin/org/usvm/model/LazyModels.kt index 41af729165..6cc7ce92d1 100644 --- a/usvm-core/src/main/kotlin/org/usvm/model/LazyModels.kt +++ b/usvm-core/src/main/kotlin/org/usvm/model/LazyModels.kt @@ -3,6 +3,8 @@ package org.usvm.model import io.ksmt.solver.KModel import io.ksmt.utils.asExpr import io.ksmt.utils.cast +import org.usvm.INITIAL_INPUT_ADDRESS +import org.usvm.NULL_ADDRESS import org.usvm.UBoolExpr import org.usvm.UComposer import org.usvm.UConcreteHeapRef @@ -15,7 +17,6 @@ import org.usvm.UMockSymbol import org.usvm.USizeExpr import org.usvm.USizeSort import org.usvm.USort -import org.usvm.memory.UAddressCounter import org.usvm.memory.UInputArrayId import org.usvm.memory.UInputArrayLengthId import org.usvm.memory.UInputFieldId @@ -96,15 +97,27 @@ class ULazyHeapModel<Field, ArrayType>( private val resolvedInputArrays = mutableMapOf<ArrayType, UReadOnlyMemoryRegion<USymbolicArrayIndex, out USort>>() private val resolvedInputLengths = mutableMapOf<ArrayType, UReadOnlyMemoryRegion<UHeapRef, USizeSort>>() - private val nullRef = translator - .translate(translator.ctx.nullRef) + /** + * To resolve nullRef, we need to: + * * translate it + * * evaluate the translated value in the [model] + * * map the evaluated value with the [addressesMapping] + * + * Actually, its address should always be equal 0. + */ + private val nullRef = model + .eval(translator.translate(translator.ctx.nullRef)) .mapAddress(addressesMapping) as UConcreteHeapRef + init { + check(nullRef.address == NULL_ADDRESS) + } + override fun <Sort : USort> readField(ref: UHeapRef, field: Field, sort: Sort): UExpr<Sort> { // All the expressions in the model are interpreted, therefore, they must // have concrete addresses. Moreover, the model knows only about input values // which have addresses less or equal than INITIAL_INPUT_ADDRESS - require(ref is UConcreteHeapRef && ref.address <= UAddressCounter.INITIAL_INPUT_ADDRESS) + require(ref is UConcreteHeapRef && ref.address <= INITIAL_INPUT_ADDRESS) val resolvedRegion = resolvedInputFields[field] val regionId = UInputFieldId(field, sort, contextHeap = null) @@ -129,7 +142,7 @@ class ULazyHeapModel<Field, ArrayType>( // All the expressions in the model are interpreted, therefore, they must // have concrete addresses. Moreover, the model knows only about input values // which have addresses less or equal than INITIAL_INPUT_ADDRESS - require(ref is UConcreteHeapRef && ref.address <= UAddressCounter.INITIAL_INPUT_ADDRESS) + require(ref is UConcreteHeapRef && ref.address <= INITIAL_INPUT_ADDRESS) val key = ref to index @@ -151,7 +164,7 @@ class ULazyHeapModel<Field, ArrayType>( // All the expressions in the model are interpreted, therefore, they must // have concrete addresses. Moreover, the model knows only about input values // which have addresses less or equal than INITIAL_INPUT_ADDRESS - require(ref is UConcreteHeapRef && ref.address <= UAddressCounter.INITIAL_INPUT_ADDRESS) + require(ref is UConcreteHeapRef && ref.address <= INITIAL_INPUT_ADDRESS) val resolvedRegion = resolvedInputLengths[arrayType] val regionId = UInputArrayLengthId(arrayType, ref.uctx.sizeSort, contextHeap = null) diff --git a/usvm-core/src/main/kotlin/org/usvm/model/Model.kt b/usvm-core/src/main/kotlin/org/usvm/model/Model.kt index a899275b1f..8a49fbfca2 100644 --- a/usvm-core/src/main/kotlin/org/usvm/model/Model.kt +++ b/usvm-core/src/main/kotlin/org/usvm/model/Model.kt @@ -4,16 +4,18 @@ import io.ksmt.utils.asExpr import org.usvm.UArrayIndexLValue import org.usvm.UArrayLengthLValue import org.usvm.UComposer +import org.usvm.UConcreteHeapRef import org.usvm.UContext import org.usvm.UExpr import org.usvm.UFieldLValue +import org.usvm.UHeapRef import org.usvm.ULValue import org.usvm.UMockEvaluator import org.usvm.URegisterLValue import org.usvm.USort -import org.usvm.constraints.UTypeModel import org.usvm.memory.UReadOnlySymbolicHeap import org.usvm.memory.UReadOnlySymbolicMemory +import org.usvm.types.UTypeStream interface UModel { fun <Sort : USort> eval(expr: UExpr<Sort>): UExpr<Sort> @@ -33,7 +35,7 @@ open class UModelBase<Field, Type>( val heap: UReadOnlySymbolicHeap<Field, Type>, val types: UTypeModel<Type>, val mocks: UMockEvaluator, -) : UModel, UReadOnlySymbolicMemory { +) : UModel, UReadOnlySymbolicMemory<Type> { private val composer = UComposer(ctx, stack, heap, types, mocks) /** @@ -56,4 +58,9 @@ open class UModelBase<Field, Type>( else -> throw IllegalArgumentException("Unexpected lvalue $this") } } + + override fun typeStreamOf(ref: UHeapRef): UTypeStream<Type> { + require(ref is UConcreteHeapRef) + return types.typeStream(ref) + } } \ No newline at end of file diff --git a/usvm-core/src/main/kotlin/org/usvm/model/UTypeModel.kt b/usvm-core/src/main/kotlin/org/usvm/model/UTypeModel.kt new file mode 100644 index 0000000000..2369ff30e1 --- /dev/null +++ b/usvm-core/src/main/kotlin/org/usvm/model/UTypeModel.kt @@ -0,0 +1,44 @@ +package org.usvm.model + +import org.usvm.INITIAL_INPUT_ADDRESS +import org.usvm.NULL_ADDRESS +import org.usvm.UBoolExpr +import org.usvm.UConcreteHeapAddress +import org.usvm.UConcreteHeapRef +import org.usvm.UHeapRef +import org.usvm.constraints.UTypeEvaluator +import org.usvm.types.UTypeStream +import org.usvm.types.UTypeSystem + +class UTypeModel<Type>( + val typeSystem: UTypeSystem<Type>, + typeStreamByAddr: Map<UConcreteHeapAddress, UTypeStream<Type>>, +) : UTypeEvaluator<Type> { + private val typeStreamByAddr = typeStreamByAddr.toMutableMap() + + fun typeStream(ref: UConcreteHeapRef): UTypeStream<Type> = + typeStreamByAddr[ref.address] ?: typeSystem.topTypeStream() + + override fun evalIs(ref: UHeapRef, type: Type): UBoolExpr = + when { + ref is UConcreteHeapRef && ref.address == NULL_ADDRESS -> ref.ctx.trueExpr + + ref is UConcreteHeapRef -> { + // All the expressions in the model are interpreted, therefore, they must + // have concrete addresses. Moreover, the model knows only about input values + // which have addresses less or equal than INITIAL_INPUT_ADDRESS + require(ref.address <= INITIAL_INPUT_ADDRESS) + + val evaluatedTypeStream = typeStream(ref) + val typeStream = evaluatedTypeStream.filterBySupertype(type) + if (!typeStream.isEmpty) { + typeStreamByAddr[ref.address] = typeStream + ref.ctx.trueExpr + } else { + ref.ctx.falseExpr + } + } + + else -> error("Expecting concrete ref, but got $ref") + } +} diff --git a/usvm-core/src/main/kotlin/org/usvm/solver/ExprTranslator.kt b/usvm-core/src/main/kotlin/org/usvm/solver/ExprTranslator.kt index 23ecb7250f..7804c81d24 100644 --- a/usvm-core/src/main/kotlin/org/usvm/solver/ExprTranslator.kt +++ b/usvm-core/src/main/kotlin/org/usvm/solver/ExprTranslator.kt @@ -64,7 +64,7 @@ open class UExprTranslator<Field, Type>( } override fun transform(expr: UNullRef): KExpr<UAddressSort> { - val const = ctx.mkUninterpretedSortValue(ctx.addressSort, valueIdx = 0) + val const = expr.sort.mkConst("null") return const } diff --git a/usvm-core/src/main/kotlin/org/usvm/solver/Solver.kt b/usvm-core/src/main/kotlin/org/usvm/solver/Solver.kt index dabe1f695a..15f9ac9dd9 100644 --- a/usvm-core/src/main/kotlin/org/usvm/solver/Solver.kt +++ b/usvm-core/src/main/kotlin/org/usvm/solver/Solver.kt @@ -7,6 +7,7 @@ import org.usvm.UContext import org.usvm.UHeapRef import org.usvm.constraints.UEqualityConstraints import org.usvm.constraints.UPathConstraints +import org.usvm.constraints.UTypeUnsatResult import org.usvm.isFalse import org.usvm.memory.UMemoryBase import org.usvm.model.UModelBase @@ -106,50 +107,85 @@ open class USolverBase<Field, Type, Method>( return UUnsatResult() } - smtSolver.push() + smtSolver.withAssertionsScope { + translateToSmt(pc) - translateToSmt(pc) + val softConstraints = mutableListOf<UBoolExpr>() + if (useSoftConstraints) { + pc.logicalConstraints.flatMapTo(softConstraints) { + softConstraintsProvider + .provide(it) + .map { sc -> translator.translate(sc) } + .filterNot { sc -> sc.isFalse } + } + } - var status: KSolverStatus + // DPLL(T)-like solve procedure + var iter = 0 + @Suppress("KotlinConstantConditions") + do { + iter++ + + // first, get a model from the SMT solver + val kModel = when (internalCheckWithSoftConstraints(softConstraints)) { + KSolverStatus.SAT -> smtSolver.model().detach() + KSolverStatus.UNSAT -> return UUnsatResult() + KSolverStatus.UNKNOWN -> return UUnknownResult() + } - if (useSoftConstraints) { - var softConstraints = pc.logicalConstraints.flatMap { - softConstraintsProvider - .provide(it) - .map { sc -> translator.translate(sc) } - .filterNot { sc -> sc.isFalse } - } + // second, decode it unto uModel + val uModel = decoder.decode(kModel) + + // third, check it satisfies typeConstraints + when (val typeResult = pc.typeConstraints.verify(uModel)) { + is USatResult -> return USatResult( + UModelBase( + ctx, + uModel.stack, + uModel.heap, + typeResult.model, + uModel.mocks + ) + ) + + // in case of failure, assert reference disequality expressions + is UTypeUnsatResult<Type> -> typeResult.referenceDisequalitiesDisjuncts + .map(translator::translate) + .forEach(smtSolver::assert) + + is UUnknownResult -> return UUnknownResult() + is UUnsatResult -> return UUnsatResult() + } + } while (iter < ITERATIONS_THRESHOLD || ITERATIONS_THRESHOLD == INFINITE_ITERATIONS) + return UUnsatResult() + } + } + + private fun internalCheckWithSoftConstraints( + softConstraints: MutableList<UBoolExpr>, + ): KSolverStatus { + var status: KSolverStatus + if (softConstraints.isNotEmpty()) { status = smtSolver.checkWithAssumptions(softConstraints) while (status == KSolverStatus.UNSAT) { - val unsatCore = smtSolver.unsatCore() - + val unsatCore = smtSolver.unsatCore().toHashSet() if (unsatCore.isEmpty()) break - - softConstraints = softConstraints.filterNot { it in unsatCore } + softConstraints.removeAll { it in unsatCore } status = smtSolver.checkWithAssumptions(softConstraints) } } else { status = smtSolver.check() } + return status + } - if (status != KSolverStatus.SAT) { - smtSolver.pop() - - return if (status == KSolverStatus.UNSAT) { - UUnsatResult() - } else { - UUnknownResult() - } - } - - val kModel = smtSolver.model().detach() - val uModel = decoder.decode(kModel) - - smtSolver.pop() - - return USatResult(uModel) + private inline fun <T> KSolver<*>.withAssertionsScope(block: KSolver<*>.() -> T): T = try { + push() + block() + } finally { + pop() } fun emptyModel(): UModelBase<Field, Type> = @@ -158,4 +194,13 @@ open class USolverBase<Field, Type, Method>( override fun close() { smtSolver.close() } + + companion object { + // TODO: options + /** + * -1 means no threshold + */ + val ITERATIONS_THRESHOLD = -1 + val INFINITE_ITERATIONS = -1 + } } diff --git a/usvm-core/src/main/kotlin/org/usvm/types/SupportTypeStream.kt b/usvm-core/src/main/kotlin/org/usvm/types/SupportTypeStream.kt new file mode 100644 index 0000000000..a69d116024 --- /dev/null +++ b/usvm-core/src/main/kotlin/org/usvm/types/SupportTypeStream.kt @@ -0,0 +1,116 @@ +package org.usvm.types + +import org.usvm.util.CachingSequence +import org.usvm.util.DfsIterator + +/** + * A persistent type stream based on the [supportType]. Takes inheritors of the [supportType] and + * provides those that satisfy the [filtering] function. + * + * Maintains invariant that [cachingSequence] already filtered with the [filtering] function. + */ +class USupportTypeStream<Type> private constructor( + private val typeSystem: UTypeSystem<Type>, + private val cachingSequence: CachingSequence<Type>, + private val supportType: Type, + private val filtering: (Type) -> Boolean, +) : UTypeStream<Type> { + override fun filterBySupertype(type: Type): UTypeStream<Type> { + return when { + typeSystem.isSupertype(supportType, type) -> { // we update the [supportType] + USupportTypeStream( + typeSystem, + rootSequence(typeSystem, type).filter(filtering), + type, + filtering + ) + } + + else -> { // just add one more filter + USupportTypeStream( + typeSystem, + cachingSequence.filter { typeSystem.isSupertype(type, it) }, + supportType, + filtering = { filtering(it) && typeSystem.isSupertype(type, it) } + ) + } + } + } + + override fun filterBySubtype(type: Type): UTypeStream<Type> { + return when { + typeSystem.isSupertype(type, supportType) -> { + if (type == supportType && filtering(type) && typeSystem.isInstantiable(type)) { // exact type + USingleTypeStream(typeSystem, type) + } else { + emptyTypeStream() + } + } + + else -> { + USupportTypeStream( + typeSystem, + cachingSequence.filter { typeSystem.isSupertype(it, type) }, + supportType, + filtering = { filtering(it) && typeSystem.isSupertype(it, type) } + ) + } + } + } + + override fun filterByNotSupertype(type: Type): UTypeStream<Type> { + return when { + typeSystem.isSupertype(type, supportType) -> { + emptyTypeStream() + } + + else -> { + USupportTypeStream( + typeSystem, + cachingSequence.filter { !typeSystem.isSupertype(type, it) }, + supportType, + filtering = { filtering(it) && !typeSystem.isSupertype(type, it) }, + ) + } + } + } + + override fun filterByNotSubtype(type: Type): UTypeStream<Type> { + return when { + typeSystem.isSupertype(type, supportType) && type != supportType -> { + this + } + + else -> { + USupportTypeStream( + typeSystem, + cachingSequence.filter { !typeSystem.isSupertype(it, type) }, + supportType, + filtering = { filtering(it) && !typeSystem.isSupertype(it, type) } + ) + } + } + } + + override fun take(n: Int): List<Type> = + cachingSequence.take(n).toList() + + override val isEmpty: Boolean + get() = take(1).isEmpty() + + companion object { + fun <Type> from(typeSystem: UTypeSystem<Type>, type: Type): USupportTypeStream<Type> { + val root = rootSequence(typeSystem, type).filter(typeSystem::isInstantiable) + return USupportTypeStream(typeSystem, root, type, typeSystem::isInstantiable) + } + + private fun <Type> rootSequence( + typeSystem: UTypeSystem<Type>, + type: Type, + ): CachingSequence<Type> { + // TODO: we might use another strategy of iterating here + val dfsIterator = DfsIterator(type) { typeNode -> typeSystem.findSubtypes(typeNode).iterator() } + return CachingSequence(dfsIterator) + } + } +} \ No newline at end of file diff --git a/usvm-core/src/main/kotlin/org/usvm/constraints/TypeRegion.kt b/usvm-core/src/main/kotlin/org/usvm/types/TypeRegion.kt similarity index 80% rename from usvm-core/src/main/kotlin/org/usvm/constraints/TypeRegion.kt rename to usvm-core/src/main/kotlin/org/usvm/types/TypeRegion.kt index 9ef602a380..6f91dac877 100644 --- a/usvm-core/src/main/kotlin/org/usvm/constraints/TypeRegion.kt +++ b/usvm-core/src/main/kotlin/org/usvm/types/TypeRegion.kt @@ -1,8 +1,7 @@ -package org.usvm.constraints +package org.usvm.types import kotlinx.collections.immutable.PersistentSet import kotlinx.collections.immutable.persistentSetOf -import org.usvm.UTypeSystem import org.usvm.util.Region import org.usvm.util.RegionComparisonResult @@ -11,18 +10,19 @@ import org.usvm.util.RegionComparisonResult */ open class UTypeRegion<Type>( val typeSystem: UTypeSystem<Type>, + val typeStream: UTypeStream<Type>, val supertypes: PersistentSet<Type> = persistentSetOf(), val notSupertypes: PersistentSet<Type> = persistentSetOf(), val subtypes: PersistentSet<Type> = persistentSetOf(), val notSubtypes: PersistentSet<Type> = persistentSetOf(), - val isContradicting: Boolean = false, ) : Region<UTypeRegion<Type>> { + val isContradicting get() = typeStream.isEmpty /** * Returns region that represents empty set of types. Called when type * constraints contradict, for example if X <: Y and X </: Y. */ - protected fun contradiction() = UTypeRegion(typeSystem, isContradicting = true) + protected fun contradiction() = UTypeRegion(typeSystem, emptyTypeStream()) // TODO: generate unsat core for DPLL(T) /** @@ -69,8 +69,9 @@ open class UTypeRegion<Type>( } val newSupertypes = supertypes.removeAll { typeSystem.isSupertype(it, supertype) }.add(supertype) + val newTypeStream = typeStream.filterBySupertype(supertype) - return UTypeRegion(typeSystem, supertypes = newSupertypes, subtypes = newSubtypes) + return UTypeRegion(typeSystem, newTypeStream, supertypes = newSupertypes, subtypes = newSubtypes) } /** @@ -82,7 +83,7 @@ open class UTypeRegion<Type>( * (here X is type from this region and t is [notSupertype]): * X <: u && u <: t && X </: t, i.e. if [supertypes] contains subtype of [notSupertype] */ - protected open fun excludeSupertype(notSupertype: Type): UTypeRegion<Type> { + open fun excludeSupertype(notSupertype: Type): UTypeRegion<Type> { if (isContradicting || notSupertypes.any { typeSystem.isSupertype(it, notSupertype) }) { return this } @@ -92,8 +93,9 @@ open class UTypeRegion<Type>( } val newNotSupertypes = notSupertypes.removeAll { typeSystem.isSupertype(notSupertype, it) }.add(notSupertype) + val newTypeStream = typeStream.filterByNotSupertype(notSupertype) - return UTypeRegion(typeSystem, notSupertypes = newNotSupertypes) + return UTypeRegion(typeSystem, newTypeStream, notSupertypes = newNotSupertypes) } /** @@ -120,8 +122,9 @@ open class UTypeRegion<Type>( } val newSubtypes = subtypes.removeAll { typeSystem.isSupertype(subtype, it) }.add(subtype) + val newTypeStream = typeStream.filterBySubtype(subtype) - return UTypeRegion(typeSystem, subtypes = newSubtypes) + return UTypeRegion(typeSystem, newTypeStream, subtypes = newSubtypes) } /** @@ -145,18 +148,27 @@ open class UTypeRegion<Type>( } val newNotSubtypes = notSubtypes.removeAll { typeSystem.isSupertype(it, notSubtype) }.add(notSubtype) + val newTypeStream = typeStream.filterByNotSubtype(notSubtype) - return UTypeRegion(typeSystem, notSubtypes = newNotSubtypes) + return UTypeRegion(typeSystem, newTypeStream, notSubtypes = newNotSubtypes) } override val isEmpty: Boolean = isContradicting override fun intersect(other: UTypeRegion<Type>): UTypeRegion<Type> { // TODO: optimize things up by not re-allocating type regions after each operation - val result1 = other.supertypes.fold(this) { acc, t -> acc.addSupertype(t) } - val result2 = other.notSupertypes.fold(result1) { acc, t -> acc.excludeSupertype(t) } - val result3 = other.subtypes.fold(result2) { acc, t -> acc.addSubtype(t) } - return other.notSubtypes.fold(result3) { acc, t -> acc.excludeSubtype(t) } + val otherSize = other.size + val thisSize = this.size + val (smallRegion, largeRegion) = if (otherSize < thisSize) { + other to this + } else { + this to other + } + + val result1 = smallRegion.supertypes.fold(largeRegion) { acc, t -> acc.addSupertype(t) } + val result2 = smallRegion.notSupertypes.fold(result1) { acc, t -> acc.excludeSupertype(t) } + val result3 = smallRegion.subtypes.fold(result2) { acc, t -> acc.addSubtype(t) } + return smallRegion.notSubtypes.fold(result3) { acc, t -> acc.excludeSubtype(t) } } override fun subtract(other: UTypeRegion<Type>): UTypeRegion<Type> { @@ -185,3 +197,6 @@ open class UTypeRegion<Type>( } } + +private val <Type> UTypeRegion<Type>.size: Int + get() = supertypes.size + subtypes.size + notSupertypes.size + notSubtypes.size diff --git a/usvm-core/src/main/kotlin/org/usvm/types/TypeStream.kt b/usvm-core/src/main/kotlin/org/usvm/types/TypeStream.kt new file mode 100644 index 0000000000..e124cbe601 --- /dev/null +++ b/usvm-core/src/main/kotlin/org/usvm/types/TypeStream.kt @@ -0,0 +1,115 @@ +package org.usvm.types + +/** + * A base interface representing persistent type constraints and a function to collect + * **instantiable** types satisfying them. + * + * Consists of a conjunction of constraints of four kinds: + * + * 1. x <: T, i.e. object referenced in x inherits T (supertype constraints for x) + * 2. T <: x, i.e. object referenced in x inherited by T (subtype constraints for x) + * 3. x </: T, i.e. object referenced in x does not inherit T (notSupertype constraints for x) + * 4. T </: x, i.e. object referenced in x is not inherited by T (notSubtype constraints for x) + * + * To collect **instantiable** types satisfying constraints use [take] function. + */ +interface UTypeStream<Type> { + /** + * Excludes from this type stream types which are not subtypes of [type]. + * + * @return the updated type stream + */ + fun filterBySupertype(type: Type): UTypeStream<Type> + + /** + * Excludes from this type stream types which are not supertypes of [type]. + * + * @return the updated type stream + */ + fun filterBySubtype(type: Type): UTypeStream<Type> + + /** + * Excludes from this type stream types which are subtypes of [type]. + * + * @return the updated type stream + */ + fun filterByNotSupertype(type: Type): UTypeStream<Type> + + /** + * Excludes from this type stream types which are supertypes of [type]. + * + * @return the updated type stream + */ + fun filterByNotSubtype(type: Type): UTypeStream<Type> + + /** + * @return the collection of **instantiable** types satisfying accumulated type constraints. + */ + fun take(n: Int): Collection<Type> + + val isEmpty: Boolean +} + +/** + * An empty type stream. + */ +object UEmptyTypeStream : UTypeStream<Nothing> { + override fun filterBySupertype(type: Nothing): UTypeStream<Nothing> = this + + override fun filterBySubtype(type: Nothing): UTypeStream<Nothing> = this + + override fun filterByNotSupertype(type: Nothing): UTypeStream<Nothing> = this + + override fun filterByNotSubtype(type: Nothing): UTypeStream<Nothing> = this + + override fun take(n: Int): Collection<Nothing> = emptyList() + + override val isEmpty: Boolean + get() = true +} + +@Suppress("UNCHECKED_CAST") +fun <Type> emptyTypeStream(): UTypeStream<Type> = UEmptyTypeStream as UTypeStream<Type> + +fun <Type> UTypeStream<Type>.takeFirst(): Type = take(1).single() + +/** + * Consists of just one type [singleType]. + */ +class USingleTypeStream<Type>( + private val typeSystem: UTypeSystem<Type>, + private val singleType: Type, +) : UTypeStream<Type> { + override fun filterBySupertype(type: Type): UTypeStream<Type> = + if (!typeSystem.isSupertype(type, singleType)) { + emptyTypeStream() + } else { + this + } + + override fun filterBySubtype(type: Type): UTypeStream<Type> = + if (!typeSystem.isSupertype(singleType, type)) { + emptyTypeStream() + } else { + this + } + + override fun filterByNotSupertype(type: Type): UTypeStream<Type> = + if (typeSystem.isSupertype(type, singleType)) { + emptyTypeStream() + } else { + this + } + + override fun filterByNotSubtype(type: Type): UTypeStream<Type> = + if (typeSystem.isSupertype(singleType, type)) { + emptyTypeStream() + } else { + this + } + + override fun take(n: Int) = listOf(singleType) + + override val isEmpty: Boolean + get() = false +} diff --git a/usvm-core/src/main/kotlin/org/usvm/types/TypeSystem.kt b/usvm-core/src/main/kotlin/org/usvm/types/TypeSystem.kt new file mode 100644 index 0000000000..23ec94b830 --- /dev/null +++ b/usvm-core/src/main/kotlin/org/usvm/types/TypeSystem.kt @@ -0,0 +1,39 @@ +package org.usvm.types + +/** + * A base interface, instantiated in target machines. Provides type information and [topTypeStream], + * representing all possible types in the system. + */ +interface UTypeSystem<Type> { + + /** + * @return true if t <: u. + */ + fun isSupertype(u: Type, t: Type): Boolean + + /** + * @return true if [t] can be supertype for some type together with some incomparable type u. + */ + fun isMultipleInheritanceAllowedFor(t: Type): Boolean + + /** + * @return true if there is no type u distinct from [t] and subtyping [t]. + */ + fun isFinal(t: Type): Boolean + + /** + * @return true if [t] is instantiable, meaning it can be created via constructor. + */ + fun isInstantiable(t: Type): Boolean + + /** + * @return a sequence of **direct** inheritors of the [t]. + */ + fun findSubtypes(t: Type): Sequence<Type> + + + /** + * @return the top type stream, including all the types in the system. + */ + fun topTypeStream(): UTypeStream<Type> +} diff --git a/usvm-core/src/test/kotlin/org/usvm/CompositionTest.kt b/usvm-core/src/test/kotlin/org/usvm/CompositionTest.kt index 25fe727f28..5bacaf4bf3 100644 --- a/usvm-core/src/test/kotlin/org/usvm/CompositionTest.kt +++ b/usvm-core/src/test/kotlin/org/usvm/CompositionTest.kt @@ -13,7 +13,6 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.usvm.constraints.UTypeEvaluator -import org.usvm.memory.UAddressCounter.Companion.NULL_ADDRESS import org.usvm.memory.UAllocatedArrayId import org.usvm.memory.UAllocatedArrayRegion import org.usvm.memory.UFlatUpdates diff --git a/usvm-core/src/test/kotlin/org/usvm/constraints/EqualityConstraintsTests.kt b/usvm-core/src/test/kotlin/org/usvm/constraints/EqualityConstraintsTests.kt index dcc576b3a2..17ab394501 100644 --- a/usvm-core/src/test/kotlin/org/usvm/constraints/EqualityConstraintsTests.kt +++ b/usvm-core/src/test/kotlin/org/usvm/constraints/EqualityConstraintsTests.kt @@ -33,28 +33,28 @@ class EqualityConstraintsTests { val ref6: UHeapRef = ctx.mkRegisterReading(6, ctx.addressSort) val ref7: UHeapRef = ctx.mkRegisterReading(7, ctx.addressSort) - constraints.addReferenceDisequality(ref1, ctx.nullRef) - constraints.addReferenceDisequality(ref2, ctx.nullRef) - constraints.addReferenceDisequality(ref3, ctx.nullRef) + constraints.makeNonEqual(ref1, ctx.nullRef) + constraints.makeNonEqual(ref2, ctx.nullRef) + constraints.makeNonEqual(ref3, ctx.nullRef) // First, init 2 distinct non-null addresses - constraints.addReferenceDisequality(ref1, ref2) + constraints.makeNonEqual(ref1, ref2) // Add ref2 != ref3 - constraints.addReferenceDisequality(ref2, ref3) + constraints.makeNonEqual(ref2, ref3) // ref1 still can be equal to ref3 assertSame(3, constraints.distinctReferences.size) assertTrue(constraints.referenceDisequalities[ref2]!!.contains(ref3)) assertTrue(constraints.referenceDisequalities[ref3]!!.contains(ref2)) - constraints.addReferenceDisequality(ref1, ref3) + constraints.makeNonEqual(ref1, ref3) // Now ref1, ref2 and ref3 are guaranteed to be distinct assertSame(4, constraints.distinctReferences.size) assertTrue(constraints.referenceDisequalities.all { it.value.isEmpty() }) // Adding some entry into referenceDisequalities - constraints.addReferenceDisequality(ref1, ref6) + constraints.makeNonEqual(ref1, ref6) - constraints.addReferenceEquality(ref4, ref5) - constraints.addReferenceEquality(ref5, ref1) + constraints.makeEqual(ref4, ref5) + constraints.makeEqual(ref5, ref1) // Engine should be able to infer that ref5 = ref1 != ref3 assertTrue(constraints.areDistinct(ref5, ref3)) // Checking that ref5 = ref4 = ref1 != ref6 @@ -70,12 +70,12 @@ class EqualityConstraintsTests { assertTrue(!ref6Diseq.contains(ref1)) } - assertTrue(!constraints.isContradiction) - constraints.addReferenceEquality(ref7, ref3) - assertTrue(!constraints.isContradiction) - constraints.addReferenceEquality(ref7, ref4) + assertTrue(!constraints.isContradicting) + constraints.makeEqual(ref7, ref3) + assertTrue(!constraints.isContradicting) + constraints.makeEqual(ref7, ref4) // Check that we've detected the conflict ref4 = ref5 = ref1 != ref3 = ref7 = ref4 - assertTrue(constraints.isContradiction) + assertTrue(constraints.isContradicting) } @Test @@ -94,21 +94,21 @@ class EqualityConstraintsTests { // Adding constraint ref1 == ref2. // Testing that equality constraints infer that both (ref1 == null) and (ref2 == null). // Furthermore, inferring that ref1 == null should simplify constraint (2) to true - constraints.addReferenceEquality(ref1, ref2) + constraints.makeEqual(ref1, ref2) assertFalse(constraints.nullableDisequalities.containsKey(ref1)) assertTrue(constraints.areEqual(ref1, ctx.nullRef)) assertTrue(constraints.areEqual(ref2, ctx.nullRef)) assertFalse(constraints.areDistinct(ref1, ref3)) assertFalse(constraints.nullableDisequalities[ref3]?.contains(ref1) ?: false) - constraints.addReferenceDisequality(ref4, ctx.nullRef) + constraints.makeNonEqual(ref4, ctx.nullRef) constraints.makeNonEqualOrBothNull(ref3, ref4) // Now, we've added 2 more constraints: // (3) ref4 != null // (4) ref3 != ref4 || (ref3 == ref4 == null) // These two should be automatically simplified to ref3 != ref4. assertSame(2, constraints.distinctReferences.size) - constraints.addReferenceDisequality(ref3, ctx.nullRef) + constraints.makeNonEqual(ref3, ctx.nullRef) // Now we have obtained that null, ref3 and ref4 are 3 distinct references. This should be represented as clique // constraint... assertSame(3, constraints.distinctReferences.size) diff --git a/usvm-core/src/test/kotlin/org/usvm/memory/HeapRefSplittingTest.kt b/usvm-core/src/test/kotlin/org/usvm/memory/HeapRefSplittingTest.kt index 933f4f5d60..4d6437640a 100644 --- a/usvm-core/src/test/kotlin/org/usvm/memory/HeapRefSplittingTest.kt +++ b/usvm-core/src/test/kotlin/org/usvm/memory/HeapRefSplittingTest.kt @@ -122,7 +122,7 @@ class HeapRefSplittingTest { val res1 = heap.readArrayIndex(ref, idx1, arrayDescr.first, arrayDescr.second) - val (concreteRefs, symbolicRef) = splitUHeapRef(res1) + val (concreteRefs, symbolicRef) = splitUHeapRef(res1, ignoreNullRefs = false) assertNotNull(symbolicRef) assertEquals(3, concreteRefs.size) @@ -149,7 +149,7 @@ class HeapRefSplittingTest { val res1 = heap.readArrayIndex(ref1, idx, arrayDescr.first, arrayDescr.second) - val (concreteRefs, _) = splitUHeapRef(res1) + val (concreteRefs, _) = splitUHeapRef(res1, ignoreNullRefs = false) assertEquals(2, concreteRefs.size) assertSame(val2, concreteRefs[0].expr) diff --git a/usvm-core/src/test/kotlin/org/usvm/model/ModelCompositionTest.kt b/usvm-core/src/test/kotlin/org/usvm/model/ModelCompositionTest.kt index abfae4b7cd..75da4afd05 100644 --- a/usvm-core/src/test/kotlin/org/usvm/model/ModelCompositionTest.kt +++ b/usvm-core/src/test/kotlin/org/usvm/model/ModelCompositionTest.kt @@ -6,13 +6,20 @@ import kotlinx.collections.immutable.persistentMapOf import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.usvm.* -import org.usvm.memory.UAddressCounter +import org.usvm.Field +import org.usvm.NULL_ADDRESS +import org.usvm.Type +import org.usvm.UBv32Sort +import org.usvm.UComponents +import org.usvm.UComposer +import org.usvm.UConcreteHeapRef +import org.usvm.UContext import org.usvm.memory.UInputToAllocatedKeyConverter import org.usvm.memory.emptyAllocatedArrayRegion import org.usvm.memory.emptyInputArrayLengthRegion import org.usvm.memory.emptyInputArrayRegion import org.usvm.memory.emptyInputFieldRegion +import org.usvm.sampleUValue import kotlin.test.assertSame class ModelCompositionTest { @@ -24,7 +31,7 @@ class ModelCompositionTest { val components: UComponents<*, *, *> = mockk() every { components.mkTypeSystem(any()) } returns mockk() ctx = UContext(components) - concreteNull = ctx.mkConcreteHeapRef(UAddressCounter.NULL_ADDRESS) + concreteNull = ctx.mkConcreteHeapRef(NULL_ADDRESS) } @Test diff --git a/usvm-core/src/test/kotlin/org/usvm/model/ModelDecodingTest.kt b/usvm-core/src/test/kotlin/org/usvm/model/ModelDecodingTest.kt index be2563b71a..3e8ec59ae2 100644 --- a/usvm-core/src/test/kotlin/org/usvm/model/ModelDecodingTest.kt +++ b/usvm-core/src/test/kotlin/org/usvm/model/ModelDecodingTest.kt @@ -23,6 +23,8 @@ import org.usvm.solver.USatResult import org.usvm.solver.USoftConstraintsProvider import org.usvm.solver.USolverBase import org.usvm.solver.UUnsatResult +import org.usvm.types.USingleTypeStream +import org.usvm.types.single.SingleTypeSystem import kotlin.test.assertIs class ModelDecodingTest { @@ -37,7 +39,7 @@ class ModelDecodingTest { @BeforeEach fun initializeContext() { val components: UComponents<*, *, *> = mockk() - every { components.mkTypeSystem(any()) } returns mockk() + every { components.mkTypeSystem(any()) } returns SingleTypeSystem ctx = UContext(components) val softConstraintProvider = USoftConstraintsProvider<Field, Type>(ctx) diff --git a/usvm-core/src/test/kotlin/org/usvm/solver/SoftConstraintsTest.kt b/usvm-core/src/test/kotlin/org/usvm/solver/SoftConstraintsTest.kt index 0278787720..c44acee6ba 100644 --- a/usvm-core/src/test/kotlin/org/usvm/solver/SoftConstraintsTest.kt +++ b/usvm-core/src/test/kotlin/org/usvm/solver/SoftConstraintsTest.kt @@ -10,26 +10,25 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.usvm.UComponents import org.usvm.UContext -import org.usvm.UTypeSystem import org.usvm.constraints.UPathConstraints import org.usvm.memory.emptyInputArrayLengthRegion import org.usvm.model.ULazyModelDecoder import org.usvm.model.buildTranslatorAndLazyDecoder +import org.usvm.types.UTypeSystem +import org.usvm.types.single.SingleTypeSystem import kotlin.test.assertSame open class SoftConstraintsTest<Field, Type, Method> { private lateinit var ctx: UContext private lateinit var softConstraintsProvider: USoftConstraintsProvider<Field, Type> - private lateinit var typeSystem: UTypeSystem<Type> private lateinit var translator: UExprTranslator<Field, Type> private lateinit var decoder: ULazyModelDecoder<Field, Type, Method> private lateinit var solver: USolverBase<Field, Type, Method> @BeforeEach fun initialize() { - typeSystem = mockk<UTypeSystem<Type>>(relaxed = true) val components: UComponents<*, *, *> = mockk() - every { components.mkTypeSystem(any()) } returns typeSystem + every { components.mkTypeSystem(any()) } returns SingleTypeSystem ctx = UContext(components) softConstraintsProvider = USoftConstraintsProvider(ctx) diff --git a/usvm-core/src/test/kotlin/org/usvm/types/TypeSolverTest.kt b/usvm-core/src/test/kotlin/org/usvm/types/TypeSolverTest.kt new file mode 100644 index 0000000000..580d10a28f --- /dev/null +++ b/usvm-core/src/test/kotlin/org/usvm/types/TypeSolverTest.kt @@ -0,0 +1,315 @@ +package org.usvm.types + +import io.ksmt.solver.z3.KZ3Solver +import io.mockk.every +import io.mockk.mockk +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.usvm.Field +import org.usvm.INITIAL_INPUT_ADDRESS +import org.usvm.Method +import org.usvm.NULL_ADDRESS +import org.usvm.UComponents +import org.usvm.UConcreteHeapRef +import org.usvm.UContext +import org.usvm.constraints.UPathConstraints +import org.usvm.constraints.UTypeUnsatResult +import org.usvm.memory.UMemoryBase +import org.usvm.model.UModelBase +import org.usvm.model.buildTranslatorAndLazyDecoder +import org.usvm.solver.USatResult +import org.usvm.solver.USoftConstraintsProvider +import org.usvm.solver.USolverBase +import org.usvm.solver.UUnsatResult +import org.usvm.types.system.TestType +import org.usvm.types.system.base1 +import org.usvm.types.system.base2 +import org.usvm.types.system.c +import org.usvm.types.system.derived1A +import org.usvm.types.system.derived1B +import org.usvm.types.system.derivedMulti +import org.usvm.types.system.derivedMultiInterfaces +import org.usvm.types.system.interface1 +import org.usvm.types.system.interface2 +import org.usvm.types.system.interfaceAB +import org.usvm.types.system.interfaceAC +import org.usvm.types.system.interfaceBC1 +import org.usvm.types.system.interfaceBC2 +import org.usvm.types.system.testTypeSystem +import kotlin.test.assertEquals +import kotlin.test.assertIs +import kotlin.test.assertNotEquals +import kotlin.test.assertTrue + +class TypeSolverTest { + private val typeSystem = testTypeSystem + private val components = mockk<UComponents<Field, TestType, Method>>() + private val ctx = UContext(components) + private val solver: USolverBase<Field, TestType, Method> + + init { + val (translator, decoder) = buildTranslatorAndLazyDecoder<Field, TestType, Method>(ctx) + val softConstraintsProvider = USoftConstraintsProvider<Field, TestType>(ctx) + + val smtSolver = KZ3Solver(ctx) + solver = USolverBase(ctx, smtSolver, translator, decoder, softConstraintsProvider) + + every { components.mkSolver(ctx) } returns solver + every { components.mkTypeSystem(ctx) } returns typeSystem + } + + private val pc = UPathConstraints<TestType>(ctx) + private val memory = UMemoryBase<Field, TestType, Method>(ctx, pc.typeConstraints) + + @Test + fun `Test concrete ref -- open type inheritance`() { + val ref = memory.alloc(base1) + val types = memory.typeStreamOf(ref) + types.take100AndAssertEqualsToSetOf(base1) + } + + @Test + fun `Test symbolic ref -- open type inheritance`() = with(ctx) { + val ref = ctx.mkRegisterReading(0, addressSort) + pc += mkIsExpr(ref, base1) + pc += mkHeapRefEq(ref, nullRef).not() + val model = (solver.check(pc, useSoftConstraints = false) as USatResult<UModelBase<Field, TestType>>).model + val concreteRef = assertIs<UConcreteHeapRef>(model.eval(ref)) + val types = model.typeStreamOf(concreteRef) + types.take100AndAssertEqualsToSetOf(base1, derived1A, derived1B) + } + + @Test + fun `Test symbolic ref -- interface type inheritance`() = with(ctx) { + val ref = ctx.mkRegisterReading(0, addressSort) + pc += mkIsExpr(ref, interface1) + pc += mkHeapRefEq(ref, nullRef).not() + val model = (solver.check(pc, useSoftConstraints = false) as USatResult<UModelBase<Field, TestType>>).model + val concreteRef = assertIs<UConcreteHeapRef>(model.eval(ref)) + val types = model.typeStreamOf(concreteRef) + types.take100AndAssertEqualsToSetOf(derived1A, derivedMulti, derivedMultiInterfaces) + } + + @Test + fun `Test concrete ref -- empty intersection simplification`() = with(ctx) { + val ref = memory.alloc(base1) + pc += mkIsExpr(ref, base2) + assertTrue(pc.isFalse) + } + + @Test + fun `Test symbolic ref -- empty intersection simplification`() = with(ctx) { + val ref = ctx.mkRegisterReading(0, addressSort) + pc += mkIsExpr(ref, base1) + pc += mkIsExpr(ref, base2) + pc += mkHeapRefEq(ref, nullRef).not() + assertTrue(pc.isFalse) + } + + @Test + fun `Test symbolic ref cast -- empty intersection simplification`(): Unit = with(ctx) { + val ref = ctx.mkRegisterReading(0, addressSort) + pc += mkIsExpr(ref, base1) + pc += mkIsExpr(ref, base2) + + val resultWithoutNullConstraint = solver.check(pc, useSoftConstraints = false) + assertIs<USatResult<UModelBase<Field, TestType>>>(resultWithoutNullConstraint) + + pc += mkHeapRefEq(ref, nullRef).not() + + val resultWithNullConstraint = solver.check(pc, useSoftConstraints = false) + assertIs<UUnsatResult<UModelBase<Field, TestType>>>(resultWithNullConstraint) + } + + @Test + fun `Test symbolic ref -- different types`(): Unit = with(ctx) { + val ref0 = ctx.mkRegisterReading(0, addressSort) + val ref1 = ctx.mkRegisterReading(1, addressSort) + + pc += mkIsExpr(ref0, base1) + pc += mkIsExpr(ref1, base2) + pc += mkHeapRefEq(ref0, nullRef).not() + pc += mkHeapRefEq(ref1, nullRef).not() + + val resultWithoutEqConstraint = solver.check(pc, useSoftConstraints = false) + val model = assertIs<USatResult<UModelBase<Field, TestType>>>(resultWithoutEqConstraint).model + assertNotEquals(model.eval(ref0), model.eval(ref1)) + + pc += mkHeapRefEq(ref0, ref1) + + val resultWithEqConstraint = solver.check(pc, useSoftConstraints = false) + assertIs<UUnsatResult<UModelBase<Field, TestType>>>(resultWithEqConstraint) + } + + @Test + fun `Test symbolic ref -- different interface types but same base type`(): Unit = with(ctx) { + val ref0 = ctx.mkRegisterReading(0, addressSort) + val ref1 = ctx.mkRegisterReading(1, addressSort) + + pc += mkIsExpr(ref0, base1) + pc += mkIsExpr(ref0, interface1) + pc += mkIsExpr(ref1, base1) + pc += mkIsExpr(ref1, interface2) + + val resultWithoutEqConstraint = solver.check(pc, useSoftConstraints = false) + val modelWithoutEqConstraint = + assertIs<USatResult<UModelBase<Field, TestType>>>(resultWithoutEqConstraint).model + + val concreteAddress0 = assertIs<UConcreteHeapRef>(modelWithoutEqConstraint.eval(ref0)).address + val concreteAddress1 = assertIs<UConcreteHeapRef>(modelWithoutEqConstraint.eval(ref1)).address + + val bothNull = concreteAddress0 == NULL_ADDRESS && concreteAddress1 == NULL_ADDRESS + assertTrue(bothNull || concreteAddress0 != concreteAddress1) + + pc += mkHeapRefEq(ref0, ref1) + + val resultWithEqConstraint = solver.check(pc, useSoftConstraints = false) + val modelWithEqConstraint = assertIs<USatResult<UModelBase<Field, TestType>>>(resultWithEqConstraint).model + + assertEquals(mkConcreteHeapRef(NULL_ADDRESS), modelWithEqConstraint.eval(ref0)) + assertEquals(mkConcreteHeapRef(NULL_ADDRESS), modelWithEqConstraint.eval(ref1)) + + pc += mkHeapRefEq(nullRef, ref0).not() + + val resultWithEqAndNotNullConstraint = solver.check(pc, useSoftConstraints = false) + assertIs<UUnsatResult<UModelBase<Field, TestType>>>(resultWithEqAndNotNullConstraint) + } + + @Test + fun `Test symbolic ref -- expressions to assert correctness`(): Unit = with(ctx) { + val a = ctx.mkRegisterReading(0, addressSort) + val b1 = ctx.mkRegisterReading(1, addressSort) + val b2 = ctx.mkRegisterReading(2, addressSort) + val c = ctx.mkRegisterReading(3, addressSort) + + pc += mkHeapRefEq(a, nullRef).not() and + mkHeapRefEq(b1, nullRef).not() and + mkHeapRefEq(b2, nullRef).not() and + mkHeapRefEq(c, nullRef).not() + + pc += mkIsExpr(a, interfaceAB) + pc += mkIsExpr(b1, interfaceBC1) + pc += mkIsExpr(b2, interfaceBC2) + pc += mkIsExpr(c, interfaceAC) + + pc += mkHeapRefEq(b1, b2) + + with(pc.clone()) { + val result = solver.check(this, useSoftConstraints = false) + assertIs<USatResult<UModelBase<Field, TestType>>>(result) + + val concreteA = result.model.eval(a) + val concreteB1 = result.model.eval(b1) + val concreteB2 = result.model.eval(b2) + val concreteC = result.model.eval(c) + + assertEquals(concreteB1, concreteB2) + assertTrue(concreteA != concreteB1 || concreteB1 != concreteC || concreteC != concreteA) + } + + with(pc.clone()) { + val model = mockk<UModelBase<Field, TestType>> { + every { eval(a) } returns mkConcreteHeapRef(INITIAL_INPUT_ADDRESS) + every { eval(b1) } returns mkConcreteHeapRef(INITIAL_INPUT_ADDRESS) + every { eval(b2) } returns mkConcreteHeapRef(INITIAL_INPUT_ADDRESS) + every { eval(c) } returns mkConcreteHeapRef(INITIAL_INPUT_ADDRESS) + } + val result = typeConstraints.verify(model) + assertIs<UTypeUnsatResult<TestType>>(result) + } + + + with(pc.clone()) { + this += mkHeapRefEq(a, c) and mkHeapRefEq(b1, c) + val result = solver.check(this, useSoftConstraints = false) + assertIs<UUnsatResult<UModelBase<Field, TestType>>>(result) + } + } + + @Test + fun `Test symbolic ref -- expressions to assert correctness about null -- three equals`(): Unit = with(ctx) { + val a = ctx.mkRegisterReading(0, addressSort) + val b = ctx.mkRegisterReading(1, addressSort) + val c = ctx.mkRegisterReading(2, addressSort) + + pc += mkIsExpr(a, interfaceAB) + pc += mkIsExpr(b, interfaceBC1) + pc += mkIsExpr(c, interfaceAC) + + // it's overcomplicated a == c && b == c, so it's not leak to the UEqualityConstraints + pc += (mkHeapRefEq(a, c) or mkHeapRefEq(b, c)) and (!mkHeapRefEq(a, c) or !mkHeapRefEq(b, c)).not() + + val resultBeforeNotNullConstraints = solver.check(pc, useSoftConstraints = false) + val model = assertIs<USatResult<UModelBase<Field, TestType>>>(resultBeforeNotNullConstraints).model + + assertIs<USatResult<UModelBase<Field, TestType>>>(resultBeforeNotNullConstraints) + + val concreteA = assertIs<UConcreteHeapRef>(model.eval(a)).address + val concreteB = assertIs<UConcreteHeapRef>(model.eval(b)).address + val concreteC = assertIs<UConcreteHeapRef>(model.eval(c)).address + + assertTrue(concreteA == 0 && concreteB == 0 && concreteC == 0) + + pc += mkOrNoSimplify(mkHeapRefEq(a, nullRef).not(), falseExpr) + + val resultWithNotNullConstraints = solver.check(pc, useSoftConstraints = false) + assertIs<UUnsatResult<UModelBase<Field, TestType>>>(resultWithNotNullConstraints) + } + + @Test + fun `Test symbolic ref -- expressions to assert correctness about null -- two equals`(): Unit = with(ctx) { + val a = ctx.mkRegisterReading(0, addressSort) + val b = ctx.mkRegisterReading(1, addressSort) + val c = ctx.mkRegisterReading(2, addressSort) + + pc += mkIsExpr(a, interfaceAB) + pc += mkIsExpr(b, interfaceBC1) + pc += mkIsExpr(c, interfaceAC) + + // it's overcomplicated a == b, so it's not leak to the UEqualityConstraints + pc += mkOrNoSimplify(mkHeapRefEq(a, b), falseExpr) + + pc += mkOrNoSimplify(mkHeapRefEq(a, nullRef).not(), falseExpr) + + val result = solver.check(pc, useSoftConstraints = false) + val model = assertIs<USatResult<UModelBase<Field, TestType>>>(result).model + + val concreteA = assertIs<UConcreteHeapRef>(model.eval(a)).address + val concreteB = assertIs<UConcreteHeapRef>(model.eval(b)).address + val concreteC = assertIs<UConcreteHeapRef>(model.eval(c)).address + + assertTrue(concreteA != 0 && concreteA == concreteB && concreteC == 0) + } + + @Test + @Disabled("Support propositional type variables") + fun `Test symbolic ref -- not instance of constraint`(): Unit = with(ctx) { + val a = ctx.mkRegisterReading(0, addressSort) + pc += mkHeapRefEq(a, nullRef) or mkIsExpr(a, interfaceAB).not() + val result = solver.check(pc, useSoftConstraints = false) + assertIs<USatResult<UModelBase<Field, TestType>>>(result) + } + + @Test + @Disabled("Support propositional type variables") + fun `Test symbolic ref -- isExpr or bool variable`(): Unit = with(ctx) { + val a = ctx.mkRegisterReading(0, addressSort) + val unboundedBoolean = ctx.mkRegisterReading(1, boolSort) + pc += mkIsExpr(a, interfaceAB) xor unboundedBoolean + val result1 = solver.check(pc, useSoftConstraints = false) + assertIs<USatResult<UModelBase<Field, TestType>>>(result1) + pc += unboundedBoolean + val result2 = solver.check(pc, useSoftConstraints = false) + val model = assertIs<USatResult<UModelBase<Field, TestType>>>(result2).model + val concreteA = model.eval(a) as UConcreteHeapRef + val types = model.typeStreamOf(concreteA) + types.take100AndAssertEqualsToSetOf(c) + } + + private fun <T> UTypeStream<T>.take100AndAssertEqualsToSetOf(vararg elements: T) { + val set = elements.toSet() + val result = take(100) + assertEquals(set.size, result.size) + assertEquals(set, result.toSet()) + } +} \ No newline at end of file diff --git a/usvm-core/src/test/kotlin/org/usvm/types/TypeStreamTest.kt b/usvm-core/src/test/kotlin/org/usvm/types/TypeStreamTest.kt new file mode 100644 index 0000000000..36e1e684ac --- /dev/null +++ b/usvm-core/src/test/kotlin/org/usvm/types/TypeStreamTest.kt @@ -0,0 +1,144 @@ +package org.usvm.types + +import io.mockk.every +import io.mockk.spyk +import io.mockk.verify +import org.junit.jupiter.api.Test +import org.usvm.types.system.base1 +import org.usvm.types.system.base2 +import org.usvm.types.system.comparable +import org.usvm.types.system.derived1A +import org.usvm.types.system.derived1B +import org.usvm.types.system.derivedMulti +import org.usvm.types.system.derivedMultiInterfaces +import org.usvm.types.system.interface1 +import org.usvm.types.system.interface2 +import org.usvm.types.system.testTypeSystem +import org.usvm.types.system.top +import org.usvm.types.system.userComparable +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class TypeStreamTest { + private val typeSystem = testTypeSystem + + @Test + fun `Test topType`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(top) + val result = typeStream.take(100) + assertEquals(100, result.size) + assertTrue(result.all(typeSystem::isInstantiable)) + } + + + @Test + fun `Test comparable`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(comparable) + val result = typeStream.take(100) + assertEquals(100, result.size) + assertTrue(result.all(typeSystem::isInstantiable)) + } + + @Test + fun `Test open type inheritance`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(base1) + + typeStream.take100AndAssertEqualsToSetOf(base1, derived1A, derived1B) + } + + @Test + fun `Test interface inheritance`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(interface1) + + typeStream.take100AndAssertEqualsToSetOf(derived1A, derivedMulti, derivedMultiInterfaces) + } + + + @Test + fun `Test empty intersection`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(base1) + .filterBySupertype(base2) + + typeStream.take100AndAssertEqualsToSetOf() + } + + @Test + fun `Test exact type`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(derivedMulti) + .filterBySubtype(derivedMulti) + + typeStream.take100AndAssertEqualsToSetOf(derivedMulti) + } + + @Test + fun `Test supertype & !supertype`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(interface1) + .filterByNotSupertype(interface2) + + typeStream.take100AndAssertEqualsToSetOf(derived1A) + } + + @Test + fun `Test comparable & user's interface inheritor`() { // works 100ms + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(comparable) + .filterBySupertype(interface2) + + typeStream.take100AndAssertEqualsToSetOf(userComparable) + } + + @Test + fun `Test user's interface & comparable inheritor`() { // works less than 10ms + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(interface2) + .filterBySupertype(comparable) + + typeStream.take100AndAssertEqualsToSetOf(userComparable) + } + + @Test + fun `Test subtype1 & subtype2 & subtype3`() { + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(base2) + .filterBySupertype(interface1) + .filterBySupertype(interface2) + + typeStream.take100AndAssertEqualsToSetOf(derivedMulti, derivedMultiInterfaces) + } + + @Test + fun `Test caching results`() { + val typeSystem = spyk(typeSystem) + + val topType = typeSystem.topType + + every { typeSystem.topTypeStream() } returns USupportTypeStream.from(typeSystem, topType) + + val typeStream = typeSystem.topTypeStream() + .filterBySupertype(base1) + + typeStream.take100AndAssertEqualsToSetOf(base1, derived1A, derived1B) + + verify(exactly = 1) { typeSystem.findSubtypes(topType) } + verify(exactly = 1) { typeSystem.findSubtypes(base1) } + + typeStream.take100AndAssertEqualsToSetOf(base1, derived1A, derived1B) + + verify(exactly = 1) { typeSystem.findSubtypes(topType) } + verify(exactly = 1) { typeSystem.findSubtypes(base1) } + } + + private fun <T> UTypeStream<T>.take100AndAssertEqualsToSetOf(vararg elements: T) { + val set = elements.toSet() + val result = take(100) + assertEquals(set.size, result.size) + assertEquals(set, result.toSet()) + } +} diff --git a/usvm-core/src/test/kotlin/org/usvm/types/single/SingleTypeSystem.kt b/usvm-core/src/test/kotlin/org/usvm/types/single/SingleTypeSystem.kt new file mode 100644 index 0000000000..ef981515cf --- /dev/null +++ b/usvm-core/src/test/kotlin/org/usvm/types/single/SingleTypeSystem.kt @@ -0,0 +1,21 @@ +package org.usvm.types.single + +import org.usvm.types.USingleTypeStream +import org.usvm.types.UTypeStream +import org.usvm.types.UTypeSystem + +object SingleTypeSystem : UTypeSystem<SingleTypeSystem.SingleType> { + object SingleType + + override fun isSupertype(u: SingleType, t: SingleType): Boolean = true + + override fun isMultipleInheritanceAllowedFor(t: SingleType): Boolean = false + + override fun isFinal(t: SingleType): Boolean = true + + override fun isInstantiable(t: SingleType): Boolean = true + + override fun findSubtypes(t: SingleType): Sequence<SingleType> = emptySequence() + + override fun topTypeStream(): UTypeStream<SingleType> = USingleTypeStream(this, SingleType) +} diff --git a/usvm-core/src/test/kotlin/org/usvm/types/system/Builders.kt b/usvm-core/src/test/kotlin/org/usvm/types/system/Builders.kt new file mode 100644 index 0000000000..fe0c5da078 --- /dev/null +++ b/usvm-core/src/test/kotlin/org/usvm/types/system/Builders.kt @@ -0,0 +1,55 @@ +package org.usvm.types.system + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +class TestTypeSystemScope { + private val typeSystem = TestTypeSystem() + + fun `interface`(): TestType { + val type = TestInterfaceType(typeSystem.id) + typeSystem.registerType(type) + return type + } + + fun abstract(): TestType { + val type = TestAbstractClassType(typeSystem.id) + typeSystem.registerType(type) + return type + } + + val topType get() = typeSystem.topType + + fun open(): TestType { + val type = TestOpenClassType(typeSystem.id) + typeSystem.registerType(type) + return type + } + + fun final(): TestType { + val type = TestFinalClassType(typeSystem.id) + typeSystem.registerType(type) + return type + } + + infix fun TestType.implements(other: TestType): TestType { + typeSystem.registerInheritance(other, this) + return this + } + + fun TestType.implements(vararg others: TestType): TestType { + others.forEach { typeSystem.registerInheritance(it, this) } + return this + } + + fun build() = typeSystem +} + +@OptIn(ExperimentalContracts::class) +inline fun buildTypeSystem(builder: TestTypeSystemScope.() -> Unit): TestTypeSystem { + contract { + callsInPlace(builder, kind = InvocationKind.EXACTLY_ONCE) + } + return TestTypeSystemScope().apply(builder).build() +} \ No newline at end of file diff --git a/usvm-core/src/test/kotlin/org/usvm/types/system/Instance.kt b/usvm-core/src/test/kotlin/org/usvm/types/system/Instance.kt new file mode 100644 index 0000000000..64c38112a6 --- /dev/null +++ b/usvm-core/src/test/kotlin/org/usvm/types/system/Instance.kt @@ -0,0 +1,74 @@ +package org.usvm.types.system + +val top: TestType + +val base1: TestType +val base2: TestType + +val interface1: TestType +val interface2: TestType +val combinedInterface: TestType + +val derived1A: TestType +val derived1B: TestType +val derivedMulti: TestType + +val comparable: TestType +val userComparable: TestType +val derivedMultiInterfaces: TestType + +val interfaceAB: TestType +val interfaceBC1: TestType +val interfaceBC2: TestType +val interfaceAC: TestType + +val a: TestType +val b: TestType +val c: TestType + +val testTypeSystem = buildTypeSystem { + top = topType + + base1 = open() + base2 = open() + + interface1 = `interface`() + interface2 = `interface`() + comparable = `interface`() + + combinedInterface = `interface`().implements(interface1, interface2) + + derived1A = open().implements(base1, interface1) + derived1B = open().implements(base1, interface2) + derivedMulti = open().implements(base2, combinedInterface) + derivedMultiInterfaces = open().implements(base2, interface1, interface2) + userComparable = open().implements(interface2, comparable) + + interfaceAB = `interface`() + interfaceBC2 = `interface`() + interfaceBC1 = `interface`().implements(interfaceBC2) + interfaceAC = `interface`() + + a = open().implements(interfaceAB, interfaceAC) + b = open().implements(interfaceAB, interfaceBC1) + c = open().implements(interfaceAC, interfaceBC1) + + + // simulate inheritors of top type + repeat(10_000) { idx -> + when (idx % 2) { + 0 -> open() + 1 -> abstract() + } + } + + // simulate inheritors of comparable + repeat(10_000) { idx -> + when (idx % 3) { + 0 -> open() implements comparable + 1 -> `interface`() implements comparable + 2 -> abstract() implements comparable + } + } +} + diff --git a/usvm-core/src/test/kotlin/org/usvm/types/system/TestTypeSystem.kt b/usvm-core/src/test/kotlin/org/usvm/types/system/TestTypeSystem.kt new file mode 100644 index 0000000000..1253e55323 --- /dev/null +++ b/usvm-core/src/test/kotlin/org/usvm/types/system/TestTypeSystem.kt @@ -0,0 +1,75 @@ +package org.usvm.types.system + +import org.usvm.types.USupportTypeStream +import org.usvm.types.UTypeStream +import org.usvm.types.UTypeSystem + +class TestTypeSystem : UTypeSystem<TestType> { + var id = 0 + private set + + val topType = TestOpenClassType(id++) + + private val typeToDirectSubtypes = hashMapOf<TestType, HashSet<TestType>>() + private val typeToDirectSupertypes = hashMapOf<TestType, HashSet<TestType>>() + + fun registerType(u: TestType) { + if (!u.isMultipleInheritanceAllowed) { + registerInheritance(topType, u) + } + id++ + } + + private fun unregisterTopTypeInheritance(base: TestType) { + val topTypeSubtypes = typeToDirectSubtypes.getOrElse(topType) { return } + topTypeSubtypes.remove(base) + val baseTypeSupertypes = typeToDirectSupertypes.getOrElse(base) { return } + baseTypeSupertypes.remove(topType) + } + + fun registerInheritance(base: TestType, inheritor: TestType) { + if (!inheritor.isMultipleInheritanceAllowed) { + unregisterTopTypeInheritance(inheritor) + } + + val baseTypeSubtypes = typeToDirectSubtypes.getOrPut(base) { hashSetOf() } + baseTypeSubtypes += inheritor + require(!base.isFinal) + + val inheritorTypeSupertypes = typeToDirectSupertypes.getOrPut(inheritor) { hashSetOf() } + inheritorTypeSupertypes += base + + require(!inheritor.isMultipleInheritanceAllowed || inheritor == topType || inheritor.isMultipleInheritanceAllowed) + require(inheritorTypeSupertypes.count { !it.isMultipleInheritanceAllowed } <= 1) + } + + override fun isSupertype(u: TestType, t: TestType): Boolean { + if (u == t || u == topType) { + return true + } + return typeToDirectSupertypes + .getOrElse(t) { return false } + .any { isSupertype(u, it) } + } + + override fun isMultipleInheritanceAllowedFor(t: TestType): Boolean { + return t.isMultipleInheritanceAllowed + } + + override fun isFinal(t: TestType): Boolean { + return t.isFinal + } + + override fun isInstantiable(t: TestType): Boolean { + return t.isInstantiable + } + + override fun findSubtypes(t: TestType): Sequence<TestType> { + return typeToDirectSubtypes.getOrDefault(t, hashSetOf()).asSequence() + } + + override fun topTypeStream(): UTypeStream<TestType> { + return USupportTypeStream.from(this, topType) + } +} + diff --git a/usvm-core/src/test/kotlin/org/usvm/types/system/TestTypes.kt b/usvm-core/src/test/kotlin/org/usvm/types/system/TestTypes.kt new file mode 100644 index 0000000000..93a605440c --- /dev/null +++ b/usvm-core/src/test/kotlin/org/usvm/types/system/TestTypes.kt @@ -0,0 +1,54 @@ +package org.usvm.types.system + +sealed interface TestType { + val id: Int + val isMultipleInheritanceAllowed: Boolean + val isInstantiable: Boolean + val isFinal: Boolean +} + +class TestInterfaceType( + override val id: Int, +) : TestType { + override val isMultipleInheritanceAllowed: Boolean + get() = true + override val isInstantiable: Boolean + get() = false + override val isFinal: Boolean + get() = false +} + +class TestAbstractClassType( + override val id: Int, +) : TestType { + override val isMultipleInheritanceAllowed: Boolean + get() = false + override val isInstantiable: Boolean + get() = false + override val isFinal: Boolean + get() = false +} + +class TestOpenClassType( + override val id: Int, +) : TestType { + override val isMultipleInheritanceAllowed: Boolean + get() = false + override val isInstantiable: Boolean + get() = true + + override val isFinal: Boolean + get() = false +} + +class TestFinalClassType( + override val id: Int, +) : TestType { + override val isMultipleInheritanceAllowed: Boolean + get() = false + override val isInstantiable: Boolean + get() = true + + override val isFinal: Boolean + get() = true +} \ No newline at end of file diff --git a/usvm-jvm/build.gradle.kts b/usvm-jvm/build.gradle.kts index e22b0792eb..c2ded10dee 100644 --- a/usvm-jvm/build.gradle.kts +++ b/usvm-jvm/build.gradle.kts @@ -13,6 +13,10 @@ dependencies { testImplementation("io.mockk:mockk:${Versions.mockk}") testImplementation("org.junit.jupiter:junit-jupiter-params:${Versions.junitParams}") + + // https://mvnrepository.com/artifact/org.burningwave/core + // Use it to export all modules to all + testImplementation("org.burningwave:core:12.62.7") } sourceSets { diff --git a/usvm-jvm/src/main/kotlin/org/usvm/api/util/JcTestResolver.kt b/usvm-jvm/src/main/kotlin/org/usvm/api/util/JcTestResolver.kt index 809eb578f8..46c6b400da 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/api/util/JcTestResolver.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/api/util/JcTestResolver.kt @@ -19,6 +19,8 @@ import org.jacodb.api.ext.long import org.jacodb.api.ext.short import org.jacodb.api.ext.toType import org.jacodb.api.ext.void +import org.usvm.INITIAL_INPUT_ADDRESS +import org.usvm.NULL_ADDRESS import org.usvm.UArrayIndexLValue import org.usvm.UArrayLengthLValue import org.usvm.UConcreteHeapAddress @@ -44,9 +46,10 @@ import org.usvm.machine.extractShort import org.usvm.machine.state.JcMethodResult import org.usvm.machine.state.JcState import org.usvm.machine.state.WrappedException -import org.usvm.memory.UAddressCounter +import org.usvm.machine.state.localIdx import org.usvm.memory.UReadOnlySymbolicMemory import org.usvm.model.UModelBase +import org.usvm.types.takeFirst /** * A class, responsible for resolving a single [JcTest] for a specific method from a symbolic state. @@ -63,18 +66,19 @@ class JcTestResolver( */ fun resolve(method: JcTypedMethod, state: JcState): JcTest { val model = state.models.first() - val initialMemory = MemoryScope(state.ctx, model = null, model, method, classLoader) - val memory = state.memory - val afterMemory = MemoryScope(state.ctx, model, memory, method, classLoader) + val ctx = state.pathConstraints.ctx as JcContext + + val initialScope = MemoryScope(ctx, model, model, method, classLoader) + val afterScope = MemoryScope(ctx, model, memory, method, classLoader) - val before = with(initialMemory) { resolveState() } - val after = with(afterMemory) { resolveState() } + val before = with(initialScope) { resolveState() } + val after = with(afterScope) { resolveState() } val result = when (val res = state.methodResult) { is JcMethodResult.NoCall -> error("No result found") - is JcMethodResult.Success -> with(afterMemory) { Result.success(resolveExpr(res.value, method.returnType)) } + is JcMethodResult.Success -> with(afterScope) { Result.success(resolveExpr(res.value, method.returnType)) } is JcMethodResult.Exception -> Result.failure(resolveException(res.exception)) } val coverage = resolveCoverage(method, state) @@ -109,8 +113,8 @@ class JcTestResolver( */ private class MemoryScope( private val ctx: JcContext, - private val model: UModelBase<JcField, JcType>?, - private val memory: UReadOnlySymbolicMemory, + private val model: UModelBase<JcField, JcType>, + private val memory: UReadOnlySymbolicMemory<JcType>, private val method: JcTypedMethod, private val classLoader: ClassLoader = ClassLoader.getSystemClassLoader(), ) { @@ -126,7 +130,7 @@ class JcTestResolver( } val parameters = method.parameters.mapIndexed { idx, param -> - val registerIdx = if (method.isStatic) idx else idx + 1 + val registerIdx = method.method.localIdx(idx) val ref = URegisterLValue(ctx.typeToSort(param.type), registerIdx) resolveLValue(ref, param.type) } @@ -164,28 +168,37 @@ class JcTestResolver( } fun resolveReference(heapRef: UHeapRef, type: JcRefType): Any? { - val idx = (evaluateInModel(heapRef) as UConcreteHeapRef).address - if (idx == UAddressCounter.NULL_ADDRESS) { + val ref = evaluateInModel(heapRef) as UConcreteHeapRef + if (ref.address == NULL_ADDRESS) { return null } - return resolvedCache.getOrElse(idx) { - when (type) { - is JcArrayType -> resolveArray(idx, type, heapRef) - is JcClassType -> resolveReference(idx, type, heapRef) + return resolvedCache.getOrElse(ref.address) { + // to find a type, we need to understand the source of the object + val evaluatedType = if (ref.address <= INITIAL_INPUT_ADDRESS) { + // input object + val typeStream = model.typeStreamOf(ref).filterBySupertype(type) + typeStream.takeFirst() as JcRefType + } else { + // allocated object + memory.typeStreamOf(ref).takeFirst() + } + when (evaluatedType) { + is JcArrayType -> resolveArray(ref, heapRef, evaluatedType) + is JcClassType -> resolveObject(ref, heapRef, evaluatedType) else -> error("Unexpected type: $type") } } } - private fun resolveArray(idx: UConcreteHeapAddress, type: JcArrayType, heapRef: UHeapRef): Any { - val lengthRef = UArrayLengthLValue(heapRef, type) + private fun resolveArray(ref: UConcreteHeapRef, heapRef: UHeapRef, type: JcArrayType): Any { + val lengthRef = UArrayLengthLValue(heapRef, ctx.arrayDescriptorOf(type)) val resolvedLength = resolveLValue(lengthRef, ctx.cp.int) as Int val length = if (resolvedLength in 0..10_000) resolvedLength else 0 // TODO hack val cellSort = ctx.typeToSort(type.elementType) fun <T> resolveElement(idx: Int): T { - val elemRef = UArrayIndexLValue(cellSort, heapRef, ctx.mkBv(idx), type) + val elemRef = UArrayIndexLValue(cellSort, heapRef, ctx.mkBv(idx), ctx.arrayDescriptorOf(type)) @Suppress("UNCHECKED_CAST") return resolveLValue(elemRef, type.elementType) as T } @@ -201,38 +214,42 @@ class JcTestResolver( ctx.cp.char -> CharArray(length, ::resolveElement) else -> { // TODO: works incorrectly for inner array - val jClass = resolveType(idx, type.elementType as JcRefType) - val instance = Reflection.allocateArray(jClass, length) + val clazz = resolveType(type.elementType as JcRefType) + val instance = Reflection.allocateArray(clazz, length) for (i in 0 until length) { instance[i] = resolveElement(i) } instance } } + resolvedCache[ref.address] = instance return instance } - private fun resolveReference(idx: UConcreteHeapAddress, type: JcRefType, heapRef: UHeapRef): Any { - val jClass = resolveType(idx, type) - val instance = Reflection.allocateInstance(jClass) - resolvedCache[idx] = instance + private fun resolveObject(ref: UConcreteHeapRef, heapRef: UHeapRef, type: JcRefType): Any { + val clazz = resolveType(type) + val instance = Reflection.allocateInstance(clazz) + resolvedCache[ref.address] = instance + + val fields = generateSequence(type.jcClass) { it.superClass } + .map { it.toType() } + .flatMap { it.declaredFields } + .filter { !it.isStatic } - val fields = type.jcClass.toType().declaredFields // TODO: now it skips inherited fields for (field in fields) { - val ref = UFieldLValue(ctx.typeToSort(field.fieldType), heapRef, field.field) - val fieldValue = resolveLValue(ref, field.fieldType) + val lvalue = UFieldLValue(ctx.typeToSort(field.fieldType), heapRef, field.field) + val fieldValue = resolveLValue(lvalue, field.fieldType) - val javaField = jClass.getDeclaredField(field.name) + val fieldClazz = resolveType(field.enclosingType) + val javaField = fieldClazz.getDeclaredField(field.name) Reflection.setField(instance, javaField, fieldValue) } return instance } - @Suppress("UNUSED_PARAMETER") - private fun resolveType(idx: UConcreteHeapAddress, type: JcRefType): Class<*> { - // TODO: ask memory for exact type - type.ifArrayGetElementType?.let { - return when (it) { + private fun resolveType(type: JcRefType): Class<*> = + type.ifArrayGetElementType?.let { elementType -> + when (elementType) { ctx.cp.boolean -> BooleanArray::class.java ctx.cp.short -> ShortArray::class.java ctx.cp.int -> IntArray::class.java @@ -241,23 +258,22 @@ class JcTestResolver( ctx.cp.double -> DoubleArray::class.java ctx.cp.byte -> ByteArray::class.java ctx.cp.char -> CharArray::class.java - else -> { - val elementType = resolveType(idx, it as JcRefType) - Reflection.allocateArray(elementType, length = 0).javaClass + is JcRefType -> { + val clazz = resolveType(elementType) + Reflection.allocateArray(clazz, length = 0).javaClass } - } - } - return classLoader.loadClass(type.jcClass.name) - } + else -> error("Unexpected type: $elementType") + } + } ?: classLoader.loadClass(type.jcClass.name) /** * If we resolve state after, [expr] is read from a state memory, so it requires concretization via [model]. * - * @return a concretized expression, or [expr] if [model] is null. + * @return a concretized expression. */ private fun <T : USort> evaluateInModel(expr: UExpr<T>): UExpr<T> { - return model?.eval(expr) ?: expr + return model.eval(expr) } } diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcContext.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcContext.kt index db337f6614..a06271a9ca 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcContext.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcContext.kt @@ -1,8 +1,10 @@ package org.usvm.machine +import org.jacodb.api.JcArrayType import org.jacodb.api.JcClasspath import org.jacodb.api.JcRefType import org.jacodb.api.JcType +import org.jacodb.api.PredefinedPrimitives import org.jacodb.api.ext.boolean import org.jacodb.api.ext.byte import org.jacodb.api.ext.char @@ -10,6 +12,7 @@ import org.jacodb.api.ext.double import org.jacodb.api.ext.float import org.jacodb.api.ext.int import org.jacodb.api.ext.long +import org.jacodb.api.ext.objectType import org.jacodb.api.ext.short import org.jacodb.api.ext.void import org.usvm.UContext @@ -47,4 +50,10 @@ class JcContext( cp.double -> doubleSort else -> error("Unknown type: $type") } + fun arrayDescriptorOf(type: JcArrayType): JcType = + if (PredefinedPrimitives.matches(type.elementType.typeName)) { + type.elementType + } else { + type.classpath.objectType + } } \ No newline at end of file diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcExprResolver.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcExprResolver.kt index fa74dd8c8a..e7a3bed2d6 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcExprResolver.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcExprResolver.kt @@ -3,6 +3,7 @@ package org.usvm.machine import io.ksmt.expr.KBitVec32Value import io.ksmt.utils.asExpr import io.ksmt.utils.cast +import org.jacodb.api.JcArrayType import org.jacodb.api.JcMethod import org.jacodb.api.JcPrimitiveType import org.jacodb.api.JcRefType @@ -43,6 +44,7 @@ import org.jacodb.api.cfg.JcLocalVar import org.jacodb.api.cfg.JcLong import org.jacodb.api.cfg.JcLtExpr import org.jacodb.api.cfg.JcMethodConstant +import org.jacodb.api.cfg.JcMethodType import org.jacodb.api.cfg.JcMulExpr import org.jacodb.api.cfg.JcNegExpr import org.jacodb.api.cfg.JcNeqExpr @@ -214,7 +216,14 @@ class JcExprResolver( resolveBinaryOperator(JcBinaryOperator.Cmpl, expr) override fun visitJcNegExpr(expr: JcNegExpr): UExpr<out USort>? = - resolveAfterResolved(expr.operand) { operand -> JcUnaryOperator.Neg(operand) } + resolveAfterResolved(expr.operand) { operand -> + val wideOperand = if (operand.sort != operand.ctx.boolSort) { + operand wideWith expr.operand.type + } else { + operand + } + JcUnaryOperator.Neg(wideOperand) + } // endregion @@ -264,6 +273,10 @@ class JcExprResolver( TODO("Not yet implemented") } + override fun visitJcMethodType(value: JcMethodType): UExpr<out USort>? { + TODO("Not yet implemented") + } + override fun visitJcClassConstant(value: JcClassConstant): UExpr<out USort> = with(ctx) { TODO("Not yet implemented") } @@ -272,14 +285,20 @@ class JcExprResolver( override fun visitJcCastExpr(expr: JcCastExpr): UExpr<out USort>? = resolveCast(expr.operand, expr.type) - override fun visitJcInstanceOfExpr(expr: JcInstanceOfExpr): UExpr<out USort> = with(ctx) { - TODO("Not yet implemented") + override fun visitJcInstanceOfExpr(expr: JcInstanceOfExpr): UExpr<out USort>? = with(ctx) { + val ref = resolveJcExpr(expr.operand)?.asExpr(addressSort) ?: return null + scope.calcOnState { + val notEqualsNull = mkHeapRefEq(ref, memory.heap.nullRef()).not() + val isExpr = memory.types.evalIs(ref, expr.targetType) + mkAnd(notEqualsNull, isExpr) + } } override fun visitJcLengthExpr(expr: JcLengthExpr): UExpr<out USort>? = with(ctx) { val ref = resolveJcExpr(expr.array)?.asExpr(addressSort) ?: return null checkNullPointer(ref) ?: return null - val lengthRef = UArrayLengthLValue(ref, expr.array.type) + val arrayDescriptor = arrayDescriptorOf(expr.array.type as JcArrayType) + val lengthRef = UArrayLengthLValue(ref, arrayDescriptor) val length = scope.calcOnState { memory.read(lengthRef).asExpr(sizeSort) } ?: return null assertHardMaxArrayLength(length) ?: return null scope.assert(mkBvSignedLessOrEqualExpr(mkBv(0), length)) ?: return null @@ -287,7 +306,7 @@ class JcExprResolver( } override fun visitJcNewArrayExpr(expr: JcNewArrayExpr): UExpr<out USort>? = with(ctx) { - val size = resolveJcExpr(expr.dimensions[0])?.asExpr(sizeSort) ?: return null + val size = resolveCast(expr.dimensions[0], ctx.cp.int)?.asExpr(bv32Sort) ?: return null // TODO: other dimensions ( > 1) checkNewArrayLength(size) ?: return null val ref = scope.calcOnState { memory.malloc(expr.type, size) } ?: return null @@ -295,7 +314,9 @@ class JcExprResolver( } override fun visitJcNewExpr(expr: JcNewExpr): UExpr<out USort>? = - scope.calcOnState { memory.alloc(expr.type) } + scope.calcOnState { + memory.alloc(expr.type) + } override fun visitJcPhiExpr(expr: JcPhiExpr): UExpr<out USort> = error("Unexpected expr: $expr") @@ -419,8 +440,10 @@ class JcExprResolver( val arrayRef = resolveJcExpr(array)?.asExpr(addressSort) ?: return null checkNullPointer(arrayRef) ?: return null - val idx = resolveJcExpr(index)?.asExpr(bv32Sort) ?: return null - val lengthRef = UArrayLengthLValue(arrayRef, array.type) + val arrayDescriptor = arrayDescriptorOf(array.type as JcArrayType) + + val idx = resolveCast(index, ctx.cp.int)?.asExpr(bv32Sort) ?: return null + val lengthRef = UArrayLengthLValue(arrayRef, arrayDescriptor) val length = scope.calcOnState { memory.read(lengthRef).asExpr(sizeSort) } ?: return null assertHardMaxArrayLength(length) ?: return null @@ -430,7 +453,7 @@ class JcExprResolver( val elementType = requireNotNull(array.type.ifArrayGetElementType) val cellSort = typeToSort(elementType) - return UArrayIndexLValue(cellSort, arrayRef, idx, array.type) + return UArrayIndexLValue(cellSort, arrayRef, idx, arrayDescriptor) } private fun resolveLocal(local: JcLocal): ULValue { @@ -515,13 +538,11 @@ class JcExprResolver( expr: JcBinaryExpr, ) = resolveAfterResolved(expr.lhv, expr.rhv) { lhs, rhs -> // we don't want to have extra casts on booleans - val (wideLhs, wideRhs) = if (lhs.sort == ctx.boolSort && rhs.sort == ctx.boolSort) { - lhs to rhs + if (lhs.sort == ctx.boolSort && rhs.sort == ctx.boolSort) { + resolvePrimitiveCast(operator(lhs, rhs), ctx.cp.boolean, expr.type as JcPrimitiveType) } else { - (lhs wideWith expr.lhv.type) to (rhs wideWith expr.rhv.type) + operator(lhs wideWith expr.lhv.type, rhs wideWith expr.rhv.type) } - - operator(wideLhs, wideRhs) } private fun resolveShiftOperator( @@ -558,28 +579,49 @@ class JcExprResolver( private fun resolveCast( operand: JcExpr, type: JcType, - ) = when (type) { - is JcRefType -> resolveReferenceCast(operand, type) - is JcPrimitiveType -> resolvePrimitiveCast(operand, type) - else -> error("Unexpected type: $type") + ) = resolveAfterResolved(operand) { expr -> + when (type) { + is JcRefType -> resolveReferenceCast(expr, operand.type as JcRefType, type) + is JcPrimitiveType -> resolvePrimitiveCast(expr, operand.type as JcPrimitiveType, type) + else -> error("Unexpected type: $type") + } } - private fun resolveReferenceCast(operand: JcExpr, type: JcRefType) = resolveAfterResolved(operand) { expr -> - if (!type.isAssignable(operand.type)) { - TODO("Not yet implemented") + private fun resolveReferenceCast( + expr: UExpr<out USort>, + typeBefore: JcRefType, + type: JcRefType, + ): UExpr<out USort>? { + return if (!typeBefore.isAssignable(type)) { + val isExpr = scope.calcOnState { memory.types.evalIs(expr.asExpr(ctx.addressSort), type) } + ?: return null + scope.fork( + isExpr, + blockOnFalseState = { + val ln = lastStmt.lineNumber + val exception = ClassCastException("[class cast exception] $ln") + throwException(exception) + } + ) ?: return null + expr + } else { + expr } - expr } - private fun resolvePrimitiveCast(operand: JcExpr, type: JcPrimitiveType) = resolveAfterResolved(operand) { expr -> + private fun resolvePrimitiveCast( + expr: UExpr<out USort>, + typeBefore: JcPrimitiveType, + type: JcPrimitiveType, + ): UExpr<out USort> { // we need this, because char is unsigned, so it should be widened before a cast - val wideExpr = if (operand.type == ctx.cp.char) { - expr wideWith operand.type + val wideExpr = if (typeBefore == ctx.cp.char) { + expr wideWith typeBefore } else { expr } - when (type) { + return when (type) { ctx.cp.boolean -> JcUnaryOperator.CastToBoolean(wideExpr) ctx.cp.short -> JcUnaryOperator.CastToShort(wideExpr) ctx.cp.int -> JcUnaryOperator.CastToInt(wideExpr) @@ -588,7 +630,7 @@ class JcExprResolver( ctx.cp.double -> JcUnaryOperator.CastToDouble(wideExpr) ctx.cp.byte -> JcUnaryOperator.CastToByte(wideExpr) ctx.cp.char -> JcUnaryOperator.CastToChar(wideExpr) - else -> error("Unexpected cast expression: $operand") + else -> error("Unexpected cast expression: ($type) $expr of $typeBefore") } } diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcInterpreter.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcInterpreter.kt index c028a48d47..4417db0b28 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcInterpreter.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcInterpreter.kt @@ -3,6 +3,7 @@ package org.usvm.machine import io.ksmt.utils.asExpr import org.jacodb.api.JcField import org.jacodb.api.JcMethod +import org.jacodb.api.JcRefType import org.jacodb.api.JcType import org.jacodb.api.cfg.JcArgument import org.jacodb.api.cfg.JcAssignInst @@ -26,9 +27,12 @@ import org.usvm.machine.state.JcState import org.usvm.machine.state.WrappedException import org.usvm.machine.state.addEntryMethodCall import org.usvm.machine.state.lastStmt +import org.usvm.machine.state.localIdx import org.usvm.machine.state.newStmt +import org.usvm.machine.state.parametersWithThisCount import org.usvm.machine.state.returnValue import org.usvm.machine.state.throwException +import org.usvm.solver.USatResult typealias JcStepScope = StepScope<JcState, JcType, JcField> @@ -40,25 +44,35 @@ class JcInterpreter( private val applicationGraph: JcApplicationGraph, ) : UInterpreter<JcState>() { fun getInitialState(method: JcMethod): JcState { - val solver = ctx.solver<JcField, JcType, JcMethod>() - val model = solver.emptyModel() - - val state = JcState( - ctx, - models = listOf(model) - ) + val state = JcState(ctx) state.addEntryMethodCall(applicationGraph, method) - val scope = StepScope(state) + val typedMethod = with(applicationGraph) { method.typed } + if (!method.isStatic) { with(ctx) { val thisLValue = URegisterLValue(addressSort, 0) val ref = state.memory.read(thisLValue).asExpr(addressSort) - scope.assert(mkEq(ref, nullRef).not()) + state.pathConstraints += mkEq(ref, nullRef).not() + state.pathConstraints += mkIsExpr(ref, typedMethod.enclosingType) } } - check(scope.alive) + typedMethod.parameters.forEachIndexed { idx, typedParameter -> + with(ctx) { + val type = typedParameter.type + if (type is JcRefType) { + val argumentLValue = URegisterLValue(typeToSort(type), method.localIdx(idx)) + val ref = state.memory.read(argumentLValue).asExpr(addressSort) + state.pathConstraints += mkIsExpr(ref, type) + } + } + } + + val solver = ctx.solver<JcField, JcType, JcMethod>() + + val model = (solver.check(state.pathConstraints, useSoftConstraints = true) as USatResult).model + state.models = listOf(model) return state } @@ -94,6 +108,7 @@ class JcInterpreter( lastStmt: JcInst, ) { applicationGraph.successors(lastStmt) // TODO: check catchers for lastStmt + scope.calcOnState { throwException(exception) } } @@ -195,11 +210,11 @@ class JcInterpreter( is JcLocalVar -> localVarToIdx .getOrPut(method) { mutableMapOf() } .run { - getOrPut(local.name) { method.parameters.size + size + if (method.isStatic) 0 else 1 } + getOrPut(local.name) { method.parametersWithThisCount + size } } is JcThis -> 0 - is JcArgument -> local.index + if (method.isStatic) 0 else 1 + is JcArgument -> method.localIdx(local.index) else -> error("Unexpected local: $local") } diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcMachine.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcMachine.kt index d6c3a296a0..eec62a9af3 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcMachine.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcMachine.kt @@ -5,13 +5,18 @@ import org.jacodb.api.JcMethod import org.jacodb.api.cfg.JcInst import org.jacodb.api.ext.methods import org.usvm.CoverageZone -import org.usvm.UMachineOptions import org.usvm.PathSelectorCombinationStrategy import org.usvm.UMachine +import org.usvm.UMachineOptions import org.usvm.machine.state.JcMethodResult import org.usvm.machine.state.JcState import org.usvm.ps.createPathSelector -import org.usvm.statistics.* +import org.usvm.statistics.CompositeUMachineObserver +import org.usvm.statistics.CoverageStatistics +import org.usvm.statistics.CoveredNewStatesCollector +import org.usvm.statistics.DistanceStatistics +import org.usvm.statistics.PathsTreeStatistics +import org.usvm.statistics.UMachineObserver import org.usvm.stopstrategies.createStopStrategy class JcMachine( @@ -20,7 +25,7 @@ class JcMachine( ) : UMachine<JcState>() { private val applicationGraph = JcApplicationGraph(cp) - private val typeSystem = JcTypeSystem() + private val typeSystem = JcTypeSystem(cp) private val components = JcComponents(typeSystem, options.solverType) private val ctx = JcContext(cp, components) diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcTypeSystem.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcTypeSystem.kt index 9b620287ef..f8c2ae7a78 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/JcTypeSystem.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/JcTypeSystem.kt @@ -1,20 +1,50 @@ package org.usvm.machine +import org.jacodb.api.JcArrayType import org.jacodb.api.JcClassType +import org.jacodb.api.JcClasspath +import org.jacodb.api.JcPrimitiveType +import org.jacodb.api.JcRefType import org.jacodb.api.JcType import org.jacodb.api.ext.isAssignable -import org.usvm.UTypeSystem +import org.jacodb.api.ext.objectType +import org.jacodb.api.ext.toType +import org.jacodb.impl.features.HierarchyExtensionImpl +import org.usvm.types.USupportTypeStream +import org.usvm.types.UTypeStream +import org.usvm.types.UTypeSystem -class JcTypeSystem : UTypeSystem<JcType> { - override fun isSupertype(u: JcType, t: JcType): Boolean { - return t.isAssignable(u) - } +class JcTypeSystem( + private val cp: JcClasspath, +) : UTypeSystem<JcType> { + private val hierarchy = HierarchyExtensionImpl(cp) - override fun isMultipleInheritanceAllowedFor(t: JcType): Boolean { - return (t as? JcClassType)?.jcClass?.isInterface ?: false - } + override fun isSupertype(u: JcType, t: JcType): Boolean = + t.isAssignable(u) + + override fun isMultipleInheritanceAllowedFor(t: JcType): Boolean = + (t as? JcClassType)?.jcClass?.isInterface ?: false + + override fun isFinal(t: JcType): Boolean = + (t as? JcClassType)?.isFinal ?: false - override fun isFinal(t: JcType): Boolean { - return (t as? JcClassType)?.isFinal ?: false + override fun isInstantiable(t: JcType): Boolean = + t !is JcRefType || (!t.jcClass.isInterface && !t.jcClass.isAbstract) + + // TODO: deal with generics + // TODO: handle object type, serializable and cloneable + override fun findSubtypes(t: JcType): Sequence<JcType> = when (t) { + is JcPrimitiveType -> emptySequence() // TODO: should not be called here + is JcArrayType -> findSubtypes(t.elementType).map { cp.arrayTypeOf(it) } + is JcRefType -> hierarchy + .findSubClasses(t.jcClass, allHierarchy = false) // TODO: prioritize classes somehow and filter bad classes + .map { it.toType() } + + else -> error("Unknown type $t") } + + private val topTypeStream by lazy { USupportTypeStream.from(this, cp.objectType) } + + override fun topTypeStream(): UTypeStream<JcType> = + topTypeStream } diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/operator/JcUnaryOperator.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/operator/JcUnaryOperator.kt index 08a9526e24..796be91c32 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/operator/JcUnaryOperator.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/operator/JcUnaryOperator.kt @@ -29,23 +29,28 @@ sealed class JcUnaryOperator( ) object CastToByte : JcUnaryOperator( + onBool = { operand -> operand.wideTo32BitsIfNeeded(false) }, onBv = { operand -> operand.mkNarrow(Byte.SIZE_BITS, signed = true) } ) object CastToChar : JcUnaryOperator( + onBool = { operand -> operand.wideTo32BitsIfNeeded(false) }, onBv = { operand -> operand.mkNarrow(Char.SIZE_BITS, signed = true) } ) object CastToShort : JcUnaryOperator( + onBool = { operand -> operand.wideTo32BitsIfNeeded(false) }, onBv = { operand -> operand.mkNarrow(Short.SIZE_BITS, signed = true) } ) object CastToInt : JcUnaryOperator( + onBool = { operand -> operand.wideTo32BitsIfNeeded(false) }, onBv = { operand -> operand.mkNarrow(Int.SIZE_BITS, signed = true) }, onFp = { operand -> operand.castToBv(Int.SIZE_BITS) } ) object CastToLong : JcUnaryOperator( + onBool = { operand -> operand.wideTo32BitsIfNeeded(false) }, onBv = { operand -> operand.mkNarrow(Long.SIZE_BITS, signed = true) }, onFp = { operand -> operand.castToBv(Long.SIZE_BITS) } ) diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcState.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcState.kt index f7b2257d61..68a8096600 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcState.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcState.kt @@ -7,6 +7,7 @@ import org.jacodb.api.JcMethod import org.jacodb.api.JcType import org.jacodb.api.cfg.JcInst import org.usvm.UCallStack +import org.usvm.UContext import org.usvm.UState import org.usvm.constraints.UPathConstraints import org.usvm.machine.JcContext @@ -14,7 +15,7 @@ import org.usvm.memory.UMemoryBase import org.usvm.model.UModelBase class JcState( - override val ctx: JcContext, + ctx: UContext, callStack: UCallStack<JcMethod, JcInst> = UCallStack(), pathConstraints: UPathConstraints<JcType> = UPathConstraints(ctx), memory: UMemoryBase<JcField, JcType, JcMethod> = UMemoryBase(ctx, pathConstraints.typeConstraints), @@ -32,7 +33,7 @@ class JcState( override fun clone(newConstraints: UPathConstraints<JcType>?): JcState { val clonedConstraints = newConstraints ?: pathConstraints.clone() return JcState( - ctx, + pathConstraints.ctx, callStack.clone(), clonedConstraints, memory.clone(clonedConstraints.typeConstraints), diff --git a/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcStateUtils.kt b/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcStateUtils.kt index 4512462ff6..9c63c13b1d 100644 --- a/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcStateUtils.kt +++ b/usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcStateUtils.kt @@ -73,9 +73,10 @@ fun JcState.addNewMethodCall( newStmt(entryPoint) } +fun JcMethod.localIdx(idx: Int) = if (isStatic) idx else idx + 1 // TODO: cache it with JacoDB cache -inline val JcMethod.parametersWithThisCount get() = parameters.size + if (isStatic) 0 else 1 +inline val JcMethod.parametersWithThisCount get() = localIdx(parameters.size) // TODO: cache it with JacoDB cache inline val JcMethod.localsCount get() = instList.locals.filter { it !is JcArgument }.size diff --git a/usvm-jvm/src/samples/java/org/usvm/samples/mixed/Overload.java b/usvm-jvm/src/samples/java/org/usvm/samples/mixed/Overload.java index 557bb86aae..6c4e801493 100644 --- a/usvm-jvm/src/samples/java/org/usvm/samples/mixed/Overload.java +++ b/usvm-jvm/src/samples/java/org/usvm/samples/mixed/Overload.java @@ -11,7 +11,7 @@ public int sign(int x) { } } - public int sign(int x, int y) { + public int signBinary(int x, int y) { if (x + y > 0) { return 1; } else if (x + y < 0) { diff --git a/usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithRefFieldExample.java b/usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithRefFieldExample.java index a1492a3eef..9b7e5f3d31 100644 --- a/usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithRefFieldExample.java +++ b/usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithRefFieldExample.java @@ -107,7 +107,7 @@ public int compareTwoObjectsWithDifferentRefField(ObjectWithRefFieldClass fst, O return 2; } - public boolean compareTwoObjectsWithDifferentRefField(ObjectWithRefFieldClass fst, ObjectWithRefFieldClass snd) { + public boolean compareTwoObjectsWithTheDifferentRefField(ObjectWithRefFieldClass fst, ObjectWithRefFieldClass snd) { return fst.refField == snd.refField; } diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/JavaMethodTestRunner.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/JavaMethodTestRunner.kt index 8065367c7f..ef3a24a0cd 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/JavaMethodTestRunner.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/JavaMethodTestRunner.kt @@ -19,7 +19,7 @@ import kotlin.reflect.KFunction2 import kotlin.reflect.KFunction3 import kotlin.reflect.KFunction4 import kotlin.reflect.full.instanceParameter -import kotlin.reflect.full.isSubclassOf +import kotlin.reflect.jvm.javaConstructor import kotlin.reflect.jvm.javaMethod @@ -700,7 +700,8 @@ open class JavaMethodTestRunner : TestRunner<JcTest, KFunction<*>, KClass<*>?, J requireNotNull(thisInstance) values += thisInstance } else { - require(thisInstance == null) + // Note that for constructors we have thisInstance in such as case, in contrast to simple methods + require(thisInstance == null || method.javaConstructor != null) } values.addAll(parameters.take(method.parameters.size - values.size)) // add remaining arguments return values @@ -712,10 +713,10 @@ open class JavaMethodTestRunner : TestRunner<JcTest, KFunction<*>, KClass<*>?, J override val typeTransformer: (Any?) -> KClass<*>? = { value -> value?.let { it::class } } override val checkType: (KClass<*>?, KClass<*>?) -> Boolean = - { expected, actual -> actual == null || expected != null && actual.isSubclassOf(expected) } + { expected, actual -> actual == null || expected != null && expected.java.isAssignableFrom(actual.java) } override val runner: (KFunction<*>, UMachineOptions) -> List<JcTest> = { method, options -> - val declaringClassName = requireNotNull(method.javaMethod?.declaringClass?.name) + val declaringClassName = requireNotNull(method.declaringClass?.name) val jcClass = cp.findClass(declaringClassName).toType() val jcMethod = jcClass.declaredMethods.first { it.name == method.name } @@ -728,4 +729,14 @@ open class JavaMethodTestRunner : TestRunner<JcTest, KFunction<*>, KClass<*>?, J override val coverageRunner: (List<JcTest>) -> JcClassCoverage = { _ -> JcClassCoverage(visitedStmts = emptySet()) } + + companion object { + init { + // See https://dzone.com/articles/how-to-export-all-modules-to-all-modules-at-runtime-in-java?preview=true + org.burningwave.core.assembler.StaticComponentContainer.Modules.exportAllToAll() + } + } } + +private val KFunction<*>.declaringClass: Class<*>? + get() = (javaMethod ?: javaConstructor)?.declaringClass diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/BinarySearchTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/BinarySearchTest.kt index e6b2cbc2b1..feb34d2cfd 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/BinarySearchTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/BinarySearchTest.kt @@ -8,7 +8,6 @@ import org.usvm.util.isException class BinarySearchTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testLeftBinarySearch() { checkDiscoveredPropertiesWithExceptions( BinarySearch::leftBinSearch, @@ -22,7 +21,6 @@ class BinarySearchTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testRightBinarySearch() { checkDiscoveredPropertiesWithExceptions( BinarySearch::rightBinSearch, @@ -36,7 +34,6 @@ class BinarySearchTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testDefaultBinarySearch() { checkDiscoveredPropertiesWithExceptions( BinarySearch::defaultBinarySearch, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/CorrectBracketSequencesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/CorrectBracketSequencesTest.kt index 84e5c4352f..3a42dec7bc 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/CorrectBracketSequencesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/CorrectBracketSequencesTest.kt @@ -40,7 +40,7 @@ internal class CorrectBracketSequencesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3e4ead73") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@527d1fe1") fun testIsCbs() { val method = CorrectBracketSequences::isCbs checkDiscoveredPropertiesWithExceptions( diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/GraphTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/GraphTest.kt index db28811ff0..2b99b74bff 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/GraphTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/GraphTest.kt @@ -9,7 +9,7 @@ import org.usvm.util.isException internal class GraphTest : JavaMethodTestRunner() { @Test - @Disabled("Only NPEs are found") + @Disabled("Some properties were not discovered at positions (from 0): [0, 1, 2, 3, 4]. Tune coverage zone") fun testRunFindCycle() { checkDiscoveredPropertiesWithExceptions( GraphExample::runFindCycle, @@ -36,7 +36,7 @@ internal class GraphTest : JavaMethodTestRunner() { * TODO: fix Dijkstra algorithm. */ @Test - @Disabled("Some properties were not discovered at positions (from 0): [3, 4]") + @Disabled("Some properties were not discovered at positions (from 0): [3, 4]. Tune coverage zone") fun testRunDijkstraWithParameter() { checkDiscoveredPropertiesWithExceptions( GraphExample::runDijkstraWithParameter, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/SortTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/SortTest.kt index cc3ee58d6f..097fae4d35 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/SortTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/algorithms/SortTest.kt @@ -9,7 +9,7 @@ import org.usvm.util.isException internal class SortTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@b66d50c") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3a182eaf") fun testQuickSort() { checkDiscoveredProperties( Sort::quickSort, @@ -19,7 +19,6 @@ internal class SortTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testSwap() { checkDiscoveredPropertiesWithExceptions( Sort::swap, @@ -73,7 +72,7 @@ internal class SortTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [4, 5]") + @Disabled("Some properties were not discovered at positions (from 0): [1, 3, 4, 5]. Tune path selectors") fun testMerge() { checkDiscoveredPropertiesWithExceptions( Sort::merge, @@ -106,7 +105,7 @@ internal class SortTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") + @Disabled("Some properties were not discovered at positions (from 0): [1, 2]. Tune path selectors") fun testDefaultSort() { checkDiscoveredPropertiesWithExceptions( Sort::defaultSort, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/NotNullAnnotationTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/NotNullAnnotationTest.kt index d999b1c985..de2e5cc5f0 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/NotNullAnnotationTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/NotNullAnnotationTest.kt @@ -1,84 +1,80 @@ package org.usvm.samples.annotations -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner -import org.usvm.test.util.checkers.eq +import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults -@Suppress("SENSELESS_COMPARISON") internal class NotNullAnnotationTest : JavaMethodTestRunner() { @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer") fun testDoesNotThrowNPE() { checkDiscoveredProperties( NotNullAnnotation::doesNotThrowNPE, - eq(1), + /*eq(1)*/ignoreNumberOfAnalysisResults, { _, value, r -> value == r }, - invariants = arrayOf( + /*invariants = arrayOf( { _, value, _ -> value != null } - ) + )*/ + // TODO support NotNull annotations ) } @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer") fun testThrowsNPE() { checkDiscoveredProperties( NotNullAnnotation::throwsNPE, - eq(2), + /*eq(2)*/ignoreNumberOfAnalysisResults, // TODO support NotNull annotations, { _, value, _ -> value == null }, { _, value, r -> value == r }, ) } @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer") fun testSeveralParameters() { checkDiscoveredProperties( NotNullAnnotation::severalParameters, - eq(2), + /*eq(2)*/ignoreNumberOfAnalysisResults, { _, _, second, _, _ -> second == null }, { _, first, second, third, result -> first + second + third == result }, - invariants = arrayOf( + /*invariants = arrayOf( { _, first, _, third, _ -> first != null && third != null } - ) + )*/ + // TODO support NotNull annotations ) } @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer\n") fun testUseNotNullableValue() { checkDiscoveredProperties( NotNullAnnotation::useNotNullableValue, - eq(1), + /*eq(1)*/ignoreNumberOfAnalysisResults, { _, value, r -> value == r }, - invariants = arrayOf( + /*invariants = arrayOf( { _, value, _ -> value != null } - ) + )*/ + // TODO support NotNull annotations ) } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@7066363") fun testNotNullableVariable() { checkDiscoveredProperties( NotNullAnnotation::notNullableVariable, - eq(2), + /*eq(2)*/ignoreNumberOfAnalysisResults, { _, first, second, third, r -> first + second + third == r }, { _, _, second, _, _ -> second == null }, - invariants = arrayOf( + /*invariants = arrayOf( { _, first, _, third, _ -> first != null && third != null }, - ) + )*/ + // TODO support NotNull annotations ) } @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer") fun testNotNullField() { checkDiscoveredProperties( NotNullAnnotation::notNullField, - eq(1), + /*eq(1)*/ignoreNumberOfAnalysisResults, // TODO support NotNull annotations, { _, value, result -> value.boxedInt == result }, ) } @@ -94,11 +90,10 @@ internal class NotNullAnnotationTest : JavaMethodTestRunner() { // } @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer") fun testJavaxValidationNotNull() { checkDiscoveredProperties( NotNullAnnotation::javaxValidationNotNull, - eq(1), + /*eq(1)*/ignoreNumberOfAnalysisResults, // TODO support NotNull annotations, { _, value, r -> value == r } ) } diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/lombok/NotNullAnnotationsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/lombok/NotNullAnnotationsTest.kt index 60dc993265..62bee0a0b2 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/lombok/NotNullAnnotationsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/lombok/NotNullAnnotationsTest.kt @@ -1,9 +1,8 @@ package org.usvm.samples.annotations.lombok -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner -import org.usvm.test.util.checkers.eq +import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults /** @@ -15,12 +14,12 @@ import org.usvm.test.util.checkers.eq */ internal class NotNullAnnotationsTest : JavaMethodTestRunner() { @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer") fun testNonNullAnnotations() { checkDiscoveredProperties( NotNullAnnotations::lombokNonNull, - eq(1), + /*eq(1)*/ignoreNumberOfAnalysisResults, { _, value, r -> value == r }, + // TODO support NotNull annotations ) } } \ No newline at end of file diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfArraysTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfArraysTest.kt index e87a74ef81..e8050bba61 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfArraysTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfArraysTest.kt @@ -31,7 +31,7 @@ internal class ArrayOfArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Impossible NPE found") + @Disabled("Some properties were not discovered at positions (from 0): [0]. Multidimensional array") fun testDefaultValuesWithoutLastDimension() { checkDiscoveredProperties( ArrayOfArrays::defaultValuesWithoutLastDimension, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfObjectsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfObjectsTest.kt index 8a6d4a56fe..bc1d581241 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfObjectsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayOfObjectsTest.kt @@ -20,7 +20,6 @@ internal class ArrayOfObjectsTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 2 executions, but 3 found. Same exception discovered multiple times") fun testCreateArray() { checkDiscoveredProperties( ArrayOfObjects::createArray, @@ -38,7 +37,6 @@ internal class ArrayOfObjectsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testCopyArray() { checkDiscoveredPropertiesWithExceptions( ArrayOfObjects::copyArray, @@ -51,7 +49,6 @@ internal class ArrayOfObjectsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testCopyArrayMutation() { checkThisAndParamsMutations( ArrayOfObjects::copyArray, @@ -64,7 +61,6 @@ internal class ArrayOfObjectsTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testArrayWithSucc() { checkDiscoveredProperties( ArrayOfObjects::arrayWithSucc, @@ -84,7 +80,8 @@ internal class ArrayOfObjectsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2].") + @Disabled("java.lang.ArrayStoreException: org.usvm.samples.arrays.ObjectWithPrimitivesClass." + + "Connect element type and array type") fun testObjectArray() { checkDiscoveredProperties( ArrayOfObjects::objectArray, @@ -98,7 +95,7 @@ internal class ArrayOfObjectsTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("List is empty. java.lang.ArrayStoreException: org.usvm.samples.arrays.ObjectWithPrimitivesClass") fun testArrayOfArrays() { checkDiscoveredProperties( ArrayOfObjects::arrayOfArrays, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayStoreExceptionExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayStoreExceptionExamplesTest.kt index 78b5328ca2..1583e173df 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayStoreExceptionExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/ArrayStoreExceptionExamplesTest.kt @@ -8,17 +8,19 @@ import org.usvm.util.isException class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") + @Disabled("Some properties were not discovered at positions (from 0): [1]. Fix branch coverage") fun testCorrectAssignmentSamePrimitiveType() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::correctAssignmentSamePrimitiveType, - eq(3), - { _, data, result -> result.isSuccess && result.getOrNull() == data?.isNotEmpty() } + eq(2), + { _, data, result -> result.isSuccess && result.getOrNull() == false && data == null }, + { _, data, result -> result.isSuccess && result.getOrNull() == false && data != null && data.isEmpty() }, + { _, data, result -> result.isSuccess && result.getOrNull() == true && data != null && data.isNotEmpty() } ) } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@46468f0") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@576c8cea") fun testCorrectAssignmentIntToIntegerArray() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::correctAssignmentIntToIntegerArray, @@ -28,7 +30,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@7ddeb27f") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@2ecc303c") fun testCorrectAssignmentSubtype() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::correctAssignmentSubtype, @@ -38,7 +40,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3684d2c0") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@47effce0") fun testCorrectAssignmentToObjectArray() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::correctAssignmentToObjectArray, @@ -48,7 +50,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("An operation is not implemented: Not yet implemented") fun testWrongAssignmentUnrelatedType() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::wrongAssignmentUnrelatedType, @@ -60,7 +62,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@17176b18") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@26bc130c") fun testCheckGenericAssignmentWithCorrectCast() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::checkGenericAssignmentWithCorrectCast, @@ -80,7 +82,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3c6fb501") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@46441754") fun testCheckGenericAssignmentWithExtendsSubtype() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::checkGenericAssignmentWithExtendsSubtype, @@ -110,7 +112,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [0]") + @Disabled("Some properties were not discovered at positions (from 0): [0]. Support generics") fun testCheckWrongAssignmentOfItself() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::checkWrongAssignmentOfItself, @@ -120,7 +122,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") + @Disabled("Some properties were not discovered at positions (from 0): [0]. Support generics") fun testCheckGoodAssignmentOfItself() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::checkGoodAssignmentOfItself, @@ -130,7 +132,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@44fd7ba4") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@76e579d8") fun testCheckAssignmentToObjectArray() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::checkAssignmentToObjectArray, @@ -152,7 +154,7 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 1 executions, but 2 found") + @Disabled("Some executions violated invariants. Support multidimensional arrays initialization") fun testFill2DPrimitiveArray() { checkDiscoveredPropertiesWithExceptions( ArrayStoreExceptionExamples::fill2DPrimitiveArray, @@ -165,7 +167,6 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("ClassNotFound java.util.List<java.lang.Integer>") fun testFillObjectArrayWithList() { checkDiscoveredProperties( ArrayStoreExceptionExamples::fillObjectArrayWithList, @@ -176,7 +177,6 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Class not found java.util.TreeSet<java.lang.Integer>") fun testFillWithTreeSet() { checkDiscoveredProperties( ArrayStoreExceptionExamples::fillWithTreeSet, @@ -187,7 +187,6 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("java.lang.InstantiationException: org.usvm.samples.arrays.SomeInterface") fun testFillSomeInterfaceArrayWithSomeInterface() { checkDiscoveredProperties( ArrayStoreExceptionExamples::fillSomeInterfaceArrayWithSomeInterface, @@ -198,7 +197,6 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("java.lang.InstantiationException: org.usvm.samples.arrays.SomeInterface") fun testFillObjectArrayWithSomeInterface() { checkDiscoveredProperties( ArrayStoreExceptionExamples::fillObjectArrayWithSomeInterface, @@ -209,7 +207,6 @@ class ArrayStoreExceptionExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testFillWithSomeImplementation() { checkDiscoveredProperties( ArrayStoreExceptionExamples::fillWithSomeImplementation, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/IntArrayBasicsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/IntArrayBasicsTest.kt index 706e1d5a94..2cc36db5ee 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/IntArrayBasicsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/IntArrayBasicsTest.kt @@ -25,7 +25,6 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testIsValid() { checkDiscoveredPropertiesWithExceptions( IntArrayBasics::isValid, @@ -40,7 +39,6 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testGetValue() { checkDiscoveredPropertiesWithExceptions( IntArrayBasics::getValue, @@ -53,7 +51,6 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testSetValue() { checkDiscoveredPropertiesWithExceptions( IntArrayBasics::setValue, @@ -67,7 +64,6 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testCheckFour() { checkDiscoveredPropertiesWithExceptions( IntArrayBasics::checkFour, @@ -90,7 +86,6 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testNullability() { checkDiscoveredProperties( IntArrayBasics::nullability, @@ -102,7 +97,7 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") + @Disabled("Disjunction in if statement covered by only one execution") fun testEquality() { checkDiscoveredProperties( IntArrayBasics::equality, @@ -115,7 +110,6 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testOverwrite() { checkDiscoveredPropertiesWithExceptions( IntArrayBasics::overwrite, @@ -129,7 +123,7 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [4, 5]") + @Disabled("Some properties were not discovered at positions (from 0): [3, 4, 5]. Tune path selectors") fun testMergeArrays() { checkDiscoveredProperties( IntArrayBasics::mergeArrays, @@ -160,7 +154,6 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testNewArrayInTheMiddle() { checkDiscoveredProperties( IntArrayBasics::newArrayInTheMiddle, @@ -187,7 +180,7 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") + @Disabled("Some properties were not discovered at positions (from 0): [3]. Fix branch coverage") fun testReversed() { checkDiscoveredProperties( IntArrayBasics::reversed, @@ -213,7 +206,7 @@ internal class IntArrayBasicsTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@42ac84a9") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@2f5d95b") fun testArraysEqualsExample() { checkDiscoveredProperties( IntArrayBasics::arrayEqualsExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/PrimitiveArraysTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/PrimitiveArraysTest.kt index 33ebf90884..b8e3e97331 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/PrimitiveArraysTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/PrimitiveArraysTest.kt @@ -38,7 +38,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testByteArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::byteArray, @@ -51,7 +50,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testShortArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::shortArray, @@ -64,7 +62,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testCharArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::charArray, @@ -77,7 +74,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testIntArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::intArray, @@ -90,7 +86,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testLongArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::longArray, @@ -104,7 +99,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { @Suppress("SimplifyNegatedBinaryExpression") @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testFloatArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::floatArray, @@ -118,7 +112,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { @Suppress("SimplifyNegatedBinaryExpression") @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testDoubleArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::doubleArray, @@ -131,7 +124,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testBooleanArray() { checkDiscoveredPropertiesWithExceptions( PrimitiveArrays::booleanArray, @@ -144,7 +136,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testByteSizeAndIndex() { checkDiscoveredProperties( PrimitiveArrays::byteSizeAndIndex, @@ -156,7 +147,6 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testShortSizeAndIndex() { checkDiscoveredProperties( PrimitiveArrays::shortSizeAndIndex, @@ -168,7 +158,7 @@ internal class PrimitiveArraysTest : JavaMethodTestRunner() { } @Test - @Disabled("java.lang.OutOfMemoryError: Java heap space") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@21698165") fun testCharSizeAndIndex() { checkDiscoveredProperties( PrimitiveArrays::charSizeAndIndex, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestMultiDimensional.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestMultiDimensional.kt index 2457ff95e4..3dcf8b14ce 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestMultiDimensional.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestMultiDimensional.kt @@ -16,7 +16,7 @@ class TestMultiDimensional : JavaMethodTestRunner() { } @Test - @Disabled("TODO: multidimensional arrays") + @Disabled("Cannot load from byte/boolean array because \"java.lang.Integer.DigitOnes\" is null") fun `Test sumOfMultiNewArray`() { checkDiscoveredProperties( MultiDimensional::sumOfMultiNewArray, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestOneDimensional.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestOneDimensional.kt index ca887644ca..ca3b426d97 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestOneDimensional.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/TestOneDimensional.kt @@ -1,13 +1,11 @@ package org.usvm.samples.arrays -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults class TetOneDimensional : JavaMethodTestRunner() { @Test - @Disabled("Failed requirement at org.usvm.model.ULazyHeapModel.readArrayLength(LazyModels.kt:167)") fun `Test sumOf`() { checkDiscoveredPropertiesWithExceptions( OneDimensional::sumOf, @@ -19,7 +17,6 @@ class TetOneDimensional : JavaMethodTestRunner() { } @Test - @Disabled("Failed requirement at org.usvm.model.ULazyHeapModel.readArrayLength(LazyModels.kt:167)") fun `Test minus`() { checkDiscoveredPropertiesWithExceptions( OneDimensional::minus, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/ArrayCastExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/ArrayCastExampleTest.kt index e65bb52f6b..b990e6e53e 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/ArrayCastExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/ArrayCastExampleTest.kt @@ -9,7 +9,6 @@ import org.usvm.test.util.checkers.eq internal class ArrayCastExampleTest : JavaMethodTestRunner() { @Suppress("KotlinConstantConditions") @Test - @Disabled("An operation is not implemented.") fun testCastToAncestor() { checkDiscoveredProperties( ArrayCastExample::castToAncestor, @@ -20,7 +19,6 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testClassCastException() { checkDiscoveredProperties( ArrayCastExample::classCastException, @@ -32,7 +30,6 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testNullCast() { checkDiscoveredProperties( ArrayCastExample::nullCast, @@ -52,7 +49,6 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testSuccessfulExampleFromJLS() { checkDiscoveredProperties( ArrayCastExample::successfulExampleFromJLS, @@ -71,7 +67,6 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testCastAfterStore() { checkDiscoveredProperties( ArrayCastExample::castAfterStore, @@ -94,7 +89,6 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testCastFromObject() { checkDiscoveredProperties( ArrayCastExample::castFromObject, @@ -106,7 +100,7 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("Support assumptions") fun testCastFromObjectToPrimitivesArray() { checkDiscoveredProperties( ArrayCastExample::castFromObjectToPrimitivesArray, @@ -117,7 +111,6 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testCastsChainFromObject() { checkDiscoveredProperties( ArrayCastExample::castsChainFromObject, @@ -134,7 +127,7 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("java.lang.ClassNotFoundException: sun.rmi.rmic.BatchEnvironment\$Path. Fix types priority") fun testCastFromCollections() { checkDiscoveredProperties( ArrayCastExample::castFromCollections, @@ -146,7 +139,7 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("java.lang.ClassNotFoundException: sun.rmi.rmic.BatchEnvironment\$Path. Fix types priority") fun testCastFromIterable() { checkDiscoveredProperties( ArrayCastExample::castFromIterable, @@ -158,7 +151,7 @@ internal class ArrayCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("java.lang.ClassNotFoundException: sun.rmi.rmic.BatchEnvironment\$Path. Fix types priority") fun testCastFromIterableToCollection() { checkDiscoveredProperties( ArrayCastExample::castFromIterableToCollection, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastClassTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastClassTest.kt index 14353702b3..0ca41f85b3 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastClassTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastClassTest.kt @@ -9,7 +9,7 @@ import org.usvm.test.util.checkers.eq internal class CastClassTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented.") + @Disabled("Support instanceof") fun testThisTypeChoice() { checkDiscoveredProperties( CastClass::castToInheritor, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastExampleTest.kt index ed06f3d4e5..af3f1233f1 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastExampleTest.kt @@ -9,7 +9,6 @@ import org.usvm.util.isException internal class CastExampleTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented.") fun testSimpleCast() { checkDiscoveredProperties( CastExample::simpleCast, @@ -21,7 +20,6 @@ internal class CastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testClassCastException() { checkDiscoveredPropertiesWithExceptions( CastExample::castClassException, @@ -33,7 +31,6 @@ internal class CastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testCastUp() { checkDiscoveredProperties( CastExample::castUp, @@ -42,7 +39,6 @@ internal class CastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testCastNullToDifferentTypes() { checkDiscoveredProperties( CastExample::castNullToDifferentTypes, @@ -51,7 +47,6 @@ internal class CastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") fun testFromObjectToPrimitive() { checkDiscoveredProperties( CastExample::fromObjectToPrimitive, @@ -63,7 +58,7 @@ internal class CastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("Support assumptions") fun testCastFromObjectToInterface() { checkDiscoveredProperties( CastExample::castFromObjectToInterface, @@ -74,7 +69,7 @@ internal class CastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("Support assumptions") fun testComplicatedCast() { checkDiscoveredProperties( CastExample::complicatedCast, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/GenericCastExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/GenericCastExampleTest.kt index bc89dfa292..73d99cbe80 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/GenericCastExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/GenericCastExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class GenericCastExampleTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented.") + @Disabled("Expected exactly 5 executions, but 1 found. Support generics") fun testCompareTwoNumbers() { checkDiscoveredProperties( GenericCastExample::compareTwoNumbers, @@ -22,7 +22,7 @@ internal class GenericCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("Expected exactly 3 executions, but 2 found. Support generics") fun testGetGenericFieldValue() { checkDiscoveredProperties( GenericCastExample::getGenericFieldValue, @@ -34,7 +34,7 @@ internal class GenericCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("List is empty. Support generics") fun testCompareGenericField() { checkDiscoveredProperties( GenericCastExample::compareGenericField, @@ -47,7 +47,7 @@ internal class GenericCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@5f0f70c7") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@5927f2b1") fun testCreateNewGenericObject() { checkDiscoveredProperties( GenericCastExample::createNewGenericObject, @@ -57,7 +57,7 @@ internal class GenericCastExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented.") + @Disabled("List is empty. Support generics") fun testSumFromArrayOfGenerics() { checkDiscoveredProperties( GenericCastExample::sumFromArrayOfGenerics, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/InstanceOfExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/InstanceOfExampleTest.kt index 896b2eff53..c95de1f41a 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/InstanceOfExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/casts/InstanceOfExampleTest.kt @@ -8,9 +8,9 @@ import org.usvm.test.util.checkers.ge import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults +@Disabled("Support instanceof") internal class InstanceOfExampleTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testSimpleInstanceOf() { checkDiscoveredProperties( InstanceOfExample::simpleInstanceOf, @@ -21,7 +21,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testNullPointerCheck() { checkDiscoveredProperties( InstanceOfExample::nullPointerCheck, @@ -33,7 +32,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testVirtualCall() { checkDiscoveredProperties( InstanceOfExample::virtualCall, @@ -44,7 +42,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testVirtualFunctionCallWithCast() { checkDiscoveredProperties( InstanceOfExample::virtualFunctionCallWithCast, @@ -56,7 +53,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testVirtualCallWithoutOneInheritor() { checkDiscoveredProperties( InstanceOfExample::virtualCallWithoutOneInheritor, @@ -69,7 +65,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testVirtualCallWithoutOneInheritorInverse() { checkDiscoveredProperties( InstanceOfExample::virtualCallWithoutOneInheritorInverse, @@ -82,7 +77,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testWithoutOneInheritorOnArray() { checkDiscoveredProperties( InstanceOfExample::withoutOneInheritorOnArray, @@ -93,7 +87,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testWithoutOneInheritorOnArrayInverse() { checkDiscoveredProperties( InstanceOfExample::withoutOneInheritorOnArrayInverse, @@ -105,7 +98,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfAsPartOfInternalExpressions() { checkDiscoveredProperties( InstanceOfExample::instanceOfAsPartOfInternalExpressions, @@ -138,7 +130,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfAsPartOfInternalExpressionsCastClass() { checkDiscoveredProperties( InstanceOfExample::instanceOfAsPartOfInternalExpressionsCastClass, @@ -171,7 +162,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfAsPartOfInternalExpressionsXor() { checkDiscoveredProperties( InstanceOfExample::instanceOfAsPartOfInternalExpressionsXor, @@ -200,7 +190,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfAsPartOfInternalExpressionsXorInverse() { checkDiscoveredProperties( InstanceOfExample::instanceOfAsPartOfInternalExpressionsXorInverse, @@ -229,7 +218,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfAsPartOfInternalExpressionsIntValue() { checkDiscoveredProperties( InstanceOfExample::instanceOfAsPartOfInternalExpressionsIntValue, @@ -246,7 +234,7 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@6f986501") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@74414a78") fun testInstanceOfAsInternalExpressionsMap() { checkDiscoveredProperties( InstanceOfExample::instanceOfAsInternalExpressionsMap, @@ -256,7 +244,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testSymbolicInstanceOf() { checkDiscoveredProperties( InstanceOfExample::symbolicInstanceOf, @@ -271,7 +258,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testComplicatedInstanceOf() { checkDiscoveredProperties( InstanceOfExample::complicatedInstanceOf, @@ -315,7 +301,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfFromArray() { checkDiscoveredProperties( InstanceOfExample::instanceOfFromArray, @@ -329,7 +314,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfFromArrayWithReadingAnotherElement() { checkDiscoveredProperties( InstanceOfExample::instanceOfFromArrayWithReadingAnotherElement, @@ -342,7 +326,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfFromArrayWithReadingSameElement() { checkDiscoveredProperties( InstanceOfExample::instanceOfFromArrayWithReadingSameElement, @@ -355,7 +338,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testIsNull() { checkDiscoveredProperties( InstanceOfExample::isNull, @@ -366,7 +348,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testArrayInstanceOfArray() { checkDiscoveredProperties( InstanceOfExample::arrayInstanceOfArray, @@ -382,7 +363,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testObjectInstanceOfArray() { checkDiscoveredProperties( InstanceOfExample::objectInstanceOfArray, @@ -394,7 +374,6 @@ internal class InstanceOfExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testInstanceOfObjectArray() { checkDiscoveredProperties( InstanceOfExample::instanceOfObjectArray, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/ClassWithStaticAndInnerClassesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/ClassWithStaticAndInnerClassesTest.kt index 10114c88d1..9bf196d3d1 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/ClassWithStaticAndInnerClassesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/ClassWithStaticAndInnerClassesTest.kt @@ -8,9 +8,9 @@ import org.usvm.test.util.checkers.eq @Suppress("INACCESSIBLE_TYPE") +@Disabled("Expected exactly 2 executions, but 1 found. Fix inner classes") internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePrivateStaticClassWithPrivateField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePrivateStaticClassWithPrivateField, @@ -19,7 +19,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePrivateStaticClassWithPublicField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePrivateStaticClassWithPublicField, @@ -28,7 +27,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePublicStaticClassWithPrivateField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePublicStaticClassWithPrivateField, @@ -37,7 +35,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePublicStaticClassWithPublicField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePublicStaticClassWithPublicField, @@ -46,7 +43,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePrivateInnerClassWithPrivateField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePrivateInnerClassWithPrivateField, @@ -55,7 +51,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePrivateInnerClassWithPublicField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePrivateInnerClassWithPublicField, @@ -64,7 +59,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePublicInnerClassWithPrivateField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePublicInnerClassWithPrivateField, @@ -73,7 +67,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePublicInnerClassWithPublicField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePublicInnerClassWithPublicField, @@ -82,7 +75,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePackagePrivateFinalStaticClassWithPackagePrivateField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePackagePrivateFinalStaticClassWithPackagePrivateField, @@ -91,7 +83,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testUsePackagePrivateFinalInnerClassWithPackagePrivateField() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::usePackagePrivateFinalInnerClassWithPackagePrivateField, @@ -100,7 +91,6 @@ internal class ClassWithStaticAndInnerClassesTest : JavaMethodTestRunner() { } @Test - @Disabled("java.lang.ClassNotFoundException: org.usvm.samples.codegen.ClassWithStaticAndInnerClasses.ClassWithStaticAndInnerClasses\$PrivateInnerClassWithPublicField") fun testGetValueFromPublicFieldWithPrivateType() { checkDiscoveredProperties( ClassWithStaticAndInnerClasses::getValueFromPublicFieldWithPrivateType, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/JavaAssertTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/JavaAssertTest.kt index d6ab5b62cc..2c913d4b07 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/JavaAssertTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/JavaAssertTest.kt @@ -8,7 +8,7 @@ import org.usvm.util.isException class JavaAssertTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@41ccb3b9") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@2efac41a") fun testAssertPositive() { checkDiscoveredPropertiesWithExceptions( JavaAssert::assertPositive, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/VoidStaticMethodsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/VoidStaticMethodsTest.kt index 2ad88af0ec..c204f611a1 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/VoidStaticMethodsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/VoidStaticMethodsTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq class VoidStaticMethodsTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@41ccb3b9") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@206987b2") fun testInvokeChangeStaticFieldMethod() { checkDiscoveredProperties( VoidStaticMethodsTestingClass::invokeChangeStaticFieldMethod, @@ -17,7 +17,7 @@ class VoidStaticMethodsTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3d2bcab9") fun testInvokeThrowExceptionMethod() { checkDiscoveredProperties( VoidStaticMethodsTestingClass::invokeThrowExceptionMethod, @@ -26,7 +26,7 @@ class VoidStaticMethodsTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") + @Disabled("Expected exactly 2 executions, but 1 found. Tune coverage ZONE") fun testInvokeAnotherThrowExceptionMethod() { checkDiscoveredProperties( VoidStaticMethodsTestingClass::invokeAnotherThrowExceptionMethod, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/deepequals/DeepEqualsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/deepequals/DeepEqualsTest.kt index f31b8294d6..f282e34d58 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/deepequals/DeepEqualsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/deepequals/DeepEqualsTest.kt @@ -50,7 +50,7 @@ class DeepEqualsTest : JavaMethodTestRunner() { } @Test - @Disabled("We do not support 2d generics containers right now") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@5927f2b1") fun testReturn2DList() { checkDiscoveredProperties( DeepEqualsTestingClass::return2DList, @@ -59,7 +59,6 @@ class DeepEqualsTest : JavaMethodTestRunner() { } @Test - @Disabled("We do not support 2d generics containers right now") fun testReturn2DSet() { checkDiscoveredProperties( DeepEqualsTestingClass::return2DSet, @@ -68,7 +67,7 @@ class DeepEqualsTest : JavaMethodTestRunner() { } @Test - @Disabled("We do not support 2d generics containers right now") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@5927f2b1") fun testReturn2DMap() { checkDiscoveredProperties( DeepEqualsTestingClass::return2DMap, @@ -77,7 +76,7 @@ class DeepEqualsTest : JavaMethodTestRunner() { } @Test - @Disabled("We do not support 2d generics containers right now") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@5927f2b1") fun testIntegers2DList() { checkDiscoveredProperties( DeepEqualsTestingClass::returnIntegers2DList, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListIteratorsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListIteratorsTest.kt index 57d3faa9d4..cbf2b4be64 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListIteratorsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListIteratorsTest.kt @@ -66,7 +66,6 @@ internal class ListIteratorsTest : JavaMethodTestRunner() { } @Test - @Disabled("Java 11 transition") fun testAddElements() { checkDiscoveredProperties( ListIterators::addElements, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListsPart3Test.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListsPart3Test.kt index 2dac793cef..7d34a2a7d8 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListsPart3Test.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListsPart3Test.kt @@ -208,7 +208,6 @@ internal class ListsPart3Test : JavaMethodTestRunner() { } @Test - @Disabled("TODO: add choosing proper type in list wrapper") fun testRemoveFromList() { checkDiscoveredPropertiesWithExceptions( Lists::removeFromList, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/QueueUsagesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/QueueUsagesTest.kt index c15d674d78..18c9ee5318 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/QueueUsagesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/QueueUsagesTest.kt @@ -96,7 +96,6 @@ class QueueUsagesTest : JavaMethodTestRunner() { } @Test - @Disabled("TODO: Related to https://github.com/UnitTestBot/UTBotJava/issues/820") fun testCheckSubtypesOfQueueWithUsage() { checkDiscoveredProperties( QueueUsages::checkSubtypesOfQueueWithUsage, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/SetsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/SetsTest.kt index 2ee502e84e..d8c3cf8c3f 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/SetsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/collections/SetsTest.kt @@ -34,7 +34,6 @@ internal class SetsTest : JavaMethodTestRunner() { } @Test - @Disabled("Does not find positive branches JIRA:1529") fun testSetContains() { checkDiscoveredProperties( Sets::setContains, @@ -54,7 +53,6 @@ internal class SetsTest : JavaMethodTestRunner() { } @Test - @Disabled("Same problem from testSetContains JIRA:1529") fun testMoreComplicatedContains() { checkDiscoveredProperties( Sets::moreComplicatedContains, // TODO how many branches do we have? diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/ConditionsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/ConditionsTest.kt index 7c30ec62d3..95b888960d 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/ConditionsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/ConditionsTest.kt @@ -19,7 +19,6 @@ internal class ConditionsTest : JavaMethodTestRunner() { } @Test - @Disabled("java.lang.IndexOutOfBoundsException: Index: 1, Size: 1") fun testIfLastStatement() { checkDiscoveredPropertiesWithExceptions( Conditions::emptyBranches, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/CyclesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/CyclesTest.kt index 47a1b2e2f4..1d440587aa 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/CyclesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/CyclesTest.kt @@ -72,7 +72,7 @@ internal class CyclesTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [0]") + @Disabled("Some properties were not discovered at positions (from 0): [0]. Tune coverage zone") fun testCallInnerWhile() { checkDiscoveredProperties( Cycles::callInnerWhile, @@ -107,11 +107,10 @@ internal class CyclesTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 3 executions, but 32 found. Same exception discovered multiple times") fun moveToExceptionTest() { checkDiscoveredPropertiesWithExceptions( Cycles::moveToException, - eq(3), + /*eq(3)*/ignoreNumberOfAnalysisResults, // TODO minimization { _, x, r -> x < 400 && r.isException<IllegalArgumentException>() }, { _, x, r -> x > 400 && r.isException<IllegalArgumentException>() }, { _, x, r -> x == 400 && r.isException<IllegalArgumentException>() }, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/SwitchTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/SwitchTest.kt index 03c057354c..28fcaf31ab 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/SwitchTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/controlflow/SwitchTest.kt @@ -14,7 +14,7 @@ import java.math.RoundingMode.HALF_UP internal class SwitchTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@2e7563f6") + @Disabled("An operation is not implemented: Not yet implemented") fun testSimpleSwitch() { checkDiscoveredProperties( Switch::simpleSwitch, @@ -27,7 +27,7 @@ internal class SwitchTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@2e7563f6") + @Disabled("An operation is not implemented: Not yet implemented") fun testLookupSwitch() { checkDiscoveredProperties( Switch::lookupSwitch, @@ -40,7 +40,7 @@ internal class SwitchTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@2e7563f6") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3e4141cf") fun testEnumSwitch() { checkDiscoveredProperties( Switch::enumSwitch, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ClassWithEnumTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ClassWithEnumTest.kt index 1e0037659b..8c895607c4 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ClassWithEnumTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ClassWithEnumTest.kt @@ -23,7 +23,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { // } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testGetter() { checkDiscoveredProperties( ClassWithEnum::useGetter, @@ -45,7 +45,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { } @Test - @Disabled("org.usvm.samples.enums.ClassWithEnum.ClassWithEnum\$StatusEnum") + @Disabled("Some properties were not discovered at positions (from 0): [1]. Support enums") fun testNullParameter() { checkDiscoveredProperties( ClassWithEnum::nullEnumAsParameter, @@ -56,7 +56,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testNullField() { checkDiscoveredPropertiesWithExceptions( ClassWithEnum::nullField, @@ -67,9 +67,8 @@ class ClassWithEnumTest : JavaMethodTestRunner() { ) } - @Suppress("KotlinConstantConditions") @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testChangeEnum() { checkDiscoveredPropertiesWithExceptions( ClassWithEnum::changeEnum, @@ -80,7 +79,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testChangeMutableField() { checkDiscoveredPropertiesWithExceptions( ClassWithEnum::changeMutableField, @@ -91,7 +90,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testCheckName() { checkDiscoveredProperties( ClassWithEnum::checkName, @@ -150,7 +149,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { // } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@579caf9c") fun testFromCode() { checkDiscoveredProperties( StatusEnum::fromCode, @@ -162,7 +161,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testFromIsReady() { checkDiscoveredProperties( StatusEnum::fromIsReady, @@ -195,7 +194,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testAffectSystemStaticAndUseInitEnumFromIt() { checkDiscoveredProperties( ClassWithEnum::affectSystemStaticAndInitEnumFromItAndReturnField, @@ -205,7 +204,7 @@ class ClassWithEnumTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@7fbde9f0") fun testAffectSystemStaticAndInitEnumFromItAndGetItFromEnumFun() { checkDiscoveredProperties( ClassWithEnum::affectSystemStaticAndInitEnumFromItAndGetItFromEnumFun, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ComplexEnumExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ComplexEnumExamplesTest.kt index 63f1c76440..5a6b9a64c0 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ComplexEnumExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/enums/ComplexEnumExamplesTest.kt @@ -51,7 +51,7 @@ class ComplexEnumExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("org.usvm.samples.enums.ComplexEnumExamples.ComplexEnumExamples\$Color") + @Disabled("Some properties were not discovered at positions (from 0): [0]") fun testCountEqualColors() { checkDiscoveredProperties( ComplexEnumExamples::countEqualColors, @@ -63,7 +63,7 @@ class ComplexEnumExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("org.usvm.samples.enums.ComplexEnumExamples.ComplexEnumExamples\$Color") + @Disabled("Some properties were not discovered at positions (from 0): [0]") fun testCountNullColors() { checkDiscoveredProperties( ComplexEnumExamples::countNullColors, @@ -75,7 +75,7 @@ class ComplexEnumExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testFindState() { checkDiscoveredProperties( ComplexEnumExamples::findState, @@ -85,7 +85,7 @@ class ComplexEnumExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testCountValuesInArray() { fun Color.isCorrectlyCounted(inputs: Array<Color>, counts: Map<Color, Int>): Boolean = inputs.count { it == this } == (counts[this] ?: 0) @@ -100,7 +100,7 @@ class ComplexEnumExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1b0e9707") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testCountRedInArray() { checkDiscoveredProperties( ComplexEnumExamples::countRedInArray, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/ExceptionExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/ExceptionExamplesTest.kt index bb2dd9dc89..20f3b04240 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/ExceptionExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/ExceptionExamplesTest.kt @@ -10,7 +10,6 @@ import org.usvm.util.isException @Disabled("Unsupported") internal class ExceptionExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Sequence has more than one element.") fun testInitAnArray() { checkDiscoveredProperties( ExceptionExamples::initAnArray, @@ -99,7 +98,6 @@ internal class ExceptionExamplesTest : JavaMethodTestRunner() { * Covers [#656](https://github.com/UnitTestBot/UTBotJava/issues/656). */ @Test - @Disabled("Sequence has more than one element.") fun testCatchExceptionAfterOtherPossibleException() { checkDiscoveredPropertiesWithExceptions( ExceptionExamples::catchExceptionAfterOtherPossibleException, @@ -114,7 +112,6 @@ internal class ExceptionExamplesTest : JavaMethodTestRunner() { * Used for path generation check in [org.utbot.engine.Traverser.fullPath] */ @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testDontCatchDeepNestedThrow() { checkDiscoveredPropertiesWithExceptions( ExceptionExamples::dontCatchDeepNestedThrow, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/JvmCrashExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/JvmCrashExamplesTest.kt index 1764fd93ad..d9d1aecc26 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/JvmCrashExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/exceptions/JvmCrashExamplesTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class JvmCrashExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("JIRA:1527") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@27975320") fun testExit() { checkDiscoveredProperties( JvmCrashExamples::exit, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/InvokeExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/InvokeExampleTest.kt index 9df8ffa643..f61a6ddeab 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/InvokeExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/InvokeExampleTest.kt @@ -10,7 +10,7 @@ import org.usvm.util.isException internal class InvokeExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Expected exactly 3 executions, but 5 found. Same exception discovered multiple times") + @Disabled("Disjunction in if statement covered by only one execution") fun testSimpleFormula() { checkDiscoveredProperties( InvokeExample::simpleFormula, @@ -22,7 +22,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testChangeObjectValueByMethod() { checkDiscoveredProperties( InvokeExample::changeObjectValueByMethod, @@ -33,7 +32,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testParticularValue() { checkDiscoveredProperties( InvokeExample::particularValue, @@ -55,7 +53,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testGetNullOrValue() { checkDiscoveredProperties( InvokeExample::getNullOrValue, @@ -68,7 +65,7 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Some properties were not discovered at positions (from 0): [1, 2]") + @Disabled("Expected exactly 3 executions, but 1 found. Tune coverage zone") fun testConstraintsFromOutside() { checkDiscoveredProperties( InvokeExample::constraintsFromOutside, @@ -81,7 +78,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { @Test -// @Disabled("Expected exactly 3 executions, but 2 found") fun testConstraintsFromInside() { checkDiscoveredProperties( InvokeExample::constraintsFromInside, @@ -93,7 +89,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testAlwaysNPE() { checkDiscoveredPropertiesWithExceptions( InvokeExample::alwaysNPE, @@ -109,7 +104,7 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 3 executions, but 5 found. Same exception discovered multiple times") + @Disabled("Expected exactly 3 executions, but 2 found. Tune coverage zone") fun testExceptionInNestedMethod() { checkDiscoveredPropertiesWithExceptions( InvokeExample::exceptionInNestedMethod, @@ -121,7 +116,7 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") + @Disabled("Some properties were not discovered at positions (from 0): [1, 2, 3]. Tune coverage zone") fun testFewNestedExceptions() { checkDiscoveredPropertiesWithExceptions( InvokeExample::fewNestedException, @@ -135,7 +130,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 4 executions, but 7 found. Same exception discovered multiple times") fun testDivBy() { checkDiscoveredPropertiesWithExceptions( InvokeExample::divBy, @@ -148,7 +142,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testUpdateValue() { checkDiscoveredProperties( InvokeExample::updateValue, @@ -172,7 +165,7 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 3 executions, but 4 found. Same exception discovered multiple times") + @Disabled("Expected exactly 3 executions, but 2 found. Tune coverage zone") fun testChangeArrayWithAssignFromMethod() { checkDiscoveredProperties( InvokeExample::changeArrayWithAssignFromMethod, @@ -187,7 +180,7 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") + @Disabled("Some properties were not discovered at positions (from 0): [1]. Tune coverage zone") fun testChangeArrayByMethod() { checkDiscoveredProperties( InvokeExample::changeArrayByMethod, @@ -198,7 +191,7 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") + @Disabled("Some properties were not discovered at positions (from 0): [3]. Tune coverage zone") fun testArrayCopyExample() { checkDiscoveredProperties( InvokeExample::arrayCopyExample, @@ -212,7 +205,6 @@ internal class InvokeExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testUpdateValues() { checkDiscoveredProperties( InvokeExample::updateValues, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/SimpleInterfaceExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/SimpleInterfaceExampleTest.kt index 69135fcdcc..6235a6615c 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/SimpleInterfaceExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/SimpleInterfaceExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class SimpleInterfaceExampleTest : JavaMethodTestRunner() { @Test - @Disabled("java.lang.InstantiationException: org.usvm.samples.invokes.SimpleInterface") + @Disabled("Expected exactly 3 executions, but 2 found. Virtual invokes are not supported yet") fun testOverrideMethod() { checkDiscoveredProperties( SimpleInterfaceExample::overrideMethod, @@ -20,7 +20,6 @@ internal class SimpleInterfaceExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("java.lang.InstantiationException: org.usvm.samples.invokes.SimpleInterface") fun testDefaultMethod() { checkDiscoveredProperties( SimpleInterfaceExample::defaultMethod, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/CustomPredicateExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/CustomPredicateExampleTest.kt index e69787e821..81784058b1 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/CustomPredicateExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/CustomPredicateExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.util.isException class CustomPredicateExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@4640195a") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testNoCapturedValuesPredicateCheck() { checkDiscoveredPropertiesWithExceptions( CustomPredicateExample::noCapturedValuesPredicateCheck, @@ -20,7 +20,7 @@ class CustomPredicateExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@4640195a") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testCapturedLocalVariablePredicateCheck() { checkDiscoveredPropertiesWithExceptions( CustomPredicateExample::capturedLocalVariablePredicateCheck, @@ -32,7 +32,7 @@ class CustomPredicateExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@4640195a") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testCapturedParameterPredicateCheck() { checkDiscoveredPropertiesWithExceptions( CustomPredicateExample::capturedParameterPredicateCheck, @@ -44,7 +44,7 @@ class CustomPredicateExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@4640195a") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testCapturedStaticFieldPredicateCheck() { checkDiscoveredPropertiesWithExceptions( CustomPredicateExample::capturedStaticFieldPredicateCheck, @@ -56,7 +56,7 @@ class CustomPredicateExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@4640195a") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testCapturedNonStaticFieldPredicateCheck() { checkDiscoveredPropertiesWithExceptions( CustomPredicateExample::capturedNonStaticFieldPredicateCheck, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/PredicateNotExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/PredicateNotExampleTest.kt index 908bbabcb8..701531b8e0 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/PredicateNotExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/PredicateNotExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq class PredicateNotExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@4640195a") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testPredicateNotExample() { checkDiscoveredProperties( PredicateNotExample::predicateNotExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/SimpleLambdaExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/SimpleLambdaExamplesTest.kt index 6372f8d122..d647d3e62c 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/SimpleLambdaExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/SimpleLambdaExamplesTest.kt @@ -8,7 +8,7 @@ import org.usvm.util.isException class SimpleLambdaExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4") + @Disabled("Index 4 out of bounds for length 4") fun testBiFunctionLambdaExample() { checkDiscoveredPropertiesWithExceptions( SimpleLambdaExamples::biFunctionLambdaExample, @@ -19,7 +19,7 @@ class SimpleLambdaExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1") + @Disabled("Index 1 out of bounds for length 1") fun testChoosePredicate() { checkDiscoveredProperties( SimpleLambdaExamples::choosePredicate, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/ThrowingWithLambdaExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/ThrowingWithLambdaExampleTest.kt index a0d8c1fdde..f24dcc0302 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/ThrowingWithLambdaExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/ThrowingWithLambdaExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq class ThrowingWithLambdaExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Sequence is empty.") + @Disabled("Support assumptions") fun testAnyExample() { checkDiscoveredProperties( ThrowingWithLambdaExample::anyExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/loops/TestWhile.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/loops/TestWhile.kt index 41be1769e7..0ab7d93f5a 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/loops/TestWhile.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/loops/TestWhile.kt @@ -41,8 +41,7 @@ class TestWhile : JavaMethodTestRunner() { ) } - @RepeatedTest(5) -// @Disabled("Some properties were not discovered at positions (from 0): [0]") + @Test fun `Test while1000`() { checkDiscoveredProperties( While::while1000, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DivRemExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DivRemExamplesTest.kt index 36e7669ac7..081393ff86 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DivRemExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DivRemExamplesTest.kt @@ -51,7 +51,6 @@ internal class DivRemExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [3]") fun testRemWithConditions() { checkDiscoveredPropertiesWithExceptions( DivRemExamples::remWithConditions, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DoubleFunctionsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DoubleFunctionsTest.kt index 99e61ead9f..e1a41b6b01 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DoubleFunctionsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/math/DoubleFunctionsTest.kt @@ -32,7 +32,7 @@ internal class DoubleFunctionsTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 5 executions, but 8 found. Same exception discovered multiple times") + @Disabled("Expected exactly 5 executions, but 1 found. Fix floats and doubles") fun testCircleSquare() { checkDiscoveredPropertiesWithExceptions( DoubleFunctions::circleSquare, @@ -46,7 +46,7 @@ internal class DoubleFunctionsTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") + @Disabled("No analysis results received") fun testNumberOfRootsInSquareFunction() { checkDiscoveredProperties( DoubleFunctions::numberOfRootsInSquareFunction, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/OverloadTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/OverloadTest.kt index 821d4ad17d..870e7c6123 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/OverloadTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/OverloadTest.kt @@ -1,6 +1,5 @@ package org.usvm.samples.mixed -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner import org.usvm.test.util.checkers.eq @@ -19,10 +18,9 @@ internal class OverloadTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [0, 1, 2]") fun testSignTwoParams() { checkDiscoveredProperties( - Overload::sign, + Overload::signBinary, eq(3), { _, x, y, r -> x + y < 0 && r == -1 }, { _, x, y, r -> x + y == 0 && r == 0 }, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/SimplifierTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/SimplifierTest.kt index de590f86f1..fd2488c8f1 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/SimplifierTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/SimplifierTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class SimplifierTest: JavaMethodTestRunner() { @Test - @Disabled("Wait for assume") + @Disabled("Support assumptions") fun testSimplifyAdditionWithZero() { checkDiscoveredProperties( Simplifier::simplifyAdditionWithZero, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/mock/aliasing/AliasingInParamsExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/mock/aliasing/AliasingInParamsExampleTest.kt index dab32e82cb..a9abcacac2 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/mock/aliasing/AliasingInParamsExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/mock/aliasing/AliasingInParamsExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class AliasingInParamsExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Sort mismatch") + @Disabled("Sequence is empty.") fun testExamplePackageBased() { checkDiscoveredProperties( AliasingInParamsExample::example, @@ -18,7 +18,7 @@ internal class AliasingInParamsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") + @Disabled("Sequence is empty.") fun testExample() { checkDiscoveredProperties( AliasingInParamsExample::example, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/natives/NativeExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/natives/NativeExamplesTest.kt index 4bbdb31078..e3ceeb7a12 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/natives/NativeExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/natives/NativeExamplesTest.kt @@ -10,7 +10,7 @@ import org.usvm.test.util.checkers.ge internal class NativeExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@6ba88a47") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testFindAndPrintSum() { checkDiscoveredProperties( NativeExamples::findAndPrintSum, @@ -19,7 +19,7 @@ internal class NativeExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@53b2e5") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testFindSumWithMathRandom() { checkDiscoveredProperties( NativeExamples::findSumWithMathRandom, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/numbers/ArithmeticUtilsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/numbers/ArithmeticUtilsTest.kt index fefcc4289a..645afa16d7 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/numbers/ArithmeticUtilsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/numbers/ArithmeticUtilsTest.kt @@ -10,7 +10,7 @@ import org.usvm.test.util.checkers.eq // example from Apache common-numbers internal class ArithmeticUtilsTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testPow() { checkDiscoveredProperties( ArithmeticUtils::pow, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AbstractAnonymousClassTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AbstractAnonymousClassTest.kt index 7d05b8cda9..691294a299 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AbstractAnonymousClassTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AbstractAnonymousClassTest.kt @@ -9,7 +9,6 @@ import org.usvm.test.util.checkers.eq class AbstractAnonymousClassTest : JavaMethodTestRunner() { @Test - @Disabled("java.lang.InstantiationException: org.usvm.samples.objects.AbstractAnonymousClass") fun testNonOverriddenMethod() { checkDiscoveredProperties( AbstractAnonymousClass::methodWithoutOverrides, @@ -18,7 +17,7 @@ class AbstractAnonymousClassTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected exception type thrown ==> expected: <org.opentest4j.AssertionFailedError> but was: <java.lang.InstantiationException>") + @Disabled("Repeats UTBot behavior, see require(possibleTypesWithNonOverriddenMethod.isNotEmpty()) in Traverser") fun testOverriddenMethod() { // check we have error during execution assertThrows<org.opentest4j.AssertionFailedError> { diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AnonymousClassesExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AnonymousClassesExampleTest.kt index 0023d4d1b5..21bb92940b 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AnonymousClassesExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/AnonymousClassesExampleTest.kt @@ -33,7 +33,7 @@ class AnonymousClassesExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@69b66787") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testAnonymousClassAsStatic() { checkDiscoveredProperties( AnonymousClassesExample::anonymousClassAsStatic, @@ -43,7 +43,6 @@ class AnonymousClassesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("An operation is not implemented: Not yet implemented") fun testAnonymousClassAsResult() { checkDiscoveredProperties( AnonymousClassesExample::anonymousClassAsResult, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassForTestClinitSectionsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassForTestClinitSectionsTest.kt index ce5e4dc35d..a555cdf147 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassForTestClinitSectionsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassForTestClinitSectionsTest.kt @@ -21,7 +21,7 @@ internal class ClassForTestClinitSectionsTest : JavaMethodTestRunner() { // } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@7e0a7b9e") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testClinitWithClinitAnalysis() { checkDiscoveredProperties( ClassForTestClinitSections::resultDependingOnStaticSection, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassRefTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassRefTest.kt index 5712857713..cbc4833027 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassRefTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassRefTest.kt @@ -13,7 +13,7 @@ import kotlin.arrayOf internal class ClassRefTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@25bb5bf9") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testTakeBooleanClassRef() { checkDiscoveredProperties( ClassRef::takeBooleanClassRef, @@ -76,7 +76,7 @@ internal class ClassRefTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@25bb5bf9") + @Disabled("An operation is not implemented: Not yet implemented") fun testTakeConstantClassRef() { checkDiscoveredProperties( ClassRef::takeConstantClassRef, @@ -126,7 +126,7 @@ internal class ClassRefTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@77f76656") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testEqualityOnGenericClassRef() { checkDiscoveredProperties( ClassRef::equalityOnGenericClassRef, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldAccessModifiersTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldAccessModifiersTest.kt index 6d81681f25..f233b8412c 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldAccessModifiersTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldAccessModifiersTest.kt @@ -8,7 +8,6 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults internal class HiddenFieldAccessModifiersTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testCheckSuperFieldEqualsOne() { checkDiscoveredProperties( HiddenFieldAccessModifiersExample::checkSuperFieldEqualsOne, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldExampleTest.kt index 0fb32fefaa..2bbdc122c0 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class HiddenFieldExampleTest : JavaMethodTestRunner() { @Test - @Disabled("An operation is not implemented: Not yet implemented") + @Disabled("Support instanceof") fun testCheckHiddenField() { checkDiscoveredProperties( HiddenFieldExample::checkHiddenField, @@ -21,7 +21,6 @@ internal class HiddenFieldExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 5 executions, but 6 found. Same exception discovered multiple times") fun testCheckSuccField() { checkDiscoveredProperties( HiddenFieldExample::checkSuccField, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ModelMinimizationExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ModelMinimizationExamplesTest.kt index e275759580..e6de4a161e 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ModelMinimizationExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ModelMinimizationExamplesTest.kt @@ -45,7 +45,6 @@ internal class ModelMinimizationExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun conditionCheckAEqTest() { // Parameters `a` and `b` should be not null. // Parameters `a` and `b` should refer to the same instance. diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesClassTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesClassTest.kt index f3999f844f..dc43279f65 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesClassTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesClassTest.kt @@ -20,7 +20,7 @@ internal class ObjectWithPrimitivesClassTest : JavaMethodTestRunner() { // } @Test - @Disabled("Required value was null. at org.usvm.samples.JavaMethodTestRunner\$runner\$1.invoke(JavaMethodTestRunner.kt:516)") + @Disabled("Support constructors in matchers") fun testConstructorWithParams() { val method: KFunction3<Int, Int, Double, ObjectWithPrimitivesClass> = ::ObjectWithPrimitivesClass checkDiscoveredProperties( diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesExampleTest.kt index 7a0c0fcc93..24ac3af5c4 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithPrimitivesExampleTest.kt @@ -10,7 +10,6 @@ import org.usvm.util.isException internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testMax() { checkDiscoveredPropertiesWithExceptions( ObjectWithPrimitivesExample::max, @@ -24,21 +23,24 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") + @Disabled("Some properties were not discovered at positions (from 0): [0]. Fix minimization") fun testIgnoredInputParameters() { checkDiscoveredProperties( ObjectWithPrimitivesExample::ignoredInputParameters, eq(1), - { _, fst, snd, r -> fst == null && snd == null && r != null } + { _, _, _, r -> + val instanceWithDefaultValues = ObjectWithPrimitivesClass() + + r == instanceWithDefaultValues + } ) } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testExample() { checkDiscoveredProperties( ObjectWithPrimitivesExample::example, - ignoreNumberOfAnalysisResults, + eq(3), { _, v, _ -> v == null }, { _, v, r -> v != null && v.x == 1 && r?.x == 1 }, { _, v, r -> v != null && v.x != 1 && r?.x == 1 }, @@ -56,7 +58,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Unsupported default values") fun testDefaultValueForSuperclassFields() { checkDiscoveredProperties( ObjectWithPrimitivesExample::defaultValueForSuperclassFields, @@ -66,7 +67,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("TODO JIRA:1594") fun testCreateObject() { checkDiscoveredPropertiesWithExceptions( ObjectWithPrimitivesExample::createObject, @@ -86,7 +86,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testMemory() { checkDiscoveredPropertiesWithExceptions( ObjectWithPrimitivesExample::memory, @@ -119,7 +118,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testCompareWithNull() { checkDiscoveredProperties( ObjectWithPrimitivesExample::compareWithNull, @@ -139,7 +137,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testNullExample() { checkDiscoveredProperties( ObjectWithPrimitivesExample::nullExample, @@ -152,7 +149,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 4 executions, but 6 found. Same exception discovered multiple times") fun testCompareTwoOuterObjects() { checkDiscoveredPropertiesWithExceptions( ObjectWithPrimitivesExample::compareTwoOuterObjects, @@ -165,7 +161,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testCompareObjectWithArgument() { checkDiscoveredProperties( ObjectWithPrimitivesExample::compareObjectWithArgument, @@ -183,7 +178,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testCompareTwoIdenticalObjectsFromArguments() { checkDiscoveredPropertiesWithExceptions( ObjectWithPrimitivesExample::compareTwoIdenticalObjectsFromArguments, @@ -204,7 +198,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testGetOrDefault() { checkDiscoveredPropertiesWithExceptions( ObjectWithPrimitivesExample::getOrDefault, @@ -217,7 +210,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testInheritorsFields() { checkDiscoveredPropertiesWithExceptions( ObjectWithPrimitivesExample::inheritorsFields, @@ -238,7 +230,6 @@ internal class ObjectWithPrimitivesExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [0]") fun testCreateWithSuperConstructor() { checkDiscoveredProperties( ObjectWithPrimitivesExample::createWithSuperConstructor, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithRefFieldsExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithRefFieldsExampleTest.kt index 63fa92c4e9..6336e79b5c 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithRefFieldsExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithRefFieldsExampleTest.kt @@ -19,7 +19,7 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") + @Disabled("Some properties were not discovered at positions (from 0): [2]. Fix branch coverage") fun testWriteToRefTypeField() { checkDiscoveredProperties( ObjectWithRefFieldExample::writeToRefTypeField, @@ -45,7 +45,6 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testReadFromRefTypeField() { checkDiscoveredProperties( ObjectWithRefFieldExample::readFromRefTypeField, @@ -58,7 +57,6 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 3 executions, but 129 found. Same exception discovered multiple times") fun testWriteToArrayField() { checkDiscoveredProperties( ObjectWithRefFieldExample::writeToArrayField, @@ -79,7 +77,6 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testReadFromArrayField() { checkDiscoveredProperties( ObjectWithRefFieldExample::readFromArrayField, @@ -92,7 +89,6 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { ) } - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testCompareTwoDifferentObjectsFromArguments() { checkDiscoveredProperties( ObjectWithRefFieldExample::compareTwoDifferentObjectsFromArguments, @@ -107,7 +103,6 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Failed requirement at org.usvm.UInputFieldReading.<init>(Expressions.kt:166)") fun testCompareTwoObjectsWithNullRefField() { checkDiscoveredPropertiesWithExceptions( ObjectWithRefFieldExample::compareTwoObjectsWithNullRefField, @@ -120,7 +115,6 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testCompareTwoObjectsWithDifferentRefField() { checkDiscoveredPropertiesWithExceptions( ObjectWithRefFieldExample::compareTwoObjectsWithDifferentRefField, @@ -133,10 +127,9 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [2, 3]") fun testCompareTwoObjectsWithTheDifferentRefField() { checkDiscoveredPropertiesWithExceptions( - ObjectWithRefFieldExample::compareTwoObjectsWithDifferentRefField, + ObjectWithRefFieldExample::compareTwoObjectsWithTheDifferentRefField, ignoreNumberOfAnalysisResults, { _, fst, _, r -> fst == null && r.isException<NullPointerException>() }, { _, fst, snd, r -> fst != null && snd == null && r.isException<NullPointerException>() }, @@ -146,7 +139,6 @@ internal class ObjectWithRefFieldsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testCompareTwoObjectsWithTheSameRefField() { checkDiscoveredPropertiesWithExceptions( ObjectWithRefFieldExample::compareTwoObjectsWithTheSameRefField, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithThrowableConstructorTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithThrowableConstructorTest.kt index 740e70dcea..1d6244ad37 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithThrowableConstructorTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithThrowableConstructorTest.kt @@ -9,7 +9,7 @@ import kotlin.reflect.KFunction2 internal class ObjectWithThrowableConstructorTest : JavaMethodTestRunner() { @Test - @Disabled("SAT-1500 Support verification of UtAssembleModel for possible exceptions") + @Disabled("Support constructors in matchers") fun testThrowableConstructor() { val method: KFunction2<Int, Int, ObjectWithThrowableConstructor> = ::ObjectWithThrowableConstructor checkDiscoveredProperties( diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/PrivateFieldsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/PrivateFieldsTest.kt index f517f27400..e527240e76 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/PrivateFieldsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/PrivateFieldsTest.kt @@ -8,7 +8,6 @@ import org.usvm.util.isException internal class PrivateFieldsTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testAccessWithGetter() { checkDiscoveredPropertiesWithExceptions( PrivateFields::accessWithGetter, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/RecursiveTypeTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/RecursiveTypeTest.kt index 39cd16b692..59242afcd8 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/RecursiveTypeTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/RecursiveTypeTest.kt @@ -8,7 +8,6 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults internal class RecursiveTypeTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun testNextValue() { checkDiscoveredProperties( RecursiveType::nextValue, @@ -22,7 +21,6 @@ internal class RecursiveTypeTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun testWriteObjectFieldTest() { checkDiscoveredProperties( RecursiveType::writeObjectField, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassExampleTest.kt index 784342d63b..d5c34a9b7d 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassExampleTest.kt @@ -9,7 +9,6 @@ import kotlin.test.Ignore internal class SimpleClassExampleTest : JavaMethodTestRunner() { - @Disabled("Some types don't match at positions (from 0): [1]. ") fun simpleConditionTest() { checkDiscoveredProperties( SimpleClassExample::simpleCondition, @@ -27,7 +26,6 @@ internal class SimpleClassExampleTest : JavaMethodTestRunner() { * @see multipleFieldAccessesTest */ @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun singleFieldAccessTest() { checkDiscoveredProperties( SimpleClassExample::singleFieldAccess, @@ -44,7 +42,6 @@ internal class SimpleClassExampleTest : JavaMethodTestRunner() { * that affects their number */ @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun multipleFieldAccessesTest() { checkDiscoveredProperties( SimpleClassExample::multipleFieldAccesses, @@ -57,7 +54,6 @@ internal class SimpleClassExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Some types don't match at positions (from 0): [1]. ") fun immutableFieldAccessTest() { checkDiscoveredPropertiesWithExceptions( SimpleClassExample::immutableFieldAccess, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassMultiInstanceExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassMultiInstanceExampleTest.kt index 2a3533a5d8..9495042ff3 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassMultiInstanceExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassMultiInstanceExampleTest.kt @@ -8,7 +8,6 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults internal class SimpleClassMultiInstanceExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Some types don't match at positions (from 0): [1, 2]. ") fun singleObjectChangeTest() { checkDiscoveredProperties( SimpleClassMultiInstanceExample::singleObjectChange, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/operators/TestOverflow.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/operators/TestOverflow.kt index e7571b60c6..2f5928a085 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/operators/TestOverflow.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/operators/TestOverflow.kt @@ -7,7 +7,6 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults class TestOverflow : JavaMethodTestRunner() { @Test - @Disabled("TODO: disabled due to JacoDB incorrect types of local variables") fun `Test shortOverflow`() { checkDiscoveredPropertiesWithExceptions( Overflow::shortOverflow, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/ByteExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/ByteExamplesTest.kt index c4a7dd2dff..0dae512157 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/ByteExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/ByteExamplesTest.kt @@ -1,6 +1,5 @@ package org.usvm.samples.primitives -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner import org.usvm.test.util.checkers.eq @@ -9,7 +8,6 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults internal class ByteExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Bytes are unsupported") fun testNegByte() { checkDiscoveredProperties( ByteExamples::negByte, @@ -30,7 +28,6 @@ internal class ByteExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Bytes are unsupported") fun testSumTwoBytes() { checkDiscoveredProperties( ByteExamples::sumTwoBytes, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/CharExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/CharExamplesTest.kt index 8e17130772..861c54b03e 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/CharExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/CharExamplesTest.kt @@ -8,7 +8,6 @@ import org.usvm.util.isException internal class CharExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Sort mismatch") fun testCharDiv() { checkDiscoveredPropertiesWithExceptions( CharExamples::charDiv, @@ -19,7 +18,6 @@ internal class CharExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 2 executions, but 1 found") fun testCharNeg() { checkDiscoveredProperties( CharExamples::charNeg, @@ -44,7 +42,6 @@ internal class CharExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 3 executions, but 4 found. Same exception discovered multiple times") fun testUpdateObject() { checkDiscoveredPropertiesWithExceptions( CharExamples::updateObject, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/DoubleExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/DoubleExamplesTest.kt index 046e9da1cc..c6b7d2acee 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/DoubleExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/DoubleExamplesTest.kt @@ -1,7 +1,6 @@ package org.usvm.samples.primitives import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.RepeatedTest import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner import org.usvm.test.util.checkers.eq @@ -31,7 +30,6 @@ internal class DoubleExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 2 executions, but 0 found. Timeout") fun testCompareWithDiv() { checkDiscoveredProperties( DoubleExamples::compareWithDiv, @@ -64,7 +62,7 @@ internal class DoubleExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Some properties were not discovered at positions (from 0): [1]. Timeout") + @Disabled("Not enough time") fun testSimpleMul() { checkDiscoveredProperties( DoubleExamples::simpleMul, @@ -76,7 +74,7 @@ internal class DoubleExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 6 executions, but 3 found. Timeout") + @Disabled("Not enough time") fun testMul() { checkDiscoveredProperties( DoubleExamples::mul, @@ -120,6 +118,7 @@ internal class DoubleExamplesTest : JavaMethodTestRunner() { } @Test + @Disabled("Not enough time") fun testSimpleNonLinearEquation() { checkDiscoveredProperties( DoubleExamples::simpleNonLinearEquation, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/IntExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/IntExamplesTest.kt index f30dc1d6b4..9c75f7ff1e 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/IntExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/IntExamplesTest.kt @@ -10,7 +10,7 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults @Suppress("ConvertTwoComparisonsToRangeCheck") internal class IntExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: String constants") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testIsInteger() { val method = IntExamples::isInteger checkDiscoveredProperties( diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/psbenchmarks/TestLoanExam.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/psbenchmarks/TestLoanExam.kt index b13502ea13..f382048ace 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/psbenchmarks/TestLoanExam.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/psbenchmarks/TestLoanExam.kt @@ -1,6 +1,10 @@ package org.usvm.samples.psbenchmarks -import org.usvm.* +import org.usvm.CoverageZone +import org.usvm.PathSelectionStrategy +import org.usvm.PathSelectorCombinationStrategy +import org.usvm.SolverType +import org.usvm.UMachineOptions import org.usvm.samples.JavaMethodTestRunner import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults import org.usvm.util.Options diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/recursion/RecursionTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/recursion/RecursionTest.kt index a50a594de4..a4f0826fc1 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/recursion/RecursionTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/recursion/RecursionTest.kt @@ -55,7 +55,6 @@ internal class RecursionTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 4 executions, but 5 found. Same exception discovered multiple times") fun testPow() { checkDiscoveredPropertiesWithExceptions( Recursion::pow, @@ -68,7 +67,7 @@ internal class RecursionTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 2 executions, but 28 found. Same exception discovered multiple times") + @Disabled("Expected exactly 2 executions, but 54 found. Fix minimization") fun infiniteRecursionTest() { checkDiscoveredPropertiesWithExceptions( Recursion::infiniteRecursion, @@ -79,7 +78,7 @@ internal class RecursionTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@4640195a") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun vertexSumTest() { checkDiscoveredProperties( Recursion::vertexSum, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/reflection/NewInstanceExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/reflection/NewInstanceExampleTest.kt index 46cf9b3e7b..550db8a566 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/reflection/NewInstanceExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/reflection/NewInstanceExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq class NewInstanceExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testNewInstanceExample() { checkDiscoveredProperties( NewInstanceExample::createWithReflectionExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/DateExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/DateExampleTest.kt index 10cd218c65..ce4ecb3182 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/DateExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/DateExampleTest.kt @@ -39,7 +39,7 @@ class DateExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Virtual call: sun.util.calendar.BaseCalendar.Date.getNormalizedYear") + @Disabled("Sequence is empty.") fun testGetTimeWithoutReflection() { checkDiscoveredPropertiesWithExceptions( DateExample::getTime, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/StaticsPathDiversionTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/StaticsPathDiversionTest.kt index 56380948ab..76cfa905c6 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/StaticsPathDiversionTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/stdlib/StaticsPathDiversionTest.kt @@ -9,7 +9,7 @@ import java.io.File internal class StaticsPathDiversionTest : JavaMethodTestRunner() { @Test - @Disabled("See https://github.com/UnitTestBot/UTBotJava/issues/716") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testJavaIOFile() { // TODO Here we have a path diversion example - the static field `java.io.File#separator` is considered as not meaningful, // so it is not passed to the concrete execution because of absence in the `stateBefore` models. diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/BaseStreamExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/BaseStreamExampleTest.kt index c51576fcc5..a6b21c49c3 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/BaseStreamExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/BaseStreamExampleTest.kt @@ -12,9 +12,9 @@ import java.util.Optional import java.util.stream.Collectors import java.util.stream.Stream +@Disabled("Still too complex") class BaseStreamExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Expected exactly 1 executions, but 3 found") fun testReturningStreamAsParameterExample() { checkDiscoveredProperties( BaseStreamExample::returningStreamAsParameterExample, @@ -24,7 +24,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFilterExample() { checkDiscoveredProperties( BaseStreamExample::filterExample, @@ -35,7 +34,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::mapExample, @@ -82,7 +80,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFlatMapExample() { checkDiscoveredProperties( BaseStreamExample::flatMapExample, @@ -103,7 +100,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFlatMapToLongExample() { checkDiscoveredProperties( BaseStreamExample::flatMapToLongExample, @@ -113,7 +109,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFlatMapToDoubleExample() { checkDiscoveredProperties( BaseStreamExample::flatMapToDoubleExample, @@ -159,7 +154,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testLimitExample() { checkDiscoveredProperties( BaseStreamExample::limitExample, @@ -170,7 +164,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testSkipExample() { checkDiscoveredProperties( BaseStreamExample::skipExample, @@ -191,7 +184,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testToArrayExample() { checkDiscoveredProperties( BaseStreamExample::toArrayExample, @@ -201,7 +193,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testReduceExample() { checkDiscoveredProperties( BaseStreamExample::reduceExample, @@ -212,7 +203,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testOptionalReduceExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::optionalReduceExample, @@ -224,7 +214,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 4 out of bounds for length 4") fun testComplexReduceExample() { checkDiscoveredProperties( BaseStreamExample::complexReduceExample, @@ -235,7 +224,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("TODO zero executions https://github.com/UnitTestBot/UTBotJava/issues/207") fun testCollectorExample() { checkDiscoveredProperties( BaseStreamExample::collectorExample, @@ -245,7 +233,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testCollectExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::collectExample, @@ -256,7 +243,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMinExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::minExample, @@ -268,7 +254,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMaxExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::maxExample, @@ -280,7 +265,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testCountExample() { checkDiscoveredProperties( BaseStreamExample::countExample, @@ -291,7 +275,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testAnyMatchExample() { checkDiscoveredProperties( BaseStreamExample::anyMatchExample, @@ -305,7 +288,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testAllMatchExample() { checkDiscoveredProperties( BaseStreamExample::allMatchExample, @@ -319,7 +301,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testNoneMatchExample() { checkDiscoveredProperties( BaseStreamExample::noneMatchExample, @@ -333,7 +314,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFindFirstExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::findFirstExample, @@ -345,7 +325,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testIteratorExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::iteratorSumExample, @@ -357,7 +336,7 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStreamOfExample() { checkDiscoveredProperties( BaseStreamExample::streamOfExample, @@ -369,7 +348,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testClosedStreamExample() { checkDiscoveredPropertiesWithExceptions( BaseStreamExample::closedStreamExample, @@ -379,7 +357,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testCustomCollectionStreamExample() { checkDiscoveredProperties( BaseStreamExample::customCollectionStreamExample, @@ -390,7 +367,6 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testAnyCollectionStreamExample() { checkDiscoveredProperties( BaseStreamExample::anyCollectionStreamExample, @@ -401,7 +377,7 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testGenerateExample() { checkDiscoveredProperties( BaseStreamExample::generateExample, @@ -411,7 +387,7 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testIterateExample() { checkDiscoveredProperties( BaseStreamExample::iterateExample, @@ -421,7 +397,7 @@ class BaseStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testConcatExample() { checkDiscoveredProperties( BaseStreamExample::concatExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/DoubleStreamExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/DoubleStreamExampleTest.kt index a3662bbf56..757ef1c926 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/DoubleStreamExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/DoubleStreamExampleTest.kt @@ -13,9 +13,9 @@ import java.util.OptionalDouble import java.util.stream.DoubleStream import kotlin.streams.toList +@Disabled("Still too complex") class DoubleStreamExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Expected exactly 1 executions, but 3 found") fun testReturningStreamAsParameterExample() { checkDiscoveredProperties( DoubleStreamExample::returningStreamAsParameterExample, @@ -25,7 +25,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testUseParameterStream() { checkDiscoveredProperties( DoubleStreamExample::useParameterStream, @@ -40,7 +39,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFilterExample() { checkDiscoveredProperties( DoubleStreamExample::filterExample, @@ -51,7 +49,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapExample() { checkDiscoveredProperties( DoubleStreamExample::mapExample, @@ -62,7 +59,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToObjExample() { checkDiscoveredProperties( DoubleStreamExample::mapToObjExample, @@ -83,7 +79,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToIntExample() { checkDiscoveredProperties( DoubleStreamExample::mapToIntExample, @@ -102,7 +97,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToLongExample() { checkDiscoveredProperties( DoubleStreamExample::mapToLongExample, @@ -121,7 +115,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFlatMapExample() { checkDiscoveredProperties( DoubleStreamExample::flatMapExample, @@ -137,7 +130,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testDistinctExample() { checkDiscoveredProperties( DoubleStreamExample::distinctExample, @@ -180,7 +172,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { */ @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testLimitExample() { checkDiscoveredProperties( DoubleStreamExample::limitExample, @@ -191,7 +182,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testSkipExample() { checkDiscoveredProperties( DoubleStreamExample::skipExample, @@ -212,7 +202,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testToArrayExample() { checkDiscoveredProperties( DoubleStreamExample::toArrayExample, @@ -222,7 +211,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testReduceExample() { checkDiscoveredProperties( DoubleStreamExample::reduceExample, @@ -233,7 +221,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testOptionalReduceExample() { checkDiscoveredPropertiesWithExceptions( DoubleStreamExample::optionalReduceExample, @@ -248,7 +235,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testSumExample() { checkDiscoveredProperties( DoubleStreamExample::sumExample, @@ -259,7 +245,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMinExample() { checkDiscoveredPropertiesWithExceptions( DoubleStreamExample::minExample, @@ -272,7 +257,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMaxExample() { checkDiscoveredPropertiesWithExceptions( DoubleStreamExample::maxExample, @@ -285,7 +269,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testCountExample() { checkDiscoveredProperties( DoubleStreamExample::countExample, @@ -296,7 +279,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testAverageExample() { checkDiscoveredProperties( DoubleStreamExample::averageExample, @@ -307,7 +289,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testSummaryStatisticsExample() { checkDiscoveredProperties( DoubleStreamExample::summaryStatisticsExample, @@ -344,7 +325,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 2 out of bounds for length 2") fun testAnyMatchExample() { // TODO exceeds even default step limit 3500 => too slow checkDiscoveredProperties( @@ -371,7 +351,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 2 out of bounds for length 2") fun testAllMatchExample() { checkDiscoveredProperties( DoubleStreamExample::allMatchExample, @@ -397,7 +376,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 2 out of bounds for length 2") fun testNoneMatchExample() { checkDiscoveredProperties( DoubleStreamExample::noneMatchExample, @@ -423,7 +401,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testFindFirstExample() { checkDiscoveredProperties( DoubleStreamExample::findFirstExample, @@ -434,7 +411,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testBoxedExample() { checkDiscoveredProperties( DoubleStreamExample::boxedExample, @@ -444,7 +420,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testIteratorExample() { checkDiscoveredProperties( DoubleStreamExample::iteratorSumExample, @@ -455,7 +430,7 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStreamOfExample() { checkDiscoveredProperties( DoubleStreamExample::streamOfExample, @@ -467,7 +442,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testClosedStreamExample() { checkDiscoveredPropertiesWithExceptions( DoubleStreamExample::closedStreamExample, @@ -477,7 +451,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testGenerateExample() { checkDiscoveredProperties( DoubleStreamExample::generateExample, @@ -487,7 +460,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testIterateExample() { checkDiscoveredProperties( DoubleStreamExample::iterateExample, @@ -497,7 +469,6 @@ class DoubleStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testConcatExample() { checkDiscoveredProperties( DoubleStreamExample::concatExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/IntStreamExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/IntStreamExampleTest.kt index 85cadb5f97..95733d0c87 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/IntStreamExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/IntStreamExampleTest.kt @@ -13,9 +13,9 @@ import java.util.OptionalInt import java.util.stream.IntStream import kotlin.streams.toList +@Disabled("Still too complex") class IntStreamExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Expected exactly 1 executions, but 3 found") fun testReturningStreamAsParameterExample() { checkDiscoveredProperties( IntStreamExample::returningStreamAsParameterExample, @@ -25,7 +25,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testUseParameterStream() { checkDiscoveredProperties( IntStreamExample::useParameterStream, @@ -40,7 +39,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFilterExample() { checkDiscoveredProperties( IntStreamExample::filterExample, @@ -51,7 +49,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapExample() { checkDiscoveredProperties( IntStreamExample::mapExample, @@ -62,7 +59,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToObjExample() { checkDiscoveredProperties( IntStreamExample::mapToObjExample, @@ -81,7 +77,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToLongExample() { checkDiscoveredProperties( IntStreamExample::mapToLongExample, @@ -100,7 +95,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToDoubleExample() { checkDiscoveredProperties( IntStreamExample::mapToDoubleExample, @@ -119,7 +113,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFlatMapExample() { checkDiscoveredProperties( IntStreamExample::flatMapExample, @@ -135,7 +128,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testDistinctExample() { checkDiscoveredProperties( IntStreamExample::distinctExample, @@ -154,7 +146,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") @Tag("slow") // TODO slow sorting https://github.com/UnitTestBot/UTBotJava/issues/188 fun testSortedExample() { @@ -176,7 +167,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testLimitExample() { checkDiscoveredProperties( IntStreamExample::limitExample, @@ -187,7 +177,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testSkipExample() { checkDiscoveredProperties( IntStreamExample::skipExample, @@ -208,7 +197,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testToArrayExample() { checkDiscoveredProperties( IntStreamExample::toArrayExample, @@ -218,7 +206,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testReduceExample() { checkDiscoveredProperties( IntStreamExample::reduceExample, @@ -229,7 +216,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testOptionalReduceExample() { checkDiscoveredPropertiesWithExceptions( IntStreamExample::optionalReduceExample, @@ -240,7 +226,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testSumExample() { checkDiscoveredProperties( IntStreamExample::sumExample, @@ -251,7 +236,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMinExample() { checkDiscoveredPropertiesWithExceptions( IntStreamExample::minExample, @@ -264,7 +248,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMaxExample() { checkDiscoveredPropertiesWithExceptions( IntStreamExample::maxExample, @@ -277,7 +260,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testCountExample() { checkDiscoveredProperties( IntStreamExample::countExample, @@ -288,7 +270,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testAverageExample() { checkDiscoveredProperties( IntStreamExample::averageExample, @@ -299,7 +280,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testSummaryStatisticsExample() { checkDiscoveredProperties( IntStreamExample::summaryStatisticsExample, @@ -336,7 +316,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testAnyMatchExample() { checkDiscoveredProperties( IntStreamExample::anyMatchExample, @@ -362,7 +341,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testAllMatchExample() { checkDiscoveredProperties( IntStreamExample::allMatchExample, @@ -388,7 +366,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testNoneMatchExample() { checkDiscoveredProperties( IntStreamExample::noneMatchExample, @@ -414,7 +391,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testFindFirstExample() { checkDiscoveredProperties( IntStreamExample::findFirstExample, @@ -425,7 +401,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testAsLongStreamExample() { checkDiscoveredProperties( IntStreamExample::asLongStreamExample, @@ -435,7 +410,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testAsDoubleStreamExample() { checkDiscoveredProperties( IntStreamExample::asDoubleStreamExample, @@ -445,7 +419,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testBoxedExample() { checkDiscoveredProperties( IntStreamExample::boxedExample, @@ -455,7 +428,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testIteratorExample() { checkDiscoveredProperties( IntStreamExample::iteratorSumExample, @@ -466,7 +438,7 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStreamOfExample() { checkDiscoveredProperties( IntStreamExample::streamOfExample, @@ -478,7 +450,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testClosedStreamExample() { checkDiscoveredPropertiesWithExceptions( IntStreamExample::closedStreamExample, @@ -488,7 +459,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testGenerateExample() { checkDiscoveredProperties( IntStreamExample::generateExample, @@ -498,7 +468,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testIterateExample() { checkDiscoveredProperties( IntStreamExample::iterateExample, @@ -508,7 +477,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testConcatExample() { checkDiscoveredProperties( IntStreamExample::concatExample, @@ -518,7 +486,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testRangeExample() { checkDiscoveredProperties( IntStreamExample::rangeExample, @@ -528,7 +495,6 @@ class IntStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testRangeClosedExample() { checkDiscoveredProperties( IntStreamExample::rangeClosedExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/LongStreamExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/LongStreamExampleTest.kt index 7d706314dc..c4dbc4ffb4 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/LongStreamExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/LongStreamExampleTest.kt @@ -13,9 +13,9 @@ import java.util.OptionalLong import java.util.stream.LongStream import kotlin.streams.toList +@Disabled("Still too complex") class LongStreamExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Expected exactly 1 executions, but 3 found") fun testReturningStreamAsParameterExample() { checkDiscoveredProperties( LongStreamExample::returningStreamAsParameterExample, @@ -25,7 +25,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testUseParameterStream() { checkDiscoveredProperties( LongStreamExample::useParameterStream, @@ -40,7 +39,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFilterExample() { checkDiscoveredProperties( LongStreamExample::filterExample, @@ -51,7 +49,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapExample() { checkDiscoveredProperties( LongStreamExample::mapExample, @@ -62,7 +59,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToObjExample() { checkDiscoveredProperties( LongStreamExample::mapToObjExample, @@ -81,7 +77,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToIntExample() { checkDiscoveredProperties( LongStreamExample::mapToIntExample, @@ -100,7 +95,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMapToDoubleExample() { checkDiscoveredProperties( LongStreamExample::mapToDoubleExample, @@ -119,7 +113,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testFlatMapExample() { checkDiscoveredProperties( LongStreamExample::flatMapExample, @@ -135,7 +128,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testDistinctExample() { checkDiscoveredProperties( LongStreamExample::distinctExample, @@ -176,7 +168,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testLimitExample() { checkDiscoveredProperties( LongStreamExample::limitExample, @@ -187,7 +178,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testSkipExample() { checkDiscoveredProperties( LongStreamExample::skipExample, @@ -208,7 +198,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { // } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testToArrayExample() { checkDiscoveredProperties( LongStreamExample::toArrayExample, @@ -218,7 +207,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testReduceExample() { checkDiscoveredProperties( LongStreamExample::reduceExample, @@ -229,7 +217,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testOptionalReduceExample() { checkDiscoveredPropertiesWithExceptions( LongStreamExample::optionalReduceExample, @@ -244,7 +231,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testSumExample() { checkDiscoveredProperties( LongStreamExample::sumExample, @@ -255,7 +241,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMinExample() { checkDiscoveredPropertiesWithExceptions( LongStreamExample::minExample, @@ -268,7 +253,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testMaxExample() { checkDiscoveredPropertiesWithExceptions( LongStreamExample::maxExample, @@ -293,7 +277,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testAverageExample() { checkDiscoveredProperties( LongStreamExample::averageExample, @@ -304,7 +287,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testSummaryStatisticsExample() { checkDiscoveredProperties( LongStreamExample::summaryStatisticsExample, @@ -341,7 +323,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 2 out of bounds for length 2") fun testAnyMatchExample() { checkDiscoveredProperties( LongStreamExample::anyMatchExample, @@ -367,7 +348,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 2 out of bounds for length 2") fun testAllMatchExample() { checkDiscoveredProperties( LongStreamExample::allMatchExample, @@ -393,7 +373,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 2 out of bounds for length 2") fun testNoneMatchExample() { checkDiscoveredProperties( LongStreamExample::noneMatchExample, @@ -419,7 +398,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testFindFirstExample() { checkDiscoveredProperties( LongStreamExample::findFirstExample, @@ -430,7 +408,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testAsDoubleStreamExample() { checkDiscoveredProperties( LongStreamExample::asDoubleStreamExample, @@ -440,7 +417,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testBoxedExample() { checkDiscoveredProperties( LongStreamExample::boxedExample, @@ -450,7 +426,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testIteratorExample() { checkDiscoveredProperties( LongStreamExample::iteratorSumExample, @@ -461,7 +436,7 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStreamOfExample() { checkDiscoveredProperties( LongStreamExample::streamOfExample, @@ -473,7 +448,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testClosedStreamExample() { checkDiscoveredPropertiesWithExceptions( LongStreamExample::closedStreamExample, @@ -483,7 +457,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testGenerateExample() { checkDiscoveredProperties( LongStreamExample::generateExample, @@ -493,7 +466,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Index 1 out of bounds for length 1") fun testIterateExample() { checkDiscoveredProperties( LongStreamExample::iterateExample, @@ -503,7 +475,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") fun testConcatExample() { checkDiscoveredProperties( LongStreamExample::concatExample, @@ -513,7 +484,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") fun testRangeExample() { checkDiscoveredProperties( LongStreamExample::rangeExample, @@ -523,7 +493,6 @@ class LongStreamExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@dc6a186") fun testRangeClosedExample() { checkDiscoveredProperties( LongStreamExample::rangeClosedExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/StreamsAsMethodResultExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/StreamsAsMethodResultExampleTest.kt index e2452d6201..6e7d8ecfd1 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/StreamsAsMethodResultExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/stream/StreamsAsMethodResultExampleTest.kt @@ -5,9 +5,9 @@ import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner import org.usvm.test.util.checkers.eq +@Disabled("Still too complex") class StreamsAsMethodResultExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: virtual calls with abstract methods") fun testReturningStreamExample() { checkDiscoveredProperties( StreamsAsMethodResultExample::returningStreamExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/GenericExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/GenericExamplesTest.kt index 447edf75ea..3b933df166 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/GenericExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/GenericExamplesTest.kt @@ -8,7 +8,7 @@ import org.usvm.util.isException internal class GenericExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Expected exactly 2 executions, but 1 found. Support strings") fun testContainsOkWithIntegerType() { checkDiscoveredPropertiesWithExceptions( GenericExamples<Int>::containsOk, @@ -19,7 +19,7 @@ internal class GenericExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testContainsOkExampleTest() { checkDiscoveredProperties( GenericExamples<String>::containsOkExample, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/StringExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/StringExamplesTest.kt index 3b28e25cc9..b8701ebb3e 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/StringExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/strings/StringExamplesTest.kt @@ -13,7 +13,7 @@ import java.util.Locale internal class StringExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testByteToString() { checkDiscoveredProperties( StringExamples::byteToString, @@ -24,7 +24,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testByteToStringWithConstants() { val values: Array<Byte> = arrayOf( Byte.MIN_VALUE, @@ -44,7 +44,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testReplace() { checkDiscoveredProperties( StringExamples::replace, @@ -56,7 +56,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testShortToString() { checkDiscoveredProperties( StringExamples::shortToString, @@ -67,7 +67,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testShortToStringWithConstants() { val values: Array<Short> = arrayOf( Short.MIN_VALUE, @@ -87,7 +87,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testIntToString() { checkDiscoveredProperties( StringExamples::intToString, @@ -98,7 +98,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testIntToStringWithConstants() { val values: Array<Int> = arrayOf( Integer.MIN_VALUE, @@ -118,7 +118,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testLongToString() { checkDiscoveredProperties( StringExamples::longToString, @@ -129,7 +129,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testLongToStringWithConstants() { val values: Array<Long> = arrayOf( Long.MIN_VALUE, @@ -149,7 +149,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testStartsWithLiteral() { checkDiscoveredProperties( StringExamples::startsWithLiteral, @@ -162,7 +162,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testBooleanToString() { checkDiscoveredProperties( StringExamples::booleanToString, @@ -174,7 +174,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testCharToString() { checkDiscoveredProperties( StringExamples::charToString, @@ -186,7 +186,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: String constants") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStringToByte() { checkDiscoveredProperties( StringExamples::stringToByte, @@ -195,7 +195,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStringToShort() { checkDiscoveredProperties( StringExamples::stringToShort, @@ -204,7 +204,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStringToInt() { checkDiscoveredProperties( StringExamples::stringToInt, @@ -213,7 +213,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStringToLong() { checkDiscoveredProperties( StringExamples::stringToLong, @@ -222,7 +222,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testStringToBoolean() { checkDiscoveredProperties( StringExamples::stringToBoolean, @@ -233,7 +233,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testConcat() { checkDiscoveredProperties( StringExamples::concat, @@ -256,7 +256,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStringConstants() { checkDiscoveredProperties( StringExamples::stringConstants, @@ -266,7 +266,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testContainsOnLiterals() { checkDiscoveredProperties( StringExamples::containsOnLiterals, @@ -275,7 +275,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testConcatWithInt() { checkDiscoveredProperties( StringExamples::concatWithInts, @@ -287,7 +287,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testUseStringBuffer() { checkDiscoveredProperties( StringExamples::useStringBuffer, @@ -297,7 +297,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 1 executions, but 3 found") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStringBuilderAsParameterExample() { checkDiscoveredProperties( StringExamples::stringBuilderAsParameterExample, @@ -306,7 +306,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testNullableStringBuffer() { checkDiscoveredPropertiesWithExceptions( StringExamples::nullableStringBuffer, @@ -319,7 +319,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testIsStringBuilderEmpty() { checkDiscoveredProperties( StringExamples::isStringBuilderEmpty, @@ -329,7 +329,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Flaky on GitHub: https://github.com/UnitTestBot/UTBotJava/issues/1004") + @Disabled("Sequence is empty.") fun testIsValidUuid() { val pattern = Regex("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}") checkDiscoveredProperties( @@ -344,7 +344,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testIsValidUuidShortVersion() { val pattern = Regex("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}") checkDiscoveredProperties( @@ -357,7 +357,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testSplitExample() { checkDiscoveredProperties( StringExamples::splitExample, @@ -371,7 +371,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") + @Disabled("Sequence is empty.") fun testIsBlank() { checkDiscoveredProperties( StringExamples::isBlank, @@ -384,7 +384,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") + @Disabled("Sequence is empty.") fun testLength() { checkDiscoveredProperties( StringExamples::length, // TODO: that strange, why we haven't 3rd option? @@ -395,7 +395,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") + @Disabled("Sequence is empty.") fun testLonger() { checkDiscoveredPropertiesWithExceptions( StringExamples::longer, @@ -407,7 +407,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: virtual calls with abstract methods") + @Disabled("Sequence is empty.") fun testEqualChar() { checkDiscoveredPropertiesWithExceptions( StringExamples::equalChar, @@ -420,7 +420,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testSubstring() { checkDiscoveredPropertiesWithExceptions( StringExamples::substring, @@ -434,7 +434,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testSubstringWithEndIndex() { checkDiscoveredPropertiesWithExceptions( StringExamples::substringWithEndIndex, @@ -453,7 +453,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testSubstringWithEndIndexNotEqual() { checkDiscoveredPropertiesWithExceptions( StringExamples::substringWithEndIndexNotEqual, @@ -465,7 +465,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testFullSubstringEquality() { checkDiscoveredPropertiesWithExceptions( StringExamples::fullSubstringEquality, @@ -476,7 +476,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("TODO: add intern support") + @Disabled("An operation is not implemented: Not yet implemented") fun testUseIntern() { checkDiscoveredPropertiesWithExceptions( StringExamples::useIntern, @@ -488,7 +488,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@5927f2b1") fun testPrefixAndSuffix() { checkDiscoveredProperties( StringExamples::prefixAndSuffix, @@ -503,7 +503,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testPrefixWithTwoArgs() { checkDiscoveredPropertiesWithExceptions( StringExamples::prefixWithTwoArgs, @@ -515,7 +515,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testPrefixWithOffset() { checkDiscoveredProperties( StringExamples::prefixWithOffset, @@ -528,7 +528,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStartsWith() { checkDiscoveredProperties( StringExamples::startsWith, @@ -543,7 +543,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testStartsWithOffset() { checkDiscoveredProperties( StringExamples::startsWithOffset, @@ -564,7 +564,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testEndsWith() { checkDiscoveredProperties( StringExamples::endsWith, @@ -578,7 +578,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("TODO: support replace") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testReplaceAll() { checkDiscoveredPropertiesWithExceptions( StringExamples::replaceAll, @@ -593,7 +593,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testLastIndexOf() { checkDiscoveredProperties( StringExamples::lastIndexOf, @@ -607,7 +607,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testIndexOfWithOffset() { checkDiscoveredProperties( StringExamples::indexOfWithOffset, @@ -622,7 +622,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testLastIndexOfWithOffset() { checkDiscoveredProperties( StringExamples::lastIndexOfWithOffset, @@ -636,7 +636,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testCompareCodePoints() { checkDiscoveredPropertiesWithExceptions( StringExamples::compareCodePoints, @@ -653,7 +653,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testToCharArray() { checkDiscoveredProperties( StringExamples::toCharArray, @@ -664,7 +664,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: reference cast") + @Disabled("An operation is not implemented: Not yet implemented") fun testGetObj() { checkDiscoveredProperties( StringExamples::getObj, @@ -674,7 +674,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testGetObjWithCondition() { checkDiscoveredProperties( StringExamples::getObjWithCondition, @@ -686,7 +686,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testEqualsIgnoreCase() { checkDiscoveredProperties( StringExamples::equalsIgnoreCase, @@ -697,7 +697,7 @@ internal class StringExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testListToString() { checkDiscoveredProperties( StringExamples::listToString, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/strings11/StringConcatTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/strings11/StringConcatTest.kt index cb67107cea..bf92d6d44d 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/strings11/StringConcatTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/strings11/StringConcatTest.kt @@ -9,7 +9,7 @@ import org.usvm.util.isException class StringConcatTest : JavaMethodTestRunner() { @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1d628a88") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testConcatArguments() { checkDiscoveredProperties( StringConcat::concatArguments, @@ -19,7 +19,7 @@ class StringConcatTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@1d628a88") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testConcatWithConstants() { checkDiscoveredProperties( StringConcat::concatWithConstants, @@ -42,7 +42,7 @@ class StringConcatTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@78181f7f") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testExceptionInToString() { checkDiscoveredPropertiesWithExceptions( StringConcat::exceptionInToString, @@ -63,7 +63,7 @@ class StringConcatTest : JavaMethodTestRunner() { // } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@549fc0b3") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testConcatWithPrimitiveWrappers() { checkDiscoveredProperties( StringConcat::concatWithPrimitiveWrappers, @@ -74,7 +74,7 @@ class StringConcatTest : JavaMethodTestRunner() { } @Test - @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@7e8e111d") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testSameConcat() { checkDiscoveredProperties( StringConcat::sameConcat, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/HeapTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/HeapTest.kt index 43967bb778..ff9f5f6b4b 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/HeapTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/HeapTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults internal class HeapTest : JavaMethodTestRunner() { @Test - @Disabled("Failed requirement at org.usvm.model.ULazyHeapModel.readArrayLength(LazyModels.kt:154)") + @Disabled("Some properties were not discovered at positions (from 0): [4]. Fix branch coverage") fun testIsHeap() { val method = Heap::isHeap checkDiscoveredProperties( diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/MinStackExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/MinStackExampleTest.kt index 7ae395d169..33a519df2c 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/MinStackExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/MinStackExampleTest.kt @@ -11,7 +11,6 @@ import kotlin.math.min internal class MinStackExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Expected exactly 3 executions, but 244 found. Same exception discovered multiple times") fun testCreate() { checkDiscoveredProperties( MinStackExample::create, @@ -34,7 +33,7 @@ internal class MinStackExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 4 executions, but 5 found. Same exception discovered multiple times") + @Disabled("Expected exactly 3 executions, but 2 found. Tune coverage zone") fun testAddSingleValue() { checkDiscoveredProperties( MinStackExample::addSingleValue, @@ -54,7 +53,7 @@ internal class MinStackExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 3 executions, but 593 found. Same exception discovered multiple times") + @Disabled("Expected exactly 3 executions, but 2 found. Tune coverage zone") fun testGetMinValue() { checkDiscoveredProperties( MinStackExample::getMinValue, @@ -68,7 +67,7 @@ internal class MinStackExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun testRemoveValue() { checkDiscoveredProperties( MinStackExample::removeValue, @@ -85,7 +84,6 @@ internal class MinStackExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected number of executions in bounds 3..4, but 6 found. Same exception discovered multiple times") fun testConstruct() { checkDiscoveredProperties( MinStackExample::construct, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/StandardStructuresTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/StandardStructuresTest.kt index d85e9ec7dc..812663d6e7 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/StandardStructuresTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/structures/StandardStructuresTest.kt @@ -9,7 +9,7 @@ import java.util.TreeMap internal class StandardStructuresTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Instance of") + @Disabled("Support instanceof") fun testGetList() { checkDiscoveredProperties( StandardStructures::getList, @@ -24,7 +24,7 @@ internal class StandardStructuresTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Instance of") + @Disabled("Support instanceof") fun testGetMap() { checkDiscoveredProperties( StandardStructures::getMap, @@ -36,7 +36,7 @@ internal class StandardStructuresTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Instance of") + @Disabled("Support instanceof") fun testGetDeque() { checkDiscoveredProperties( StandardStructures::getDeque, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/substitution/StaticsSubstitutionTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/substitution/StaticsSubstitutionTest.kt index c2e610d4bd..4ef031429b 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/substitution/StaticsSubstitutionTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/substitution/StaticsSubstitutionTest.kt @@ -9,7 +9,7 @@ import org.usvm.test.util.checkers.eq class StaticsSubstitutionTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun lessThanZeroWithSubstitution() { checkDiscoveredProperties( StaticSubstitutionExamples::lessThanZero, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/CountDownLatchExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/CountDownLatchExamplesTest.kt index cdc9e9b6ed..0443655357 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/CountDownLatchExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/CountDownLatchExamplesTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq class CountDownLatchExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Unable to make field private final java.util.concurrent.CountDownLatch\$Sync java.util.concurrent.CountDownLatch.sync accessible: module java.base does not \"opens java.util.concurrent\" to unnamed module @399f45b1\n") + @Disabled("java.lang.IllegalStateException: Sort mismatch. Support exceptions") fun testGetAndDown() { checkDiscoveredProperties( CountDownLatchExamples::getAndDown, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ExecutorServiceExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ExecutorServiceExamplesTest.kt index 5f8e418414..f6bf686fc0 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ExecutorServiceExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ExecutorServiceExamplesTest.kt @@ -12,7 +12,7 @@ import org.usvm.util.isException // (see https://github.com/UnitTestBot/UTBotJava/issues/1610) class ExecutorServiceExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testExceptionInExecute() { checkDiscoveredPropertiesWithExceptions( ExecutorServiceExamples::throwingInExecute, @@ -22,7 +22,7 @@ class ExecutorServiceExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testChangingCollectionInExecute() { checkDiscoveredProperties( ExecutorServiceExamples::changingCollectionInExecute, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/FutureExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/FutureExamplesTest.kt index 81db92090a..1b6cc9f433 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/FutureExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/FutureExamplesTest.kt @@ -12,7 +12,7 @@ import java.util.concurrent.ExecutionException // (see https://github.com/UnitTestBot/UTBotJava/issues/1610) class FutureExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Expected exactly 1 executions, but 2 found. Same exception discovered multiple times") + @Disabled("Support invokedynamic") fun testThrowingRunnable() { checkDiscoveredPropertiesWithExceptions( FutureExamples::throwingRunnableExample, @@ -22,7 +22,7 @@ class FutureExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testResultFromGet() { checkDiscoveredProperties( FutureExamples::resultFromGet, @@ -32,7 +32,7 @@ class FutureExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testChangingCollectionInFuture() { checkDiscoveredProperties( FutureExamples::changingCollectionInFuture, @@ -42,7 +42,7 @@ class FutureExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testChangingCollectionInFutureWithoutGet() { checkDiscoveredProperties( FutureExamples::changingCollectionInFutureWithoutGet, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ThreadExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ThreadExamplesTest.kt index 5ef1849e35..b10825cfb9 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ThreadExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/threads/ThreadExamplesTest.kt @@ -12,6 +12,7 @@ import org.usvm.util.isException // (see https://github.com/UnitTestBot/UTBotJava/issues/1610) class ThreadExamplesTest : JavaMethodTestRunner() { @Test + @Disabled("Support invokedynamic") fun testExceptionInStart() { checkDiscoveredPropertiesWithExceptions( ThreadExamples::explicitExceptionInStart, @@ -21,7 +22,7 @@ class ThreadExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testChangingCollectionInThread() { checkDiscoveredProperties( ThreadExamples::changingCollectionInThread, @@ -31,7 +32,7 @@ class ThreadExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun testChangingCollectionInThreadWithoutStart() { checkDiscoveredPropertiesWithExceptions( ThreadExamples::changingCollectionInThreadWithoutStart, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/CastExamplesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/CastExamplesTest.kt index f4ef99564f..ece1aafb32 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/CastExamplesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/CastExamplesTest.kt @@ -1,6 +1,5 @@ package org.usvm.samples.types -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.usvm.samples.JavaMethodTestRunner import org.usvm.test.util.checkers.eq @@ -9,7 +8,6 @@ import org.usvm.test.util.checkers.eq @Suppress("SimplifyNegatedBinaryExpression") internal class CastExamplesTest : JavaMethodTestRunner() { @Test - @Disabled("Sort mismatch") fun testLongToByte() { checkDiscoveredProperties( CastExamples::longToByte, @@ -65,7 +63,6 @@ internal class CastExamplesTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testShortToChar() { checkDiscoveredProperties( CastExamples::shortToChar, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/GenericsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/GenericsTest.kt index 7caeece862..6399fa7ca6 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/GenericsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/GenericsTest.kt @@ -9,7 +9,7 @@ import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults internal class GenericsTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun mapAsParameterTest() { checkDiscoveredProperties( Generics<*>::mapAsParameter, @@ -20,7 +20,7 @@ internal class GenericsTest : JavaMethodTestRunner() { } @Test - @Disabled("https://github.com/UnitTestBot/UTBotJava/issues/1620 wrong equals") + @Disabled("An operation is not implemented: Not yet implemented") fun genericAsFieldTest() { checkDiscoveredProperties( Generics<*>::genericAsField, @@ -32,7 +32,7 @@ internal class GenericsTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun mapAsStaticFieldTest() { checkDiscoveredProperties( Generics<*>::mapAsStaticField, @@ -42,7 +42,7 @@ internal class GenericsTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun mapAsNonStaticFieldTest() { checkDiscoveredProperties( Generics<*>::mapAsNonStaticField, @@ -53,7 +53,7 @@ internal class GenericsTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("An operation is not implemented: Not yet implemented") fun methodWithRawTypeTest() { checkDiscoveredProperties( Generics<*>::methodWithRawType, @@ -64,7 +64,6 @@ internal class GenericsTest : JavaMethodTestRunner() { } @Test - @Disabled("Expected exactly 1 executions, but 2 found. Same exception discovered multiple times") fun testMethodWithArrayTypeBoundary() { checkDiscoveredPropertiesWithExceptions( Generics<*>::methodWithArrayTypeBoundary, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/PathDependentGenericsExampleTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/PathDependentGenericsExampleTest.kt index 92f161eb9e..ea69b05a5a 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/PathDependentGenericsExampleTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/PathDependentGenericsExampleTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class PathDependentGenericsExampleTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Instance of") + @Disabled("Support instanceof") fun testPathDependentGenerics() { checkDiscoveredProperties( PathDependentGenericsExample::pathDependentGenerics, @@ -20,7 +20,7 @@ internal class PathDependentGenericsExampleTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Instance of") + @Disabled("Sequence is empty.") fun testFunctionWithSeveralTypeConstraintsForTheSameObject() { checkDiscoveredProperties( PathDependentGenericsExample::functionWithSeveralTypeConstraintsForTheSameObject, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/TypeMatchesTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/TypeMatchesTest.kt index ede27cca3a..8a8485f97c 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/types/TypeMatchesTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/types/TypeMatchesTest.kt @@ -39,7 +39,6 @@ internal class TypeMatchesTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testSumByteAndShort() { checkDiscoveredProperties( TypeMatches::sumByteAndShort, @@ -51,7 +50,6 @@ internal class TypeMatchesTest : JavaMethodTestRunner() { } @Test - @Disabled("Sort mismatch") fun testSumShortAndChar() { checkDiscoveredProperties( TypeMatches::sumShortAndChar, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeOperationsTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeOperationsTest.kt index 7484b6aa2c..6537344bc8 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeOperationsTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeOperationsTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class UnsafeOperationsTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Class constants") + @Disabled("An operation is not implemented: Not yet implemented") fun checkGetAddressSizeOrZero() { checkDiscoveredProperties( UnsafeOperations::getAddressSizeOrZero, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeWithFieldTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeWithFieldTest.kt index 834b68847e..dfdf9a06e4 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeWithFieldTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeWithFieldTest.kt @@ -10,7 +10,7 @@ import org.usvm.test.util.checkers.eq internal class UnsafeWithFieldTest: JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun checkSetField() { checkDiscoveredProperties( UnsafeWithField::setField, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/BooleanWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/BooleanWrapperTest.kt index df5e50a7a7..d8467ac188 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/BooleanWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/BooleanWrapperTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class BooleanWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun primitiveToWrapperTest() { checkDiscoveredProperties( BooleanWrapper::primitiveToWrapper, @@ -19,7 +19,6 @@ internal class BooleanWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final java.lang.Boolean field java.lang.Boolean.TRUE to null value") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( BooleanWrapper::wrapperToPrimitive, @@ -31,7 +30,7 @@ internal class BooleanWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun equalityTest() { checkDiscoveredProperties( BooleanWrapper::equality, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ByteWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ByteWrapperTest.kt index 04cbf010b1..9b3ff02b99 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ByteWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ByteWrapperTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class ByteWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun primitiveToWrapperTest() { checkDiscoveredProperties( ByteWrapper::primitiveToWrapper, @@ -19,7 +19,6 @@ internal class ByteWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final byte field java.lang.Byte.MIN_VALUE to java.lang.Byte") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( ByteWrapper::wrapperToPrimitive, @@ -31,7 +30,7 @@ internal class ByteWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun equalityTest() { checkDiscoveredProperties( ByteWrapper::equality, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/CharacterWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/CharacterWrapperTest.kt index 2d46fbd6b8..11a9884d4e 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/CharacterWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/CharacterWrapperTest.kt @@ -9,7 +9,7 @@ import org.usvm.test.util.checkers.eq // TODO failed Kotlin compilation internal class CharacterWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun primitiveToWrapperTest() { checkDiscoveredProperties( CharacterWrapper::primitiveToWrapper, @@ -20,7 +20,6 @@ internal class CharacterWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final int field java.lang.Character.MIN_RADIX to java.lang.Integer") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( CharacterWrapper::wrapperToPrimitive, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/DoubleWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/DoubleWrapperTest.kt index 1c6ab56f3f..08e8e079b3 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/DoubleWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/DoubleWrapperTest.kt @@ -9,7 +9,6 @@ import org.usvm.test.util.checkers.eq @Suppress("SimplifyNegatedBinaryExpression") internal class DoubleWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Can not set static final double field java.lang.Double.POSITIVE_INFINITY to java.lang.Double") fun primitiveToWrapperTest() { checkDiscoveredProperties( DoubleWrapper::primitiveToWrapper, @@ -20,7 +19,6 @@ internal class DoubleWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final double field java.lang.Double.POSITIVE_INFINITY to java.lang.Double") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( DoubleWrapper::wrapperToPrimitive, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/FloatWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/FloatWrapperTest.kt index 5dc41d30a7..0f4b41fdd6 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/FloatWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/FloatWrapperTest.kt @@ -9,7 +9,6 @@ import org.usvm.test.util.checkers.eq @Suppress("SimplifyNegatedBinaryExpression") internal class FloatWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Can not set static final float field java.lang.Float.POSITIVE_INFINITY to java.lang.Float") fun primitiveToWrapperTest() { checkDiscoveredProperties( FloatWrapper::primitiveToWrapper, @@ -20,7 +19,6 @@ internal class FloatWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final float field java.lang.Float.POSITIVE_INFINITY to java.lang.Float") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( FloatWrapper::wrapperToPrimitive, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/IntegerWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/IntegerWrapperTest.kt index 83f447c6d6..ffcc3f2112 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/IntegerWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/IntegerWrapperTest.kt @@ -8,7 +8,7 @@ import org.usvm.test.util.checkers.eq internal class IntegerWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun primitiveToWrapperTest() { checkDiscoveredProperties( IntegerWrapper::primitiveToWrapper, @@ -19,7 +19,6 @@ internal class IntegerWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final int field java.lang.Integer.MIN_VALUE to java.lang.Integer") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( IntegerWrapper::wrapperToPrimitive, @@ -31,7 +30,6 @@ internal class IntegerWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: ushr") fun numberOfZerosTest() { checkDiscoveredProperties( IntegerWrapper::numberOfZeros, @@ -44,7 +42,6 @@ internal class IntegerWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: ushr") fun bitCountTest() { checkDiscoveredProperties( IntegerWrapper::bitCount, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/LongWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/LongWrapperTest.kt index 3bc267eb0c..a3244e887b 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/LongWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/LongWrapperTest.kt @@ -8,7 +8,6 @@ import org.usvm.test.util.checkers.eq internal class LongWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") fun primitiveToWrapperTest() { checkDiscoveredProperties( LongWrapper::primitiveToWrapper, @@ -19,7 +18,6 @@ internal class LongWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final long field java.lang.Long.MIN_VALUE to java.lang.Long") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( LongWrapper::wrapperToPrimitive, @@ -43,7 +41,7 @@ internal class LongWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Not implemented: String constants") + @Disabled("Unexpected lvalue org.usvm.machine.JcStaticFieldRef@3f95a1b3") fun parseLong() { checkDiscoveredProperties( LongWrapper::parseLong, diff --git a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ShortWrapperTest.kt b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ShortWrapperTest.kt index c24554b9b4..e27c717888 100644 --- a/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ShortWrapperTest.kt +++ b/usvm-jvm/src/test/kotlin/org/usvm/samples/wrappers/ShortWrapperTest.kt @@ -8,7 +8,6 @@ import org.usvm.test.util.checkers.eq internal class ShortWrapperTest : JavaMethodTestRunner() { @Test - @Disabled("Not implemented: Unexpected lvalue org.usvm.machine.JcStaticFieldRef") fun primitiveToWrapperTest() { checkDiscoveredProperties( ShortWrapper::primitiveToWrapper, @@ -19,7 +18,6 @@ internal class ShortWrapperTest : JavaMethodTestRunner() { } @Test - @Disabled("Can not set static final short field java.lang.Short.MIN_VALUE to java.lang.Short") fun wrapperToPrimitiveTest() { checkDiscoveredProperties( ShortWrapper::wrapperToPrimitive, diff --git a/usvm-sample-language/src/main/kotlin/org/usvm/machine/ResultModelConverter.kt b/usvm-sample-language/src/main/kotlin/org/usvm/machine/ResultModelConverter.kt index 2c5be7d05e..0ba56303e9 100644 --- a/usvm-sample-language/src/main/kotlin/org/usvm/machine/ResultModelConverter.kt +++ b/usvm-sample-language/src/main/kotlin/org/usvm/machine/ResultModelConverter.kt @@ -2,6 +2,7 @@ package org.usvm.machine import io.ksmt.expr.KBitVec32Value import io.ksmt.utils.asExpr +import org.usvm.NULL_ADDRESS import org.usvm.UAddressSort import org.usvm.UBoolSort import org.usvm.UBv32Sort @@ -23,7 +24,6 @@ import org.usvm.language.SampleType import org.usvm.language.StructCreation import org.usvm.language.StructExpr import org.usvm.language.StructType -import org.usvm.memory.UAddressCounter.Companion.NULL_ADDRESS import org.usvm.model.UModelBase class ResultModelConverter( diff --git a/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleLanguageComponents.kt b/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleLanguageComponents.kt index ce535588f6..8820179b35 100644 --- a/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleLanguageComponents.kt +++ b/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleLanguageComponents.kt @@ -5,7 +5,7 @@ import io.ksmt.solver.z3.KZ3Solver import org.usvm.SolverType import org.usvm.UComponents import org.usvm.UContext -import org.usvm.UTypeSystem +import org.usvm.types.UTypeSystem import org.usvm.language.Field import org.usvm.language.Method import org.usvm.language.SampleType diff --git a/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleState.kt b/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleState.kt index d54e48fd68..33f04dd719 100644 --- a/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleState.kt +++ b/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleState.kt @@ -38,7 +38,7 @@ class SampleState( override fun clone(newConstraints: UPathConstraints<SampleType>?): SampleState { val clonedConstraints = newConstraints ?: pathConstraints.clone() return SampleState( - ctx, + pathConstraints.ctx, callStack.clone(), clonedConstraints, memory.clone(clonedConstraints.typeConstraints), diff --git a/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleTypeSystem.kt b/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleTypeSystem.kt index 96bf3b0321..2d0329512e 100644 --- a/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleTypeSystem.kt +++ b/usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleTypeSystem.kt @@ -1,7 +1,9 @@ package org.usvm.machine -import org.usvm.UTypeSystem import org.usvm.language.SampleType +import org.usvm.types.UTypeStream +import org.usvm.types.UTypeSystem +import org.usvm.types.emptyTypeStream class SampleTypeSystem : UTypeSystem<SampleType> { override fun isSupertype(u: SampleType, t: SampleType): Boolean = @@ -10,4 +12,13 @@ class SampleTypeSystem : UTypeSystem<SampleType> { override fun isFinal(t: SampleType): Boolean = true override fun isMultipleInheritanceAllowedFor(t: SampleType): Boolean = false + override fun isInstantiable(t: SampleType): Boolean = true + + override fun findSubtypes(t: SampleType): Sequence<SampleType> = emptySequence() + + override fun topTypeStream(): UTypeStream<SampleType> = emptyTypeStream + + companion object { + private val emptyTypeStream: UTypeStream<SampleType> = emptyTypeStream() + } } diff --git a/usvm-util/src/main/kotlin/org/usvm/util/GraphIterators.kt b/usvm-util/src/main/kotlin/org/usvm/util/GraphIterators.kt new file mode 100644 index 0000000000..b163f07f54 --- /dev/null +++ b/usvm-util/src/main/kotlin/org/usvm/util/GraphIterators.kt @@ -0,0 +1,67 @@ +package org.usvm.util + +abstract class GraphIterator<T> : Iterator<T> { + protected sealed class IteratorState { + object Unknown : IteratorState() + object NoElements : IteratorState() + class Element<T>(val element: T) : IteratorState() + } + + private var iteratorState: IteratorState = IteratorState.Unknown + + protected abstract fun calcNext(): IteratorState + + final override fun hasNext(): Boolean { + if (iteratorState == IteratorState.Unknown) { + iteratorState = calcNext() + } + return iteratorState is IteratorState.Element<*> + } + + final override fun next(): T { + if (iteratorState == IteratorState.Unknown) { + calcNext() + } + if (iteratorState == IteratorState.NoElements) { + throw NoSuchElementException() + } + @Suppress("UNCHECKED_CAST") + val result = (iteratorState as IteratorState.Element<T>).element + iteratorState = IteratorState.Unknown + return result + } +} + +/** + * Lazily iterates elements in a DFS order, emitting a node when all its children are completely traversed. + * Guarantees that [itemToChildren] will be called no more than once on each element. + * + * @param top an element to start from. + */ +class DfsIterator<T>( + top: T, + private val itemToChildren: (T) -> Iterator<T>, +) : GraphIterator<T>() { + private val queue = ArrayDeque<Node<T>>().apply { add(Node(top, itemToChildren(top))) } + private val used = hashSetOf<T>() + private data class Node<T>(val item: T, val children: Iterator<T>) + override fun calcNext(): IteratorState { + while (queue.isNotEmpty()) { + val (item, children) = queue.last() + + var nextItem: T? = null + while (nextItem == null && children.hasNext()) { + nextItem = children.next().takeIf { it !in used } + } + if (nextItem != null) { + used += nextItem + val nextChildren = itemToChildren(nextItem) + queue.add(Node(nextItem, nextChildren)) + } else { // nextItem == null && children.hasNext() == false + queue.removeLast() + return IteratorState.Element(item) + } + } + return IteratorState.NoElements + } +} \ No newline at end of file