Skip to content
24 changes: 11 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ intellijPluginVersion=1.7.0
rdVersion=2022.2.1
# to enable - add -PincludeRiderInBuild=true in build CLI
includeRiderInBuild=false
jacocoVersion=0.8.8
commonsLangVersion=3.11
commonsIoVersion=2.8.0
kotlinLoggingVersion=1.8.3
Expand All @@ -67,24 +66,23 @@ mavenPluginTestingVersion=3.3.0
mavenResolverApiVersion=1.8.0
sisuPlexusVersion=0.3.5
javaCppVersion=1.5.3
jsoupVersion=1.7.2
djlApiVersion=0.17.0
pytorchNativeVersion=1.9.1
shadowJarVersion=7.1.2
openblasVersion=0.3.10-1.5.4
arpackNgVersion=3.7.0-1.5.4

# configuration for build server
org.gradle.daemon=false
org.gradle.parallel=false
org.gradle.jvmargs="-XX:MaxHeapSize=6144m"
kotlin.compiler.execution.strategy=in-process
org.gradle.caching=false
#org.gradle.daemon=false
#org.gradle.parallel=false
#org.gradle.jvmargs="-XX:MaxHeapSize=6144m"
#kotlin.compiler.execution.strategy=in-process
#org.gradle.caching=false

# configuration for local compilation - much faster
#org.gradle.daemon=true
#kotlin.daemon.jvm.options=-Xmx4g
#org.gradle.parallel=true
#org.gradle.caching=true
#org.gradle.workers.max=8
#org.gradle.jvmargs="-XX:MaxHeapSize=6144m"
org.gradle.daemon=true
kotlin.daemon.jvm.options=-Xmx4g
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.workers.max=8
org.gradle.jvmargs="-XX:MaxHeapSize=6144m"
1 change: 0 additions & 1 deletion utbot-analytics-torch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies {
testImplementation group: 'junit', name: 'junit', version: junit4Version

implementation group: 'org.bytedeco', name: 'javacpp', version: javaCppVersion, classifier: "$classifier"
implementation group: 'org.jsoup', name: 'jsoup', version: jsoupVersion

implementation "ai.djl:api:$djlApiVersion"
implementation "ai.djl.pytorch:pytorch-engine:$djlApiVersion"
Expand Down
1 change: 0 additions & 1 deletion utbot-cli-python/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dependencies {
implementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junit5Version
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j2Version
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4j2Version
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacocoVersion
//noinspection GroovyAssignabilityCheck
fetchInstrumentationJar project(path: ':utbot-instrumentation', configuration:'instrumentationArchive')
}
Expand Down
1 change: 0 additions & 1 deletion utbot-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dependencies {
implementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junit5Version
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j2Version
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4j2Version
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacocoVersion
fetchInstrumentationJar project(path: ':utbot-instrumentation', configuration: 'instrumentationArchive')
}

Expand Down
2 changes: 1 addition & 1 deletion utbot-core/src/main/kotlin/org/utbot/common/StopWatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class StopWatch {
}
}

fun get(unit: TimeUnit) = lock.withLockInterruptibly {
fun get(unit: TimeUnit = TimeUnit.MILLISECONDS) = lock.withLockInterruptibly {
unsafeUpdate()
unit.convert(elapsedMillis, TimeUnit.MILLISECONDS)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ object UtSettings : AbstractSettings(logger, defaultKeyForSettingsPath, defaultS
/**
* Timeout for specific concrete execution (in milliseconds).
*/
var concreteExecutionTimeoutInInstrumentedProcess: Long by getLongProperty(
var concreteExecutionDefaultTimeoutInInstrumentedProcessMillis: Long by getLongProperty(
DEFAULT_EXECUTION_TIMEOUT_IN_INSTRUMENTED_PROCESS_MS
)

Expand Down
1 change: 0 additions & 1 deletion utbot-framework-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ dependencies {
implementation group: 'com.github.curious-odd-man', name: 'rgxgen', version: rgxgenVersion
implementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: log4j2Version
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlinLoggingVersion
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacocoVersion
implementation group: 'org.apache.commons', name: 'commons-text', version: apacheCommonsTextVersion
// we need this for construction mocks from composite models
implementation group: 'org.mockito', name: 'mockito-core', version: '4.2.0'
Expand Down
1 change: 0 additions & 1 deletion utbot-framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies {
implementation group: 'com.github.curious-odd-man', name: 'rgxgen', version: rgxgenVersion
implementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: log4j2Version
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlinLoggingVersion
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacocoVersion
implementation group: 'org.apache.commons', name: 'commons-text', version: apacheCommonsTextVersion
// we need this for construction mocks from composite models
implementation group: 'org.mockito', name: 'mockito-core', version: '4.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import org.utbot.instrumentation.instrumentation.execution.UtExecutionInstrument
import soot.jimple.Stmt
import soot.tagkit.ParamNamesTag
import java.lang.reflect.Method
import kotlin.math.min
import kotlin.system.measureTimeMillis

val logger = KotlinLogging.logger {}
Expand Down Expand Up @@ -247,7 +248,7 @@ class UtBotSymbolicEngine(

try {
val concreteExecutionResult =
concreteExecutor.executeConcretely(methodUnderTest, stateBefore, instrumentation)
concreteExecutor.executeConcretely(methodUnderTest, stateBefore, instrumentation, UtSettings.concreteExecutionDefaultTimeoutInInstrumentedProcessMillis)

if (concreteExecutionResult.violatesUtMockAssumption()) {
logger.debug { "Generated test case violates the UtMock assumption: $concreteExecutionResult" }
Expand Down Expand Up @@ -353,7 +354,14 @@ class UtBotSymbolicEngine(
names,
listOf(transform(ValueProvider.of(defaultValueProviders(defaultIdGenerator))))
) { thisInstance, descr, values ->
if (controller.job?.isActive == false || System.currentTimeMillis() >= until) {
val diff = until - System.currentTimeMillis()
val thresholdMillisForFuzzingOperation = 0 // may be better use 10-20 millis as it might not be possible
// to concretely execute that values because request to instrumentation process involves
// 1. serializing/deserializing it with kryo
// 2. sending over rd
// 3. concrete execution itself
// 4. analyzing concrete result
if (controller.job?.isActive == false || diff <= thresholdMillisForFuzzingOperation) {
logger.info { "Fuzzing overtime: $methodUnderTest" }
logger.info { "Test created by fuzzer: $testEmittedByFuzzer" }
return@runJavaFuzzing BaseFeedback(result = Trie.emptyNode(), control = Control.STOP)
Expand All @@ -362,7 +370,8 @@ class UtBotSymbolicEngine(
val initialEnvironmentModels = EnvironmentModels(thisInstance?.model, values.map { it.model }, mapOf())

val concreteExecutionResult: UtConcreteExecutionResult? = try {
concreteExecutor.executeConcretely(methodUnderTest, initialEnvironmentModels, listOf())
val timeoutMillis = min(UtSettings.concreteExecutionDefaultTimeoutInInstrumentedProcessMillis, diff)
concreteExecutor.executeConcretely(methodUnderTest, initialEnvironmentModels, listOf(), timeoutMillis)
} catch (e: CancellationException) {
logger.debug { "Cancelled by timeout" }; null
} catch (e: ConcreteExecutionFailureException) {
Expand Down Expand Up @@ -508,7 +517,8 @@ class UtBotSymbolicEngine(
val concreteExecutionResult = concreteExecutor.executeConcretely(
methodUnderTest,
stateBefore,
instrumentation
instrumentation,
UtSettings.concreteExecutionDefaultTimeoutInInstrumentedProcessMillis
)

if (concreteExecutionResult.violatesUtMockAssumption()) {
Expand All @@ -527,6 +537,10 @@ class UtBotSymbolicEngine(
}
} catch (e: ConcreteExecutionFailureException) {
emitFailedConcreteExecutionResult(stateBefore, e)
} catch (e: CancellationException) {
logger.debug(e) { "Cancellation happened" }
} catch (e: Throwable) {
emit(UtError("Default concrete execution failed", e));
}
}

Expand Down Expand Up @@ -559,14 +573,16 @@ private fun ResolvedModels.constructStateForMethod(methodUnderTest: ExecutableId
private suspend fun ConcreteExecutor<UtConcreteExecutionResult, UtExecutionInstrumentation>.executeConcretely(
methodUnderTest: ExecutableId,
stateBefore: EnvironmentModels,
instrumentation: List<UtInstrumentation>
instrumentation: List<UtInstrumentation>,
timeoutInMillis: Long
): UtConcreteExecutionResult = executeAsync(
methodUnderTest.classId.name,
methodUnderTest.signature,
arrayOf(),
parameters = UtConcreteExecutionData(
stateBefore,
instrumentation
instrumentation,
timeoutInMillis
)
).convertToAssemble(methodUnderTest.classId.packageName)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ object UtBotJavaApi {
arrayOf(),
parameters = UtConcreteExecutionData(
testInfo.initialState,
instrumentation = emptyList()
instrumentation = emptyList(),
UtSettings.concreteExecutionDefaultTimeoutInInstrumentedProcessMillis
)
).result
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ enum class RuntimeExceptionTestsBehaviour(
// Get is mandatory because of the initialization order of the inheritors.
// Otherwise, in some cases we could get an incorrect value
companion object : CodeGenerationSettingBox {
override val defaultItem: RuntimeExceptionTestsBehaviour get() = FAIL
override val defaultItem: RuntimeExceptionTestsBehaviour get() = PASS
override val allItems: List<RuntimeExceptionTestsBehaviour> = values().toList()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,19 +394,14 @@ abstract class CgAbstractRenderer(

val isBlockTooLarge = workaround(LONG_CODE_FRAGMENTS) { block.size > LARGE_CODE_BLOCK_SIZE }

if (isBlockTooLarge) {
print("/*")
println(" This block of code is ${block.size} lines long and could lead to compilation error")
}

withIndent {
for (statement in block) {
statement.accept(this)
if (!isBlockTooLarge) {
withIndent {
for (statement in block) {
statement.accept(this)
}
}
}

if (isBlockTooLarge) println("*/")

print("}")

if (printNextLine) println()
Expand Down Expand Up @@ -959,6 +954,6 @@ abstract class CgAbstractRenderer(
/**
* @see [LONG_CODE_FRAGMENTS]
*/
private const val LARGE_CODE_BLOCK_SIZE: Int = 1000
private const val LARGE_CODE_BLOCK_SIZE: Int = 150
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.utbot.framework.plugin.api.UtPrimitiveModel
import org.utbot.framework.plugin.api.UtStatementModel
import org.utbot.framework.plugin.api.UtSymbolicExecution
import org.utbot.framework.plugin.api.UtVoidModel
import org.utbot.fuzzer.UtFuzzedExecution


/**
Expand Down Expand Up @@ -280,6 +281,6 @@ private fun Throwable.exceptionToInfo(): String =
* See [https://github.com/UnitTestBot/UTBotJava/issues/1504] for more details.
*/
private fun UtExecution.getExecutionPriority(): Int = when (this) {
is UtSymbolicExecution -> 0
is UtFuzzedExecution -> 0
else -> 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ open class TestCaseGenerator(
}
method2executions.getValue(method) += it
}
is UtError -> method2errors.getValue(method).merge(it.description, 1, Int::plus)
is UtError -> {
method2errors.getValue(method).merge(it.description, 1, Int::plus)
logger.error(it.error) { "UtError occurred" }
}
}
}
} catch (e: Exception) {
Expand Down
1 change: 0 additions & 1 deletion utbot-instrumentation-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies {

testImplementation configurations.fetchInstrumentationJar
testImplementation project(':utbot-sample')
testImplementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacocoVersion
implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: rdVersion
implementation group: 'com.jetbrains.rd', name: 'rd-core', version: rdVersion
}
Expand Down
Loading