From 7392e6ddf3b5280496678cef6217f1ad84b79aa8 Mon Sep 17 00:00:00 2001 From: DaniilStepanov Date: Tue, 24 Jan 2023 19:18:16 +0300 Subject: [PATCH] rebase --- .../main/kotlin/org/utbot/common/FileUtil.kt | 5 +- .../kotlin/org/utbot/framework/UtSettings.kt | 10 +- .../framework/plugin/api/UtExecutionResult.kt | 6 + .../framework/plugin/api/util/UtContext.kt | 4 +- .../org/utbot/engine/UtBotSymbolicEngine.kt | 13 +- .../org/utbot/external/api/UtBotJavaApi.kt | 2 +- .../codegen/domain/context/CgContext.kt | 3 +- .../codegen/domain/models/CgElement.kt | 2 +- .../codegen/renderer/CgAbstractRenderer.kt | 10 +- .../codegen/renderer/CgJavaRenderer.kt | 5 - .../framework/MockFrameworkManager.kt | 160 +++++++++++++----- .../utbot/framework/codegen/tree/Builders.kt | 2 +- .../codegen/tree/CgMethodConstructor.kt | 25 +-- .../codegen/tree/CgVariableConstructor.kt | 33 ++-- .../utbot/framework/codegen/util/DslUtil.kt | 2 - .../framework/plugin/api/TestCaseGenerator.kt | 4 +- .../org/utbot/framework/util/SootUtils.kt | 5 - .../org/utbot/fuzzer/FuzzerFunctions.kt | 2 +- .../org/utbot/greyboxfuzzer/GreyBoxFuzzer.kt | 7 +- .../util/UtGreyBoxFuzzedExecution.kt | 8 +- .../instrumentation/et/TraceHandler.kt | 2 +- .../instrumentation/et/TraceListStrategy.kt | 2 +- .../execution/FuzzerConcreteExecutor.kt | 35 ++-- .../execution/UtExecutionInstrumentation.kt | 17 +- ...utionInstrumentationWithStatsCollection.kt | 15 +- .../UtFuzzingExecutionInstrumentation.kt | 16 +- .../BigNumberConstructor.kt | 6 +- .../{ => constructors}/BitSetConstructor.kt | 6 +- .../DateTimeConstructors.kt | 5 +- .../{ => constructors}/LocaleConstructor.kt | 6 +- .../{ => constructors}/UUIDConstructor.kt | 5 +- .../UtAssembleModelConstructors.kt | 1 - 32 files changed, 223 insertions(+), 201 deletions(-) rename utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/{ => constructors}/BigNumberConstructor.kt (75%) rename utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/{ => constructors}/BitSetConstructor.kt (80%) rename utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/{ => constructors}/DateTimeConstructors.kt (98%) rename utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/{ => constructors}/LocaleConstructor.kt (80%) rename utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/{ => constructors}/UUIDConstructor.kt (82%) diff --git a/utbot-core/src/main/kotlin/org/utbot/common/FileUtil.kt b/utbot-core/src/main/kotlin/org/utbot/common/FileUtil.kt index 6cc649f37f..d0f6a3ab0a 100644 --- a/utbot-core/src/main/kotlin/org/utbot/common/FileUtil.kt +++ b/utbot-core/src/main/kotlin/org/utbot/common/FileUtil.kt @@ -90,7 +90,10 @@ object FileUtil { for (clazz in classes) { val path = clazz.toClassFilePath() - val resource = clazz.classLoader.getResource(path) ?: error("No such file: $path") + val resource = + clazz.classLoader.getResource(path) + ?: ClassLoader.getSystemClassLoader().getResource(path) + ?: error("No such file: $path") if (resource.toURI().scheme == "jar") { val jarLocation = resource.toURI().extractJarName() diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt index c6a3498b6b..68267044d3 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt @@ -245,17 +245,17 @@ object UtSettings : AbstractSettings(logger, defaultKeyForSettingsPath, defaultS /** * Set to true to use grey-box fuzzing */ - var useGreyBoxFuzzing: Boolean by getBooleanProperty(true) + var useGreyBoxFuzzing: Boolean by getBooleanProperty(false) /** - * Set to true to use grey-box fuzzing in competition mode (without asserts generation) + * Set to true to use UtCompositeModels in grey-box fuzzing process */ - var greyBoxFuzzingCompetitionMode: Boolean by getBooleanProperty(true) + var useCompositeModelsInGreyBoxFuzzing: Boolean by getBooleanProperty(false) /** - * Set to true to use UtCompositeModels in grey-box fuzzing process + * Set to true to use grey-box fuzzing in competition mode (without asserts generation) */ - var useCompositeModelsInGreyBoxFuzzing: Boolean by getBooleanProperty(false) + var greyBoxFuzzingCompetitionMode: Boolean by getBooleanProperty(false) /** * Set the total attempts to improve coverage by fuzzer. diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/UtExecutionResult.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/UtExecutionResult.kt index df26014027..07b7487d3d 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/UtExecutionResult.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/UtExecutionResult.kt @@ -1,5 +1,6 @@ package org.utbot.framework.plugin.api +import org.utbot.framework.plugin.api.util.objectClassId import org.utbot.framework.plugin.api.visible.UtStreamConsumingException import java.io.File import java.util.LinkedList @@ -105,6 +106,11 @@ inline fun UtExecutionResult.onFailure(action: (exception: Throwable) -> Unit): return this } +fun UtExecutionResult.getOrThrow(): UtModel = when (this) { + is UtExecutionSuccess -> model + is UtExecutionFailure -> throw exception +} + fun UtExecutionResult.exceptionOrNull(): Throwable? = when (this) { is UtExecutionFailure -> rootCauseException is UtExecutionSuccess -> null diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/UtContext.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/UtContext.kt index ad064bfb3a..9152d986c3 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/UtContext.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/UtContext.kt @@ -5,7 +5,7 @@ import org.utbot.common.currentThreadInfo import org.utbot.framework.plugin.api.util.UtContext.Companion.setUtContext import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.ThreadContextElement -//import mu.KotlinLogging +import mu.KotlinLogging val utContext: UtContext get() = UtContext.currentContext() @@ -75,7 +75,7 @@ inline fun withUtContext(context: UtContext, block: () -> T): T = setUtConte try { return@use block.invoke() } catch (e: Exception) { - //KotlinLogging.logger("withUtContext").error { e } + KotlinLogging.logger("withUtContext").error { e } throw e } } diff --git a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt index ef1f593b4e..16327b99f8 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt @@ -32,13 +32,9 @@ import org.utbot.framework.UtSettings.pathSelectorStepsLimit import org.utbot.framework.UtSettings.pathSelectorType import org.utbot.framework.UtSettings.processUnknownStatesDuringConcreteExecution import org.utbot.framework.UtSettings.useDebugVisualization -import org.utbot.framework.concrete.UtConcreteExecutionData -import org.utbot.framework.concrete.UtConcreteExecutionResult -import org.utbot.framework.concrete.UtExecutionInstrumentation -import org.utbot.framework.concrete.UtFuzzingExecutionInstrumentation import org.utbot.framework.concrete.FuzzerConcreteExecutor -import org.utbot.framework.concrete.constructors.UtModelConstructor -import org.utbot.framework.concrete.phases.ValueConstructionContext +import org.utbot.framework.concrete.UtFuzzingExecutionInstrumentation +import org.utbot.framework.util.convertToAssemble import org.utbot.framework.plugin.api.* import org.utbot.framework.plugin.api.Step import org.utbot.framework.plugin.api.util.* @@ -53,6 +49,8 @@ import org.utbot.instrumentation.ConcreteExecutor import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionData import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionResult import org.utbot.instrumentation.instrumentation.execution.UtExecutionInstrumentation +import org.utbot.instrumentation.instrumentation.execution.constructors.UtModelConstructor +import org.utbot.instrumentation.instrumentation.execution.phases.ValueConstructionContext import soot.jimple.Stmt import soot.tagkit.ParamNamesTag import java.lang.reflect.Method @@ -447,8 +445,7 @@ class UtBotSymbolicEngine( collectConstantsForGreyBoxFuzzer(methodUnderTest.sootMethod, utModelConstructor), fuzzerUtModelConstructor, FuzzerConcreteExecutor( - concreteExecutor.pathsToUserClasses, - concreteExecutor.pathsToDependencyClasses + concreteExecutor.pathsToUserClasses )::execute, ValueConstructionContext(UtFuzzingExecutionInstrumentation.instrumentationContext, true)::constructParameters, timeBudget diff --git a/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt b/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt index 0112b6aae0..cc942b7a7d 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt @@ -70,7 +70,7 @@ object UtBotJavaApi { val concreteExecutor = ConcreteExecutor( UtExecutionInstrumentation, - classpath, + classpath ) testSets.addAll(generateUnitTests(concreteExecutor, methodsForGeneration, classUnderTest)) diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/context/CgContext.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/context/CgContext.kt index cc3b736644..356d07270a 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/context/CgContext.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/context/CgContext.kt @@ -551,9 +551,8 @@ data class CgContext( } } - private var nestedClassIndex = 0 private fun createClassIdForNestedClass(testClassModel: TestClassModel): ClassId { - val simpleName = "${testClassModel.classUnderTest.simpleName}Test${nestedClassIndex++}" + val simpleName = "${testClassModel.classUnderTest.simpleName}Test" return BuiltinClassId( canonicalName = currentTestClass.canonicalName + "." + simpleName, simpleName = simpleName, diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt index b68f751b13..ba98a9fd4c 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt @@ -134,7 +134,7 @@ class CgClass( val body: CgClassBody, val isStatic: Boolean, val isNested: Boolean, -): CgStatement { +): CgElement { val packageName get() = id.packageName diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgAbstractRenderer.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgAbstractRenderer.kt index f2dd9f1fff..a2b7056f05 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgAbstractRenderer.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgAbstractRenderer.kt @@ -623,15 +623,7 @@ abstract class CgAbstractRenderer( is Boolean -> toStringConstant() // String is "\"" + "str" + "\"", RawString is "str" is String -> if (asRawString) "$this".escapeCharacters() else toStringConstant() - else -> { - val t = this@toStringConstant.type - val illegalType = t.toString().contains("$") || !t.isPublic - if (this == null && UtSettings.greyBoxFuzzingCompetitionMode && !illegalType) { - "(${this@toStringConstant.type}) null" - } else { - "$this" - } - } + else -> "$this" } } diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt index 6493d8df5a..b6371cac60 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt @@ -238,11 +238,6 @@ internal class CgJavaRenderer(context: CgRendererContext, printer: CgPrinter = C renderExceptions(element) } - private fun getTypeStringRepresentation(typeId: ClassId): String = - when { - typeId.isArray -> getTypeStringRepresentation(typeId.elementClassId!!) + "[]" - else -> typeId.toString() - } override fun renderMethodSignature(element: CgMockMethod) { val returnType = element.returnType.asString() diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/MockFrameworkManager.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/MockFrameworkManager.kt index 6b9892a971..0e8c05a7ce 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/MockFrameworkManager.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/MockFrameworkManager.kt @@ -20,30 +20,78 @@ import org.utbot.framework.codegen.domain.builtin.thenReturnMethodId import org.utbot.framework.codegen.domain.builtin.whenMethodId import org.utbot.framework.codegen.domain.context.CgContext import org.utbot.framework.codegen.domain.context.CgContextOwner -import org.utbot.framework.codegen.domain.models.* +import org.utbot.framework.codegen.domain.models.CgAnnotation +import org.utbot.framework.codegen.domain.models.CgAnonymousFunction +import org.utbot.framework.codegen.domain.models.CgAssignment +import org.utbot.framework.codegen.domain.models.CgClass +import org.utbot.framework.codegen.domain.models.CgClassBody +import org.utbot.framework.codegen.domain.models.CgConstructorCall +import org.utbot.framework.codegen.domain.models.CgDeclaration +import org.utbot.framework.codegen.domain.models.CgDocumentationComment +import org.utbot.framework.codegen.domain.models.CgExecutableCall +import org.utbot.framework.codegen.domain.models.CgExpression +import org.utbot.framework.codegen.domain.models.CgLiteral +import org.utbot.framework.codegen.domain.models.CgMethodCall +import org.utbot.framework.codegen.domain.models.CgMethodsCluster +import org.utbot.framework.codegen.domain.models.CgMockMethod +import org.utbot.framework.codegen.domain.models.CgParameterDeclaration +import org.utbot.framework.codegen.domain.models.CgRunnable +import org.utbot.framework.codegen.domain.models.CgSimpleRegion +import org.utbot.framework.codegen.domain.models.CgStatement +import org.utbot.framework.codegen.domain.models.CgStatementExecutableCall +import org.utbot.framework.codegen.domain.models.CgStaticRunnable +import org.utbot.framework.codegen.domain.models.CgSwitchCase +import org.utbot.framework.codegen.domain.models.CgSwitchCaseLabel +import org.utbot.framework.codegen.domain.models.CgValue +import org.utbot.framework.codegen.domain.models.CgVariable import org.utbot.framework.codegen.services.access.CgCallableAccessManager import org.utbot.framework.codegen.services.access.CgCallableAccessManagerImpl import org.utbot.framework.codegen.tree.* +import org.utbot.framework.codegen.tree.buildClassBody +import org.utbot.framework.codegen.tree.CgStatementConstructor +import org.utbot.framework.codegen.tree.CgVariableConstructor import org.utbot.framework.codegen.tree.CgStatementConstructorImpl import org.utbot.framework.codegen.tree.CgTestClassConstructor.CgComponents.getVariableConstructorBy import org.utbot.framework.codegen.tree.hasAmbiguousOverloadsOf import org.utbot.framework.codegen.util.isAccessibleFrom -import org.utbot.framework.plugin.api.* -import org.utbot.framework.plugin.api.util.* -import java.lang.IllegalStateException +import org.utbot.framework.plugin.api.BuiltinClassId +import org.utbot.framework.plugin.api.ClassId +import org.utbot.framework.plugin.api.ConstructorId +import org.utbot.framework.plugin.api.ExecutableId +import org.utbot.framework.plugin.api.MethodId +import org.utbot.framework.plugin.api.TypeParameters +import org.utbot.framework.plugin.api.UtCompositeModel +import org.utbot.framework.plugin.api.UtModel +import org.utbot.framework.plugin.api.UtNewInstanceInstrumentation +import org.utbot.framework.plugin.api.UtStaticMethodInstrumentation +import org.utbot.framework.plugin.api.util.atomicIntegerClassId +import org.utbot.framework.plugin.api.util.atomicIntegerGet +import org.utbot.framework.plugin.api.util.atomicIntegerGetAndIncrement +import org.utbot.framework.plugin.api.util.booleanClassId +import org.utbot.framework.plugin.api.util.byteClassId +import org.utbot.framework.plugin.api.util.charClassId +import org.utbot.framework.plugin.api.util.doubleClassId +import org.utbot.framework.plugin.api.util.floatClassId +import org.utbot.framework.plugin.api.util.id +import org.utbot.framework.plugin.api.util.intClassId +import org.utbot.framework.plugin.api.util.longClassId +import org.utbot.framework.plugin.api.util.shortClassId +import org.utbot.framework.plugin.api.util.voidClassId +import org.utbot.framework.plugin.api.util.isRefType +import org.utbot.framework.plugin.api.util.exceptions abstract class CgVariableConstructorComponent(val context: CgContext) : - CgContextOwner by context, - CgCallableAccessManager by CgCallableAccessManagerImpl(context), - CgStatementConstructor by CgStatementConstructorImpl(context) { + CgContextOwner by context, + CgCallableAccessManager by CgCallableAccessManagerImpl(context), + CgStatementConstructor by CgStatementConstructorImpl(context) { val variableConstructor: CgVariableConstructor by lazy { getVariableConstructorBy(context) } fun mockitoArgumentMatchersFor(executable: ExecutableId): Array = - executable.parameters.map { - val matcher = it.mockitoAnyMatcher(executable.classId.hasAmbiguousOverloadsOf(executable)) - if (matcher != anyOfClass) argumentMatchersClassId[matcher]() else matchByClass(it) - }.toTypedArray() + executable.parameters.map { + val matcher = it.mockitoAnyMatcher(executable.classId.hasAmbiguousOverloadsOf(executable)) + if (matcher != anyOfClass) argumentMatchersClassId[matcher]() else matchByClass(it) + }.toTypedArray() /** * Clears all resources required for [currentExecution]. @@ -63,24 +111,27 @@ abstract class CgVariableConstructorComponent(val context: CgContext) : } fun ClassId.mockitoAnyMatcher(withExplicitClass: Boolean): MethodId = - when (this) { - byteClassId -> anyByte - charClassId -> anyChar - shortClassId -> anyShort - intClassId -> anyInt - longClassId -> anyLong - floatClassId -> anyFloat - doubleClassId -> anyDouble - booleanClassId -> anyBoolean - // we cannot match by string here - // because anyString accepts only non-nullable strings but argument could be null - else -> if (withExplicitClass) anyOfClass else any - } + when (this) { + byteClassId -> anyByte + charClassId -> anyChar + shortClassId -> anyShort + intClassId -> anyInt + longClassId -> anyLong + floatClassId -> anyFloat + doubleClassId -> anyDouble + booleanClassId -> anyBoolean + // we cannot match by string here + // because anyString accepts only non-nullable strings but argument could be null + else -> if (withExplicitClass) anyOfClass else any + } private fun matchByClass(id: ClassId): CgMethodCall = - argumentMatchersClassId[anyOfClass](getClassOf(id)) + argumentMatchersClassId[anyOfClass](getClassOf(id)) } +/** + * Experimental in-place mocker + */ private class InPlaceMocker(context: CgContext) : ObjectMocker(context) { private var mockID = 0 @@ -124,7 +175,8 @@ private class InPlaceMocker(context: CgContext) : ObjectMocker(context) { } }.catch(Throwable::class.id) { throwStatement { - val constructor = IllegalStateException::class.java.id.allConstructors.first { it.parameters.isEmpty() } + val constructor = + IllegalStateException::class.java.id.allConstructors.first { it.parameters.isEmpty() } constructor() } } @@ -136,14 +188,14 @@ private class InPlaceMocker(context: CgContext) : ObjectMocker(context) { ) } val methodsCluster = CgSimpleRegion(null, methods) - val declaration = buildClass { + val classDeclaration = buildClass { id = mockClassId interfaces.add(model.classId) body = buildClassBody(mockClassId) { methodRegions += CgMethodsCluster(header = null, content = listOf(methodsCluster)) } } - currentBlock += declaration + currentBlock += CgClassAsStatement(classDeclaration) ++mockID val constructorId = ConstructorId(mockClassId, emptyList()) return newVar(model.classId, baseName) { @@ -159,11 +211,39 @@ private class InPlaceMocker(context: CgContext) : ObjectMocker(context) { TODO("Not yet implemented") } + private class CgClassAsStatement( + val id: ClassId, + val documentation: CgDocumentationComment?, + val annotations: List, + val superclass: ClassId?, + val interfaces: List, + val body: CgClassBody, + val isStatic: Boolean, + val isNested: Boolean + ) : CgStatement { + constructor(cgClass: CgClass) : this( + cgClass.id, + cgClass.documentation, + cgClass.annotations, + cgClass.superclass, + cgClass.interfaces, + cgClass.body, + cgClass.isStatic, + cgClass.isNested + ) + + val packageName + get() = id.packageName + + val simpleName + get() = id.simpleName + } + } class MockFrameworkManager(context: CgContext) : CgVariableConstructorComponent(context) { - private val objectMocker = InPlaceMocker(context) + private val objectMocker = MockitoMocker(context) private val staticMocker = when (context.staticsMocking) { is NoStaticMocking -> null is MockitoStaticMocking -> MockitoStaticMocker(context, objectMocker) @@ -197,7 +277,7 @@ class MockFrameworkManager(context: CgContext) : CgVariableConstructorComponent( } private abstract class ObjectMocker( - context: CgContext + context: CgContext ) : CgVariableConstructorComponent(context) { abstract fun createMock(model: UtCompositeModel, baseName: String): CgVariable @@ -207,7 +287,7 @@ private abstract class ObjectMocker( } private abstract class StaticMocker( - context: CgContext + context: CgContext ) : CgVariableConstructorComponent(context) { abstract fun mockNewInstance(mock: UtNewInstanceInstrumentation) abstract fun mockStaticMethodsOfClass(classId: ClassId, methodMocks: List) @@ -229,7 +309,7 @@ private class MockitoMocker(context: CgContext) : ObjectMocker(context) { when (executable) { is MethodId -> { if (executable.parameters.any { !it.isAccessibleFrom(testClassPackageName) }) { - error("Cannot mock method $executable with not accessible parameters") + error("Cannot mock method $executable with not accessible parameters" ) } val matchers = mockitoArgumentMatchersFor(executable) @@ -240,7 +320,6 @@ private class MockitoMocker(context: CgContext) : ObjectMocker(context) { val results = values.map { variableConstructor.getOrCreateVariable(it) }.toTypedArray() `when`(mockObject[executable](*matchers)).thenReturn(executable.returnType, *results) } - else -> error("ConstructorId was not expected to appear in simple mocker but got $executable") } } @@ -249,10 +328,10 @@ private class MockitoMocker(context: CgContext) : ObjectMocker(context) { } override fun mock(clazz: CgExpression): CgMethodCall = - mockitoClassId[mockMethodId](clazz) + mockitoClassId[mockMethodId](clazz) override fun `when`(call: CgExecutableCall): CgMethodCall = - mockitoClassId[whenMethodId](call) + mockitoClassId[whenMethodId](call) } private class MockitoStaticMocker(context: CgContext, private val mocker: ObjectMocker) : StaticMocker(context) { @@ -298,7 +377,7 @@ private class MockitoStaticMocker(context: CgContext, private val mocker: Object override fun mockStaticMethodsOfClass(classId: ClassId, methodMocks: List) { for ((methodId, values) in methodMocks) { if (methodId.parameters.any { !it.isAccessibleFrom(testClassPackageName) }) { - error("Cannot mock static method $methodId with not accessible parameters") + error("Cannot mock static method $methodId with not accessible parameters" ) } val matchers = mockitoArgumentMatchersFor(methodId) @@ -313,10 +392,10 @@ private class MockitoStaticMocker(context: CgContext, private val mocker: Object listOf( CgStatementExecutableCall( CgMethodCall( - caller = null, - methodId, - matchers.toList() - ) + caller = null, + methodId, + matchers.toList() + ) ) ) ) @@ -386,7 +465,6 @@ private class MockitoStaticMocker(context: CgContext, private val mocker: Object mocker.`when`(mockParameter[executable](*matchers))[thenReturnMethodId](*results) ) } - else -> error("Expected MethodId but got ConstructorId $executable") } } diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt index ce858d1c93..90b5d0b54e 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/Builders.kt @@ -85,7 +85,7 @@ interface CgMethodBuilder : CgBuilder { class CgTestMethodBuilder : CgMethodBuilder { override lateinit var name: String - override var returnType: ClassId = voidClassId + override val returnType: ClassId = voidClassId override lateinit var parameters: List override lateinit var statements: List override val exceptions: MutableSet = mutableSetOf() 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 2ea3f42a5f..8d98e8bcd5 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 @@ -5,7 +5,6 @@ import org.utbot.common.WorkaroundReason import org.utbot.common.isStatic import org.utbot.common.workaround import org.utbot.engine.ArtificialError -import org.utbot.engine.OverflowDetectionError import org.utbot.greyboxfuzzer.util.UtGreyBoxFuzzedExecution import org.utbot.framework.assemble.assemble import org.utbot.framework.codegen.domain.ForceStaticMocking @@ -1453,28 +1452,14 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte } } - if (UtSettings.greyBoxFuzzingCompetitionMode) { + if (statics.isNotEmpty()) { +tryBlock { - if (statics.isNotEmpty()) { - +tryBlock { - mainBody() - }.finally { - recoverStaticFields() - } - } else { - mainBody() - } - }.catch(Throwable::class.id) {} - } else { - if (statics.isNotEmpty()) { - +tryBlock { - mainBody() - }.finally { - recoverStaticFields() - } - } else { mainBody() + }.finally { + recoverStaticFields() } + } else { + mainBody() } mockFrameworkManager.getAndClearMethodResources()?.let { resources -> diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgVariableConstructor.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgVariableConstructor.kt index b264c4b37e..cf5d44ed9d 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgVariableConstructor.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgVariableConstructor.kt @@ -98,12 +98,7 @@ open class CgVariableConstructor(val context: CgContext) : } } else valueByModel.getOrPut(model) { when (model) { - is UtNullModel -> - if (UtSettings.greyBoxFuzzingCompetitionMode && !model.classId.name.contains("Zilch")) { - nullLiteralWithCast(model.classId) - } else { - nullLiteral() - } + is UtNullModel -> nullLiteral() is UtPrimitiveModel -> CgLiteral(model.classId, model.value) is UtReferenceModel -> error("Unexpected UtReferenceModel: ${model::class}") is UtVoidModel -> error("Unexpected UtVoidModel: ${model::class}") @@ -202,18 +197,22 @@ open class CgVariableConstructor(val context: CgContext) : is UtDirectSetFieldModel -> { val instance = declareOrGet(statementModel.instance) // fields here are supposed to be accessible, so we assign them directly without any checks - val fieldValue = declareOrGet(statementModel.fieldModel) - if (statementModel.fieldId.canBeSetFrom(context) && fieldValue.type isSubtypeOf statementModel.fieldId.type) { - instance[statementModel.fieldId] `=` fieldValue - } else { - with(statementModel) { - +utilsClassId[setField]( - instance, - fieldId.declaringClass.name, - fieldId.name, - fieldValue - ) + if (UtSettings.useGreyBoxFuzzing) { + val fieldValue = declareOrGet(statementModel.fieldModel) + if (statementModel.fieldId.canBeSetFrom(context) && fieldValue.type isSubtypeOf statementModel.fieldId.type) { + instance[statementModel.fieldId] `=` fieldValue + } else { + with(statementModel) { + +utilsClassId[setField]( + instance, + fieldId.declaringClass.name, + fieldId.name, + fieldValue + ) + } } + } else { + instance[statementModel.fieldId] `=` declareOrGet(statementModel.fieldModel) } } is UtExecutableCallModel -> { diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/util/DslUtil.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/util/DslUtil.kt index 2429d6b0ac..228654457d 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/util/DslUtil.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/util/DslUtil.kt @@ -46,8 +46,6 @@ infix fun CgExpression.greaterThan(other: Any?): CgGreaterThan = // TODO: is it OK to use Object as a type of null literal? fun nullLiteral() = CgLiteral(objectClassId, null) -fun nullLiteralWithCast(classId: ClassId) = CgLiteral(classId, null) - fun intLiteral(num: Int) = CgLiteral(intClassId, num) fun longLiteral(num: Long) = CgLiteral(longClassId, num) 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 50f0443849..b0832725c4 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 @@ -17,7 +17,6 @@ import org.utbot.common.trace import org.utbot.engine.EngineController import org.utbot.engine.Mocker import org.utbot.engine.UtBotSymbolicEngine -import org.utbot.engine.greyboxfuzzer.util.GreyBoxFuzzingStatisticPrinter import org.utbot.engine.util.mockListeners.ForceMockListener import org.utbot.engine.util.mockListeners.ForceStaticMockListener import org.utbot.framework.TestSelectionStrategyType @@ -36,7 +35,6 @@ import org.utbot.framework.util.ConflictTriggers import org.utbot.framework.util.SootUtils import org.utbot.framework.util.jimpleBody import org.utbot.framework.util.toModel -import org.utbot.framework.util.sootMethodExists import org.utbot.greyboxfuzzer.util.CoverageCollector import org.utbot.greyboxfuzzer.util.GreyBoxFuzzingStatisticPrinter import org.utbot.instrumentation.ConcreteExecutor @@ -238,7 +236,7 @@ open class TestCaseGenerator( if (UtSettings.useGreyBoxFuzzing) { GreyBoxFuzzingStatisticPrinter.printFuzzingStats(method2executions) } - return methods.filter { it.sootMethodExists }.map { method -> + return methods.map { method -> UtMethodTestSet( method, minimizeExecutions(method2executions.getValue(method)), diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt index 33f78f9760..e95e76f5ea 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt @@ -122,11 +122,6 @@ private fun initSoot(buildDirs: List, classpath: String?, jdkInfo: JdkInfo fun JimpleBody.graph() = ExceptionalUnitGraph(this) -val ExecutableId.sootMethodExists: Boolean - get() { - val clazz = Scene.v().getSootClass(classId.name) - return clazz.methods.any { it.pureJavaSignature == signature } - } val ExecutableId.sootMethod: SootMethod get() { val clazz = Scene.v().getSootClass(classId.name) diff --git a/utbot-framework/src/main/kotlin/org/utbot/fuzzer/FuzzerFunctions.kt b/utbot-framework/src/main/kotlin/org/utbot/fuzzer/FuzzerFunctions.kt index 6a050f12cb..562d3e8759 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/fuzzer/FuzzerFunctions.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/fuzzer/FuzzerFunctions.kt @@ -1,7 +1,6 @@ package org.utbot.fuzzer import mu.KotlinLogging -import org.utbot.framework.concrete.constructors.UtModelConstructor import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.UtModel import org.utbot.framework.plugin.api.classId @@ -22,6 +21,7 @@ import org.utbot.framework.plugin.api.util.intWrapperClassId import org.utbot.framework.plugin.api.util.longWrapperClassId import org.utbot.framework.plugin.api.util.shortWrapperClassId import org.utbot.framework.util.executableId +import org.utbot.instrumentation.instrumentation.execution.constructors.UtModelConstructor import soot.BooleanType import soot.ByteType import soot.CharType diff --git a/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/GreyBoxFuzzer.kt b/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/GreyBoxFuzzer.kt index 2ccf05838c..1fcf72ccef 100644 --- a/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/GreyBoxFuzzer.kt +++ b/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/GreyBoxFuzzer.kt @@ -20,6 +20,7 @@ import org.utbot.greyboxfuzzer.mutator.Seed import org.utbot.greyboxfuzzer.mutator.SeedCollector import org.utbot.greyboxfuzzer.quickcheck.generator.GeneratorContext import org.utbot.greyboxfuzzer.util.* +import org.utbot.instrumentation.instrumentation.execution.UtFuzzingConcreteExecutionResult import ru.vyarus.java.generics.resolver.context.GenericsInfoFactory import java.lang.reflect.Executable import java.lang.reflect.Field @@ -135,7 +136,7 @@ class GreyBoxFuzzer( logger.debug { "Execution of ${methodUnderTest.name} started" } val executionResult = (executor::invoke)(methodUnderTest, stateBefore, listOf()) if (methodInstructions == null && executionResult.methodInstructions != null) { - methodInstructions = executionResult.methodInstructions.toSet() + methodInstructions = executionResult.methodInstructions!!.toSet() } logger.debug { "Execution of ${methodUnderTest.name} result: $executionResult" } val seedCoverage = getCoverage(executionResult.coverage) @@ -160,7 +161,7 @@ class GreyBoxFuzzer( if (executionResult.stateAfter != null) { UtFuzzedExecution( stateBefore = newStateBefore, - stateAfter = executionResult.stateAfter, + stateAfter = executionResult.stateAfter!!, result = executionResult.result, coverage = executionResult.coverage, fuzzingValues = generatedParameters.map { FuzzedValue(it.utModel) }, @@ -241,7 +242,7 @@ class GreyBoxFuzzer( if (executionResult.stateAfter != null) { UtFuzzedExecution( stateBefore = newStateBefore, - stateAfter = executionResult.stateAfter, + stateAfter = executionResult.stateAfter!!, result = executionResult.result, coverage = executionResult.coverage, fuzzingValues = mutatedSeed.parameters.map { FuzzedValue(it.utModel) }, diff --git a/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/util/UtGreyBoxFuzzedExecution.kt b/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/util/UtGreyBoxFuzzedExecution.kt index a3d3d308c2..5837b97b6a 100644 --- a/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/util/UtGreyBoxFuzzedExecution.kt +++ b/utbot-greyboxfuzzer/src/main/kotlin/org/utbot/greyboxfuzzer/util/UtGreyBoxFuzzedExecution.kt @@ -1,13 +1,7 @@ package org.utbot.greyboxfuzzer.util import org.utbot.framework.plugin.api.* - -class UtFuzzingConcreteExecutionResult( - val stateAfter: EnvironmentModels?, - val result: UtExecutionResult, - val coverage: Coverage, - val methodInstructions: List? = null -) +import org.utbot.instrumentation.instrumentation.execution.UtFuzzingConcreteExecutionResult //class UtFuzzExecutionResult() : UtConcreteExecutionResult diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceHandler.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceHandler.kt index 2f57abebd0..e377adf17a 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceHandler.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceHandler.kt @@ -63,7 +63,7 @@ class ProcessingStorage { private val classMethodToId = mutableMapOf() private val idToClassMethod = mutableMapOf() - private val instructionsData = mutableMapOf() + val instructionsData = mutableMapOf() private val classToInstructionsCount = mutableMapOf() fun addClass(className: String): Int { diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceListStrategy.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceListStrategy.kt index 157ea89605..6ffd449bb6 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceListStrategy.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/et/TraceListStrategy.kt @@ -10,7 +10,7 @@ import org.objectweb.asm.commons.LocalVariablesSorter class TraceListStrategy( private val className: String, - private val storage: ProcessingStorage, + val storage: ProcessingStorage, private val inserter: TraceInstructionBytecodeInserter ) : IInstructionVisitor { var currentLine: Int = 0 diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/FuzzerConcreteExecutor.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/FuzzerConcreteExecutor.kt index 3551287910..b1434a279c 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/FuzzerConcreteExecutor.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/FuzzerConcreteExecutor.kt @@ -5,27 +5,35 @@ import org.utbot.framework.plugin.api.EnvironmentModels import org.utbot.framework.plugin.api.ExecutableId import org.utbot.framework.plugin.api.UtInstrumentation import org.utbot.framework.plugin.api.util.utContext -import org.utbot.greyboxfuzzer.util.UtFuzzingConcreteExecutionResult import org.utbot.instrumentation.ConcreteExecutor +import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionData +import org.utbot.instrumentation.instrumentation.execution.UtFuzzingConcreteExecutionResult class FuzzerConcreteExecutor( private val pathsToUserClasses: String, - private val pathsToDependencyClasses: String, ) { + private val concreteExecutor = + if (UtSettings.greyBoxFuzzingCompetitionMode) { + ConcreteExecutor( + UtFuzzingExecutionInstrumentation, + pathsToUserClasses, + ).apply { this.classLoader = utContext.classLoader } + } else { + ConcreteExecutor( + UtFuzzingExecutionInstrumentationWithStateAfterCollection, + pathsToUserClasses, + ).apply { this.classLoader = utContext.classLoader } + } + suspend fun execute( methodUnderTest: ExecutableId, stateBefore: EnvironmentModels, instrumentation: List ): UtFuzzingConcreteExecutionResult { return if (UtSettings.greyBoxFuzzingCompetitionMode) { - val fuzzingExecutor = - ConcreteExecutor( - UtFuzzingExecutionInstrumentation, - pathsToUserClasses, - pathsToDependencyClasses - ).apply { this.classLoader = utContext.classLoader } - val executionResult = fuzzingExecutor.executeConcretelyFuzz(methodUnderTest, stateBefore, instrumentation) + val executor = concreteExecutor as ConcreteExecutor + val executionResult = executor.executeConcretelyFuzz(methodUnderTest, stateBefore, instrumentation) UtFuzzingConcreteExecutionResult( null, executionResult.result, @@ -33,13 +41,8 @@ class FuzzerConcreteExecutor( executionResult.methodInstructions ) } else { - val fuzzingExecutor = - ConcreteExecutor( - UtFuzzingExecutionInstrumentationWithStateAfterCollection, - pathsToUserClasses, - pathsToDependencyClasses - ).apply { this.classLoader = utContext.classLoader } - val executionResult = fuzzingExecutor.executeConcretelyFuzzWithStateAfterCollection( + val executor = concreteExecutor as ConcreteExecutor + val executionResult = executor.executeConcretelyFuzzWithStateAfterCollection( methodUnderTest, stateBefore, instrumentation diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentation.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentation.kt index e178ce225a..accb4f3321 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentation.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentation.kt @@ -12,7 +12,7 @@ import org.utbot.instrumentation.instrumentation.execution.phases.start import org.utbot.framework.plugin.api.Coverage import org.utbot.framework.plugin.api.EnvironmentModels import org.utbot.framework.plugin.api.FieldId -import org.utbot.framework.plugin.api.UtAssembleModel +import org.utbot.framework.plugin.api.Instruction import org.utbot.framework.plugin.api.UtExecutionResult import org.utbot.framework.plugin.api.UtInstrumentation import org.utbot.framework.plugin.api.UtModel @@ -51,6 +51,12 @@ class UtConcreteExecutionResult( } } +class UtFuzzingConcreteExecutionResult( + val stateAfter: EnvironmentModels?, + val result: UtExecutionResult, + val coverage: Coverage, + val methodInstructions: List? = null +) object UtExecutionInstrumentation : Instrumentation { private val delegateInstrumentation = InvokeInstrumentation() @@ -191,12 +197,3 @@ object UtExecutionInstrumentation : Instrumentation { return instrumenter.classByteCode } } - -/** - * Transforms a list of internal [EtInstruction]s to a list of api [Instruction]s. - */ -internal fun List.toApiCoverage(instructionsCount: Long? = null): Coverage = - Coverage( - map { Instruction(it.className, it.methodSignature, it.line, it.id) }, - instructionsCount - ) diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentationWithStatsCollection.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentationWithStatsCollection.kt index 335f880c1f..2bb8b0c069 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentationWithStatsCollection.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentationWithStatsCollection.kt @@ -1,17 +1,16 @@ package org.utbot.framework.concrete -import org.utbot.framework.concrete.constructors.ConstructOnlyUserClassesOrCachedObjectsStrategy -import org.utbot.framework.concrete.constructors.UtModelConstructor -import org.utbot.framework.concrete.mock.InstrumentationContext import org.utbot.framework.plugin.api.* -import org.utbot.greyboxfuzzer.util.UtFuzzingConcreteExecutionResult import org.utbot.instrumentation.instrumentation.Instrumentation import org.utbot.instrumentation.instrumentation.InvokeInstrumentation import org.utbot.instrumentation.instrumentation.et.ExplicitThrowInstruction import org.utbot.instrumentation.instrumentation.et.TraceHandler +import org.utbot.instrumentation.instrumentation.execution.UtFuzzingConcreteExecutionResult +import org.utbot.instrumentation.instrumentation.execution.constructors.ConstructOnlyUserClassesOrCachedObjectsStrategy +import org.utbot.instrumentation.instrumentation.execution.constructors.UtModelConstructor +import org.utbot.instrumentation.instrumentation.execution.mock.InstrumentationContext import org.utbot.instrumentation.instrumentation.instrumenter.Instrumenter import org.utbot.instrumentation.instrumentation.mock.MockClassVisitor -import org.utbot.framework.concrete.mock.InstrumentationContext.MockGetter import java.security.AccessControlException import java.security.ProtectionDomain import java.util.* @@ -78,9 +77,9 @@ interface UtExecutionInstrumentationWithStatsCollection : Instrumentation MockClassVisitor( writer, - MockGetter::getMock.javaMethod!!, - MockGetter::checkCallSite.javaMethod!!, - MockGetter::hasMock.javaMethod!! + InstrumentationContext.MockGetter::getMock.javaMethod!!, + InstrumentationContext.MockGetter::checkCallSite.javaMethod!!, + InstrumentationContext.MockGetter::hasMock.javaMethod!! ) } diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtFuzzingExecutionInstrumentation.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtFuzzingExecutionInstrumentation.kt index 57a172ac38..7020822a61 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtFuzzingExecutionInstrumentation.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtFuzzingExecutionInstrumentation.kt @@ -1,17 +1,18 @@ package org.utbot.framework.concrete import org.objectweb.asm.Type -import org.utbot.framework.concrete.constructors.ConstructOnlyUserClassesOrCachedObjectsStrategy -import org.utbot.framework.concrete.mock.InstrumentationContext -import org.utbot.framework.concrete.phases.PhaseError -import org.utbot.framework.concrete.phases.PhasesController -import org.utbot.framework.concrete.phases.start import org.utbot.framework.plugin.api.* import org.utbot.framework.plugin.api.util.* -import org.utbot.greyboxfuzzer.util.UtFuzzingConcreteExecutionResult import org.utbot.instrumentation.instrumentation.ArgumentList import org.utbot.instrumentation.instrumentation.InvokeInstrumentation import org.utbot.instrumentation.instrumentation.et.TraceHandler +import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionData +import org.utbot.instrumentation.instrumentation.execution.UtFuzzingConcreteExecutionResult +import org.utbot.instrumentation.instrumentation.execution.constructors.ConstructOnlyUserClassesOrCachedObjectsStrategy +import org.utbot.instrumentation.instrumentation.execution.mock.InstrumentationContext +import org.utbot.instrumentation.instrumentation.execution.phases.PhaseError +import org.utbot.instrumentation.instrumentation.execution.phases.PhasesController +import org.utbot.instrumentation.instrumentation.execution.phases.start import java.security.AccessControlException object UtFuzzingExecutionInstrumentation : UtExecutionInstrumentationWithStatsCollection { @@ -22,6 +23,7 @@ object UtFuzzingExecutionInstrumentation : UtExecutionInstrumentationWithStatsCo override val traceHandler: TraceHandler = TraceHandler() override val pathsToUserClasses: MutableSet = mutableSetOf() + override fun invoke( clazz: Class<*>, methodSignature: String, @@ -206,4 +208,4 @@ private inline fun PhasesController.computeFuzzingConcreteExecutionResult(block: throw e } } -} +} \ No newline at end of file diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/BigNumberConstructor.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/BigNumberConstructor.kt similarity index 75% rename from utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/BigNumberConstructor.kt rename to utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/BigNumberConstructor.kt index 1735b2b468..63bcec156e 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/BigNumberConstructor.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/BigNumberConstructor.kt @@ -1,10 +1,6 @@ -package org.utbot.framework.concrete +package org.utbot.instrumentation.instrumentation.execution.constructors -import org.utbot.framework.concrete.constructors.UtAssembleModelConstructorBase -import org.utbot.framework.concrete.constructors.UtModelConstructorInterface -import org.utbot.framework.concrete.constructors.checkClassCast import org.utbot.framework.plugin.api.* -import org.utbot.framework.plugin.api.util.id import org.utbot.framework.plugin.api.util.jClass import org.utbot.framework.plugin.api.util.stringClassId diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/BitSetConstructor.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/BitSetConstructor.kt similarity index 80% rename from utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/BitSetConstructor.kt rename to utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/BitSetConstructor.kt index d1360f6728..e588887eb3 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/BitSetConstructor.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/BitSetConstructor.kt @@ -1,13 +1,9 @@ -package org.utbot.framework.concrete +package org.utbot.instrumentation.instrumentation.execution.constructors -import org.utbot.framework.concrete.constructors.UtAssembleModelConstructorBase -import org.utbot.framework.concrete.constructors.UtModelConstructorInterface -import org.utbot.framework.concrete.constructors.checkClassCast import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.UtAssembleModel import org.utbot.framework.plugin.api.UtExecutableCallModel import org.utbot.framework.plugin.api.UtStatementModel -import org.utbot.framework.plugin.api.util.id import org.utbot.framework.plugin.api.util.jClass import org.utbot.framework.plugin.api.util.longArrayClassId import org.utbot.framework.plugin.api.util.methodId diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/DateTimeConstructors.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/DateTimeConstructors.kt similarity index 98% rename from utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/DateTimeConstructors.kt rename to utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/DateTimeConstructors.kt index 588ae22435..d40f9cff2b 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/DateTimeConstructors.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/DateTimeConstructors.kt @@ -1,8 +1,5 @@ -package org.utbot.framework.concrete +package org.utbot.instrumentation.instrumentation.execution.constructors -import org.utbot.framework.concrete.constructors.UtAssembleModelConstructorBase -import org.utbot.framework.concrete.constructors.UtModelConstructorInterface -import org.utbot.framework.concrete.constructors.checkClassCast import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.UtAssembleModel import org.utbot.framework.plugin.api.UtExecutableCallModel diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/LocaleConstructor.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/LocaleConstructor.kt similarity index 80% rename from utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/LocaleConstructor.kt rename to utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/LocaleConstructor.kt index fd5a38ae40..6626151846 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/LocaleConstructor.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/LocaleConstructor.kt @@ -1,13 +1,9 @@ -package org.utbot.framework.concrete +package org.utbot.instrumentation.instrumentation.execution.constructors -import org.utbot.framework.concrete.constructors.UtAssembleModelConstructorBase -import org.utbot.framework.concrete.constructors.UtModelConstructorInterface -import org.utbot.framework.concrete.constructors.checkClassCast import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.UtAssembleModel import org.utbot.framework.plugin.api.UtExecutableCallModel import org.utbot.framework.plugin.api.UtStatementModel -import org.utbot.framework.plugin.api.util.id import org.utbot.framework.plugin.api.util.jClass import org.utbot.framework.plugin.api.util.methodId import org.utbot.framework.plugin.api.util.stringClassId diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UUIDConstructor.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UUIDConstructor.kt similarity index 82% rename from utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UUIDConstructor.kt rename to utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UUIDConstructor.kt index d21962a44d..a61121c5e0 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UUIDConstructor.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UUIDConstructor.kt @@ -1,8 +1,5 @@ -package org.utbot.framework.concrete +package org.utbot.instrumentation.instrumentation.execution.constructors -import org.utbot.framework.concrete.constructors.UtAssembleModelConstructorBase -import org.utbot.framework.concrete.constructors.UtModelConstructorInterface -import org.utbot.framework.concrete.constructors.checkClassCast import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.UtAssembleModel import org.utbot.framework.plugin.api.UtExecutableCallModel diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtAssembleModelConstructors.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtAssembleModelConstructors.kt index d758d1ac81..2850cf5632 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtAssembleModelConstructors.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtAssembleModelConstructors.kt @@ -1,6 +1,5 @@ package org.utbot.instrumentation.instrumentation.execution.constructors -import org.utbot.framework.concrete.* import java.util.stream.BaseStream import java.util.stream.DoubleStream import java.util.stream.IntStream