Skip to content

Commit

Permalink
Added max depth for object construction and generic removing when pas…
Browse files Browse the repository at this point in the history
…sing jc types
  • Loading branch information
DaniilStepanov committed Oct 30, 2023
1 parent adced43 commit 641bc90
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ fun AbstractBuffer.readJcField(jcClasspath: JcClasspath): JcField {
}

fun AbstractBuffer.readJcType(jcClasspath: JcClasspath): JcType? {
var typeName = readString()
//Remove info about generics
var typeName = readString().replace(Regex("""<\s*[A-Za-z*?]+\s*(\s*,\s*[A-Za-z*?]+)*>"""), "")
if (typeName == "type_is_null") return null
jcClasspath.findTypeOrNull(typeName)?.let { return it }
//We need this because of jacodb peculiarity with typenames...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ open class Value2DescriptorConverter(
}

private fun buildDescriptor(any: Any?, type: JcType?, depth: Int = 0): UTestValueDescriptor {
if (any == null) return `null`(type ?: jcClasspath.nullType)
if (any == null || depth > InstrumentationModuleConstants.maxDepthOfDescriptorConstruction) {
return `null`(type ?: jcClasspath.nullType)
}
return objectToDescriptor.getOrPut(any) {
when (any) {
is Boolean -> const(any)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ object InstrumentationModuleConstants {
const val triesToRecreateExecutorRdProcess = 3
//Rollback strategy
val testExecutorStaticsRollbackStrategy = StaticsRollbackStrategy.REINIT
//Max depth of descriptor construction
val maxDepthOfDescriptorConstruction = 5

const val nameForExistingButNullString = "USVM_GENERATED_NULL_STRING"

Expand Down
14 changes: 4 additions & 10 deletions usvm-jvm/src/test/kotlin/org/usvm/util/JcTestExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,14 @@ import org.usvm.api.JcParametersState
import org.usvm.api.JcTest
import org.usvm.api.typeStreamOf
import org.usvm.api.util.JcTestResolver
import org.usvm.api.util.Reflection
import org.usvm.collection.array.UArrayIndexLValue
import org.usvm.collection.array.length.UArrayLengthLValue
import org.usvm.collection.field.UFieldLValue
import org.usvm.instrumentation.executor.UTestConcreteExecutor
import org.usvm.instrumentation.testcase.UTest
import org.usvm.instrumentation.testcase.api.*
import org.usvm.instrumentation.testcase.descriptor.Descriptor2ValueConverter
import org.usvm.machine.JcContext
import org.usvm.machine.extractBool
import org.usvm.machine.extractByte
import org.usvm.machine.extractChar
import org.usvm.machine.extractDouble
import org.usvm.machine.extractFloat
import org.usvm.machine.extractInt
import org.usvm.machine.extractLong
import org.usvm.machine.extractShort
import org.usvm.machine.*
import org.usvm.machine.state.JcState
import org.usvm.machine.state.localIdx
import org.usvm.memory.ULValue
Expand All @@ -37,6 +28,8 @@ import org.usvm.memory.URegisterStackLValue
import org.usvm.model.UModelBase
import org.usvm.types.first
import org.usvm.types.firstOrNull
import java.nio.file.Paths
import kotlin.io.path.appendText

/**
* A class, responsible for resolving a single [JcTest] for a specific method from a symbolic state.
Expand Down Expand Up @@ -81,6 +74,7 @@ class JcTestExecutor(
val execResult = runBlocking {
runner.executeAsync(uTest)
}
Paths.get("/tmp/lol.txt").appendText("EXECUTION FINISHED")
val result =
when (execResult) {
is UTestExecutionSuccessResult -> {
Expand Down

0 comments on commit 641bc90

Please sign in to comment.