()
while (true) {
- val res = logger.trace().bracket("Low level check(): ", { it }) {
+ val res = logger.trace().measureTime({ "Low level check(): " }, { it }) {
val constraintsToCheck = translatedSoft.keys + translatedAssumptions.keys
z3Solver.check(*constraintsToCheck.toTypedArray())
}
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt
index e3eff3556b..fba77160ec 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt
@@ -1899,22 +1899,6 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
methodType = this@CgMethodConstructor.methodType
val docComment = currentExecution?.summary?.map { convertDocToCg(it) }?.toMutableList() ?: mutableListOf()
- // add JVM crash report path if exists
- if (result is UtConcreteExecutionFailure) {
- result.extractJvmReportPathOrNull()?.let {
- val jvmReportDocumentation = CgDocRegularStmt(getJvmReportDocumentation(it))
- val lastTag = docComment.lastOrNull()
- // if the last statement is a tag, put the path inside it
- if (lastTag == null || lastTag !is CgDocPreTagStatement) {
- docComment += jvmReportDocumentation
- } else {
- val tagContent = lastTag.content
- docComment.removeLast()
- docComment += CgDocPreTagStatement(tagContent + jvmReportDocumentation)
- }
- }
- }
-
documentation = CgDocumentationComment(docComment)
documentation = if (parameterized) {
CgDocumentationComment(text = null)
@@ -1970,18 +1954,6 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
return CgSimpleRegion("Errors report for ${executable.name}", listOf(errorTestMethod))
}
- private fun getJvmReportDocumentation(jvmReportPath: String): String {
- val pureJvmReportPath = jvmReportPath.substringAfter("# ")
-
- // \n is here because IntellijIdea cannot process other separators
- return PathUtil.toHtmlLinkTag(PathUtil.replaceSeparator(pureJvmReportPath), fileName = "JVM crash report") + "\n"
- }
-
- private fun UtConcreteExecutionFailure.extractJvmReportPathOrNull(): String? =
- exception.processStdout.singleOrNull {
- "hs_err_pid" in it
- }
-
private fun CgExecutableCall.wrapReflectiveCall() {
+tryBlock {
+this@wrapReflectiveCall
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt
index f3e04bd7b6..454c3e5865 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt
@@ -10,7 +10,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.yield
import mu.KLogger
import mu.KotlinLogging
-import org.utbot.common.bracket
+import org.utbot.common.measureTime
import org.utbot.common.runBlockingWithCancellationPredicate
import org.utbot.common.runIgnoringCancellationException
import org.utbot.common.trace
@@ -79,7 +79,7 @@ open class TestCaseGenerator(
System.setProperty(kotlinx.coroutines.DEBUG_PROPERTY_NAME, kotlinx.coroutines.DEBUG_PROPERTY_VALUE_OFF)
}
- timeoutLogger.trace().bracket("Soot initialization") {
+ timeoutLogger.trace().measureTime({ "Soot initialization"} ) {
SootUtils.runSoot(buildDirs, classpath, forceSootReload, jdkInfo)
}
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt
index 616c8a871d..f870126799 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt
@@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.id
import org.utbot.sarif.SarifReport
import org.utbot.sarif.SourceFindingStrategy
-import org.utbot.summary.summarize
+import org.utbot.summary.summarizeAll
import java.io.File
import java.nio.file.Path
@@ -59,9 +59,7 @@ class GenerateTestsAndSarifReportFacade(
sarifProperties.mockStrategy,
sarifProperties.classesToMockAlways,
sarifProperties.generationTimeout
- ).map {
- it.summarize(workingDirectory, targetClass.sourceCodeFile)
- }
+ ).summarizeAll(workingDirectory, targetClass.sourceCodeFile)
private fun generateTestCode(targetClass: TargetClassWrapper, testSets: List): String =
initializeCodeGenerator(targetClass)
diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineProcessMain.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineProcessMain.kt
index 01c880caea..49fc11bab7 100644
--- a/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineProcessMain.kt
+++ b/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineProcessMain.kt
@@ -6,10 +6,7 @@ import com.jetbrains.rd.util.lifetime.Lifetime
import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.utbot.analytics.AnalyticsConfigureUtil
-import org.utbot.common.AbstractSettings
-import org.utbot.common.allNestedClasses
-import org.utbot.common.appendHtmlLine
-import org.utbot.common.nameOfPackage
+import org.utbot.common.*
import org.utbot.engine.util.mockListeners.ForceMockListener
import org.utbot.engine.util.mockListeners.ForceStaticMockListener
import org.utbot.framework.codegen.*
@@ -40,7 +37,7 @@ import org.utbot.rd.generated.settingsModel
import org.utbot.rd.loggers.UtRdKLoggerFactory
import org.utbot.sarif.RdSourceFindingStrategyFacade
import org.utbot.sarif.SarifReport
-import org.utbot.summary.summarize
+import org.utbot.summary.summarizeAll
import java.io.File
import java.net.URLClassLoader
import java.nio.file.Paths
@@ -50,21 +47,25 @@ import kotlin.time.Duration.Companion.seconds
private val messageFromMainTimeoutMillis = 120.seconds
private val logger = KotlinLogging.logger {}
+@Suppress("unused")
+object EngineProcessMain
+
// use log4j2.configurationFile property to set log4j configuration
suspend fun main(args: Array) = runBlocking {
+ Logger.set(Lifetime.Eternal, UtRdKLoggerFactory(logger))
+
+ logger.info("-----------------------------------------------------------------------")
+ logger.info("-------------------NEW ENGINE PROCESS STARTED--------------------------")
+ logger.info("-----------------------------------------------------------------------")
// 0 - auto port for server, should not be used here
val port = findRdPort(args)
- Logger.set(Lifetime.Eternal, UtRdKLoggerFactory(logger))
ClientProtocolBuilder().withProtocolTimeout(messageFromMainTimeoutMillis).start(port) {
AbstractSettings.setupFactory(RdSettingsContainerFactory(protocol.settingsModel))
val kryoHelper = KryoHelper(lifetime)
engineProcessModel.setup(kryoHelper, it, protocol)
}
- logger.info { "runBlocking ending" }
-}.also {
- logger.info { "runBlocking ended" }
}
private lateinit var testGenerator: TestCaseGenerator
@@ -74,12 +75,12 @@ private var idCounter: Long = 0
private fun EngineProcessModel.setup(kryoHelper: KryoHelper, watchdog: IdleWatchdog, realProtocol: IProtocol) {
val model = this
- watchdog.wrapActiveCall(setupUtContext) { params ->
+ watchdog.measureTimeForActiveCall(setupUtContext, "UtContext setup") { params ->
UtContext.setUtContext(UtContext(URLClassLoader(params.classpathForUrlsClassloader.map {
File(it).toURI().toURL()
}.toTypedArray())))
}
- watchdog.wrapActiveCall(createTestGenerator) { params ->
+ watchdog.measureTimeForActiveCall(createTestGenerator, "Creating Test Generator") { params ->
AnalyticsConfigureUtil.configureML()
Instrumenter.adapter = RdInstrumenter(realProtocol.rdInstrumenterAdapter)
testGenerator = TestCaseGenerator(buildDirs = params.buildDir.map { Paths.get(it) },
@@ -92,37 +93,38 @@ private fun EngineProcessModel.setup(kryoHelper: KryoHelper, watchdog: IdleWatch
}
})
}
- watchdog.wrapActiveCall(generate) { params ->
- val mockFrameworkInstalled = params.mockInstalled
- val conflictTriggers = ConflictTriggers(kryoHelper.readObject(params.conflictTriggers))
- if (!mockFrameworkInstalled) {
- ForceMockListener.create(testGenerator, conflictTriggers, cancelJob = true)
- }
- val staticsMockingConfigured = params.staticsMockingIsConfigureda
- if (!staticsMockingConfigured) {
- ForceStaticMockListener.create(testGenerator, conflictTriggers, cancelJob = true)
- }
- val result = testGenerator.generate(kryoHelper.readObject(params.methods),
- MockStrategyApi.valueOf(params.mockStrategy),
- kryoHelper.readObject(params.chosenClassesToMockAlways),
- params.timeout,
- generate = testFlow {
- generationTimeout = params.generationTimeout
- isSymbolicEngineEnabled = params.isSymbolicEngineEnabled
- isFuzzingEnabled = params.isFuzzingEnabled
- fuzzingValue = params.fuzzingValue
- })
- .apply { logger.info("generation ended, starting summarization, result size: ${this.size}") }
- .map { it.summarize(Paths.get(params.searchDirectory), sourceFile = null) }
- .apply { logger.info("summarization ended") }
- .filterNot { it.executions.isEmpty() && it.errors.isEmpty() }
+ watchdog.measureTimeForActiveCall(generate, "Generating tests") { params ->
+ val methods: List = kryoHelper.readObject(params.methods)
+ logger.debug().measureTime({ "starting generation for ${methods.size} methods, starting with ${methods.first()}" }) {
+ val mockFrameworkInstalled = params.mockInstalled
+ val conflictTriggers = ConflictTriggers(kryoHelper.readObject(params.conflictTriggers))
+ if (!mockFrameworkInstalled) {
+ ForceMockListener.create(testGenerator, conflictTriggers, cancelJob = true)
+ }
+ val staticsMockingConfigured = params.staticsMockingIsConfigureda
+ if (!staticsMockingConfigured) {
+ ForceStaticMockListener.create(testGenerator, conflictTriggers, cancelJob = true)
+ }
+ val result = testGenerator.generate(methods,
+ MockStrategyApi.valueOf(params.mockStrategy),
+ kryoHelper.readObject(params.chosenClassesToMockAlways),
+ params.timeout,
+ generate = testFlow {
+ generationTimeout = params.generationTimeout
+ isSymbolicEngineEnabled = params.isSymbolicEngineEnabled
+ isFuzzingEnabled = params.isFuzzingEnabled
+ fuzzingValue = params.fuzzingValue
+ })
+ .summarizeAll(Paths.get(params.searchDirectory), null)
+ .filterNot { it.executions.isEmpty() && it.errors.isEmpty() }
- val id = ++idCounter
+ val id = ++idCounter
- testSets[id] = result
- GenerateResult(result.size, id)
+ testSets[id] = result
+ GenerateResult(result.size, id)
+ }
}
- watchdog.wrapActiveCall(render) { params ->
+ watchdog.measureTimeForActiveCall(render, "Rendering tests") { params ->
val testFramework = testFrameworkByName(params.testFramework)
val staticMocking = if (params.staticsMocking.startsWith("No")) {
NoStaticMocking
@@ -147,37 +149,32 @@ private fun EngineProcessModel.setup(kryoHelper: KryoHelper, watchdog: IdleWatch
enableTestsTimeout = params.enableTestsTimeout,
testClassPackageName = params.testClassPackageName
)
- codeGenerator.generateAsStringWithTestReport(testSets[testSetsId]!!)
- .let {
- testGenerationReports.add(it.testsGenerationReport)
- RenderResult(it.generatedCode, it.utilClassKind?.javaClass?.simpleName)
- }
+ codeGenerator.generateAsStringWithTestReport(testSets[testSetsId]!!).let {
+ testGenerationReports.add(it.testsGenerationReport)
+ RenderResult(it.generatedCode, it.utilClassKind?.javaClass?.simpleName)
+ }
}
- watchdog.wrapActiveCall(stopProcess) { watchdog.stopProtocol() }
- watchdog.wrapActiveCall(obtainClassId) { canonicalName ->
+ watchdog.measureTimeForActiveCall(obtainClassId, "Obtain class id in UtContext") { canonicalName ->
kryoHelper.writeObject(UtContext.currentContext()!!.classLoader.loadClass(canonicalName).id)
}
- watchdog.wrapActiveCall(findMethodsInClassMatchingSelected) { params ->
+ watchdog.measureTimeForActiveCall(findMethodsInClassMatchingSelected, "Find methods in Class") { params ->
val classId = kryoHelper.readObject(params.classId)
val selectedMethodDescriptions =
params.methodDescriptions.map { MethodDescription(it.name, it.containingClass, it.parametersTypes) }
FindMethodsInClassMatchingSelectedResult(kryoHelper.writeObject(classId.jClass.allNestedClasses.flatMap { clazz ->
clazz.id.allMethods.mapNotNull { it.method.kotlinFunction }
.sortedWith(compareBy { selectedMethodDescriptions.indexOf(it.methodDescription()) })
- .filter { it.methodDescription().normalized() in selectedMethodDescriptions }
- .map { it.executableId }
+ .filter { it.methodDescription().normalized() in selectedMethodDescriptions }.map { it.executableId }
}))
}
- watchdog.wrapActiveCall(findMethodParamNames) { params ->
+ watchdog.measureTimeForActiveCall(findMethodParamNames, "Find method parameters names") { params ->
val classId = kryoHelper.readObject(params.classId)
val byMethodDescription = kryoHelper.readObject