Skip to content

Commit a226ed1

Browse files
minor fixes
1 parent 73d485b commit a226ed1

File tree

23 files changed

+78
-114
lines changed

23 files changed

+78
-114
lines changed

utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,15 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) :
167167
sourceCodeFile: Path? = null,
168168
searchDirectory: Path,
169169
chosenClassesToMockAlways: Set<ClassId>
170-
): List<UtMethodTestSet> {
171-
return testCaseGenerator.generate(
170+
): List<UtMethodTestSet> =
171+
testCaseGenerator.generate(
172172
targetMethods,
173173
mockStrategy,
174174
chosenClassesToMockAlways,
175175
generationTimeout
176176
).map {
177177
if (sourceCodeFile != null) it.summarize(sourceCodeFile.toFile(), searchDirectory) else it
178178
}
179-
}
180179

181180

182181
protected fun withLogger(targetClassFqn: String, block: Runnable) {

utbot-core/src/main/kotlin/org/utbot/common/FileUtil.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ object FileUtil {
9090

9191
for (clazz in classes) {
9292
val path = clazz.toClassFilePath()
93-
val resource =
94-
clazz.classLoader.getResource(path)
95-
?: ClassLoader.getSystemClassLoader().getResource(path)
96-
?: error("No such file: $path")
93+
val resource = clazz.classLoader.getResource(path) ?: error("No such file: $path")
9794

9895
if (resource.toURI().scheme == "jar") {
9996
val jarLocation = resource.toURI().extractJarName()

utbot-core/src/main/kotlin/org/utbot/common/KClassUtil.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import java.lang.reflect.Method
99
*/
1010
fun Method.invokeCatching(obj: Any?, args: List<Any?>) = try {
1111
val invocation = invoke(obj, *args.toTypedArray())
12+
1213
Result.success(invocation)
1314
} catch (e: InvocationTargetException) {
1415
Result.failure<Nothing>(e.targetException)

utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ object UtSettings : AbstractSettings(logger, defaultKeyForSettingsPath, defaultS
239239
/**
240240
* Set to true to start fuzzing if symbolic execution haven't return anything
241241
*/
242-
var useFuzzing: Boolean by getBooleanProperty(false)
242+
var useFuzzing: Boolean by getBooleanProperty(true)
243243

244244
/**
245245
* Set to true to use grey-box fuzzing
@@ -254,7 +254,7 @@ object UtSettings : AbstractSettings(logger, defaultKeyForSettingsPath, defaultS
254254
/**
255255
* Set to true to use UtCompositeModels in grey-box fuzzing process
256256
*/
257-
var useCompositeModelsInGreyBoxFuzzing: Boolean by getBooleanProperty(true)
257+
var useCompositeModelsInGreyBoxFuzzing: Boolean by getBooleanProperty(false)
258258

259259
/**
260260
* Set the total attempts to improve coverage by fuzzer.

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/UtExecutionResult.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.utbot.framework.plugin.api
22

3-
import org.utbot.framework.plugin.api.util.objectClassId
43
import org.utbot.framework.plugin.api.visible.UtStreamConsumingException
54
import java.io.File
65
import java.util.LinkedList

utbot-framework/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ dependencies {
3535
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlinLoggingVersion
3636
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacocoVersion
3737
implementation group: 'org.apache.commons', name: 'commons-text', version: apacheCommonsTextVersion
38-
implementation "org.javaruntype:javaruntype:1.3"
39-
implementation "ru.vyarus:generics-resolver:3.0.3"
40-
implementation "ognl:ognl:3.3.2"
41-
4238
// we need this for construction mocks from composite models
4339
implementation group: 'org.mockito', name: 'mockito-core', version: '4.2.0'
4440

utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ import org.utbot.framework.UtSettings.pathSelectorStepsLimit
3232
import org.utbot.framework.UtSettings.pathSelectorType
3333
import org.utbot.framework.UtSettings.processUnknownStatesDuringConcreteExecution
3434
import org.utbot.framework.UtSettings.useDebugVisualization
35-
import org.utbot.framework.concrete.*
35+
import org.utbot.framework.concrete.UtConcreteExecutionData
36+
import org.utbot.framework.concrete.UtConcreteExecutionResult
37+
import org.utbot.framework.concrete.UtExecutionInstrumentation
3638
import org.utbot.framework.concrete.constructors.UtModelConstructor
39+
import org.utbot.framework.concrete.FuzzerConcreteExecutor
3740
import org.utbot.framework.plugin.api.*
3841
import org.utbot.framework.plugin.api.Step
3942
import org.utbot.framework.plugin.api.util.*
@@ -45,11 +48,10 @@ import org.utbot.fuzzing.utils.Trie
4548
import org.utbot.greyboxfuzzer.GreyBoxFuzzer
4649
import org.utbot.greyboxfuzzer.util.FuzzerUtModelConstructor
4750
import org.utbot.instrumentation.ConcreteExecutor
48-
import ru.vyarus.java.generics.resolver.context.GenericsInfoFactory
4951
import soot.jimple.Stmt
5052
import soot.tagkit.ParamNamesTag
5153
import java.lang.reflect.Method
52-
import java.util.*
54+
import java.util.IdentityHashMap
5355
import kotlin.system.measureTimeMillis
5456

5557
val logger = KotlinLogging.logger {}
@@ -336,7 +338,7 @@ class UtBotSymbolicEngine(
336338
fun fuzzing(until: Long = Long.MAX_VALUE, transform: (JavaValueProvider) -> JavaValueProvider = { it }) = flow {
337339
val isFuzzable = methodUnderTest.parameters.all { classId ->
338340
classId != Method::class.java.id && // causes the instrumented process crash at invocation
339-
classId != Class::class.java.id // causes java.lang.IllegalAccessException: java.lang.Class at sun.misc.Unsafe.allocateInstance(Native Method)
341+
classId != Class::class.java.id // causes java.lang.IllegalAccessException: java.lang.Class at sun.misc.Unsafe.allocateInstance(Native Method)
340342
}
341343
val hasMethodUnderTestParametersToFuzz = methodUnderTest.parameters.isNotEmpty()
342344
if (!isFuzzable || !hasMethodUnderTestParametersToFuzz && methodUnderTest.isStatic) {
@@ -421,7 +423,6 @@ class UtBotSymbolicEngine(
421423
//Simple fuzzing
422424
fun greyBoxFuzzing(timeBudget: Long = Long.MAX_VALUE) =
423425
flow {
424-
GenericsInfoFactory.disableCache()
425426
val isFuzzable = methodUnderTest.parameters.all { classId ->
426427
classId != Method::class.java.id // causes the child process crash at invocation
427428
}

utbot-framework/src/main/kotlin/org/utbot/engine/ValueConstructor.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import org.utbot.framework.plugin.api.UtValueExecutionState
4040
import org.utbot.framework.plugin.api.UtVoidModel
4141
import org.utbot.framework.plugin.api.isMockModel
4242
import org.utbot.framework.plugin.api.util.constructor
43-
import org.utbot.framework.plugin.api.util.id
4443
import org.utbot.framework.plugin.api.util.isStatic
4544
import org.utbot.framework.plugin.api.util.jField
4645
import org.utbot.framework.plugin.api.util.jClass

utbot-framework/src/main/kotlin/org/utbot/framework/concrete/FuzzerConcreteExecutor.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@ class FuzzerConcreteExecutor(
1818
stateBefore: EnvironmentModels,
1919
instrumentation: List<UtInstrumentation>
2020
): UtFuzzingConcreteExecutionResult {
21-
// val fuzzingExecutor =
22-
// ConcreteExecutor(
23-
// UtFuzzingExecutionInstrumentation/*(UtSettings.greyBoxFuzzingCompetitionMode)*/,
24-
// pathsToUserClasses,
25-
// pathsToDependencyClasses
26-
// ).apply { this.classLoader = utContext.classLoader }
27-
// val executionResult = fuzzingExecutor.executeConcretelyFuzz(methodUnderTest, stateBefore, instrumentation)
28-
// return UtFuzzingConcreteExecutionResult(
29-
// null,
30-
// executionResult.result,
31-
// executionResult.coverage,
32-
// executionResult.methodInstructionsIds
33-
// )
3421
return if (UtSettings.greyBoxFuzzingCompetitionMode) {
3522
val fuzzingExecutor =
3623
ConcreteExecutor(

utbot-framework/src/main/kotlin/org/utbot/framework/concrete/UtExecutionInstrumentation.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import org.utbot.framework.concrete.phases.start
1313
import org.utbot.framework.plugin.api.Coverage
1414
import org.utbot.framework.plugin.api.EnvironmentModels
1515
import org.utbot.framework.plugin.api.FieldId
16-
import org.utbot.framework.plugin.api.Instruction
1716
import org.utbot.framework.plugin.api.UtAssembleModel
1817
import org.utbot.framework.plugin.api.UtExecutionResult
1918
import org.utbot.framework.plugin.api.UtExecutionSuccess
@@ -23,7 +22,6 @@ import org.utbot.framework.plugin.api.util.singleExecutableId
2322
import org.utbot.instrumentation.instrumentation.ArgumentList
2423
import org.utbot.instrumentation.instrumentation.Instrumentation
2524
import org.utbot.instrumentation.instrumentation.InvokeInstrumentation
26-
import org.utbot.instrumentation.instrumentation.et.EtInstruction
2725
import org.utbot.instrumentation.instrumentation.et.TraceHandler
2826
import org.utbot.instrumentation.instrumentation.instrumenter.Instrumenter
2927
import org.utbot.instrumentation.instrumentation.mock.MockClassVisitor
@@ -235,12 +233,3 @@ object UtExecutionInstrumentation : Instrumentation<UtConcreteExecutionResult> {
235233
return instrumenter.classByteCode
236234
}
237235
}
238-
239-
/**
240-
* Transforms a list of internal [EtInstruction]s to a list of api [Instruction]s.
241-
*/
242-
internal fun List<EtInstruction>.toApiCoverage(instructionsCount: Long? = null): Coverage =
243-
Coverage(
244-
map { Instruction(it.className, it.methodSignature, it.line, it.id) },
245-
instructionsCount
246-
)

0 commit comments

Comments
 (0)