Skip to content

Commit 5c8c4c5

Browse files
committed
Improved tests, readability fixes and a corrected typo
1 parent 183b642 commit 5c8c4c5

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ val classToWrapper: MutableMap<TypeToBeWrapped, WrapperType> =
8888
putSootClass(java.util.stream.Stream::class, UT_STREAM.className)
8989
// TODO primitive streams https://github.com/UnitTestBot/UTBotJava/issues/146
9090

91-
putSootClass(java.lang.SecurityManager::class, utSecurityManagerClass)
91+
putSootClass(java.lang.SecurityManager::class, UtSecurityManager::class)
9292
}
9393

9494
/**

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import soot.Scene
1010
import soot.SootClass
1111
import soot.SootMethod
1212

13-
val utSecurityManagerClass: SootClass
14-
get() = Scene.v().getSootClass(UtSecurityManager::class.qualifiedName)
15-
1613
class SecurityManagerWrapper : BaseOverriddenWrapper(utSecurityManagerClass.name) {
1714
private val baseModelName: String = "securityManager"
1815

@@ -34,4 +31,9 @@ class SecurityManagerWrapper : BaseOverriddenWrapper(utSecurityManagerClass.name
3431
val modificationChain = mutableListOf<UtStatementModel>()
3532
return UtAssembleModel(addr, classId, modelName, instantiationChain, modificationChain)
3633
}
34+
35+
companion object {
36+
val utSecurityManagerClass: SootClass
37+
get() = Scene.v().getSootClass(UtSecurityManager::class.qualifiedName)
38+
}
3739
}

utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/JvmCrashExamplesTest.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ import org.utbot.examples.withoutSandbox
99
import org.utbot.framework.codegen.CodeGeneration
1010
import org.utbot.framework.plugin.api.CodegenLanguage
1111

12-
internal class JvmCrashExamplesTest : UtValueTestCaseChecker(
13-
testClass = JvmCrashExamples::class,
14-
testCodeGeneration = true,
15-
languagePipelines = listOf(
16-
CodeGenerationLanguageLastStage(CodegenLanguage.JAVA),
17-
CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN, CodeGeneration)
18-
)
19-
) {
12+
internal class JvmCrashExamplesTest : UtValueTestCaseChecker(testClass = JvmCrashExamples::class) {
2013
@Test
2114
@Disabled("JIRA:1527")
2215
fun testExit() {
@@ -32,6 +25,7 @@ internal class JvmCrashExamplesTest : UtValueTestCaseChecker(
3225
check(
3326
JvmCrashExamples::crash,
3427
eq(1), // we expect only one execution after minimization
28+
// It seems that we can't calculate coverage when the child JVM has crashed
3529
coverage = DoNotCalculate
3630
)
3731
}
@@ -42,6 +36,7 @@ internal class JvmCrashExamplesTest : UtValueTestCaseChecker(
4236
check(
4337
JvmCrashExamples::crashPrivileged,
4438
eq(1), // we expect only one execution after minimization
39+
// It seems that we can't calculate coverage when the child JVM has crashed
4540
coverage = DoNotCalculate
4641
)
4742
}

utbot-framework/src/test/kotlin/org/utbot/examples/unsafe/UnsafeOperationsTest.kt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,17 @@ import org.utbot.framework.codegen.CodeGeneration
99
import org.utbot.framework.plugin.api.CodegenLanguage
1010
import org.utbot.framework.plugin.api.MockStrategyApi
1111

12-
internal class UnsafeOperationsTest : UtValueTestCaseChecker(
13-
testClass = UnsafeOperations::class,
14-
testCodeGeneration = true,
15-
languagePipelines = listOf(
16-
CodeGenerationLanguageLastStage(CodegenLanguage.JAVA),
17-
CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN, CodeGeneration)
18-
)
19-
) {
12+
internal class UnsafeOperationsTest : UtValueTestCaseChecker(testClass = UnsafeOperations::class) {
2013
@Test
2114
fun checkGetAddressSizeOrZero() {
2215
withoutSandbox {
2316
check(
2417
UnsafeOperations::getAddressSizeOrZero,
2518
eq(1),
26-
{ r -> r == 8 },
27-
coverage = DoNotCalculate
19+
{ r -> r!! > 0 },
20+
// Coverage matcher fails (branches: 0/0, instructions: 15/21, lines: 0/0)
21+
// TODO: check coverage calculation
22+
// coverage = DoNotCalculate
2823
)
2924
}
3025
}
@@ -35,8 +30,10 @@ internal class UnsafeOperationsTest : UtValueTestCaseChecker(
3530
check(
3631
UnsafeOperations::getAddressSizeOrZero,
3732
eq(1),
38-
{ r -> r == 8 },
39-
coverage = DoNotCalculate,
33+
{ r -> r!! > 0 },
34+
// Coverage matcher fails (branches: 0/0, instructions: 15/21, lines: 0/0)
35+
// TODO: check coverage calculation
36+
// coverage = DoNotCalculate,
4037
mockStrategy = MockStrategyApi.OTHER_CLASSES
4138
)
4239
}

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcess.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private fun log(any: Any?) {
4949
private val kryoHelper: KryoHelper = KryoHelper(System.`in`, System.`out`)
5050

5151
/**
52-
* Command-line option do disable the sandbox
52+
* Command-line option to disable the sandbox
5353
*/
5454
const val DISABLE_SANDBOX_OPTION = "--disable-sandbox"
5555

0 commit comments

Comments
 (0)