Skip to content

Commit 0698fb3

Browse files
committed
Fix after review
1 parent b05d079 commit 0698fb3

File tree

28 files changed

+264
-161
lines changed

28 files changed

+264
-161
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,22 @@ object UtSettings : AbstractSettings(logger, defaultKeyForSettingsPath, defaultS
271271
var useTaintAnalysis by getBooleanProperty(false)
272272

273273
/**
274-
* How deep we should analyze the exceptions.
274+
* If true, [Traverser] will call [TraversalContext.implicitlyThrowException] for [TaintMarksAll],
275+
* even if [TaintMarksSet] is specified, i.e. each taint mark will not be processed separately.
276+
*
277+
* @see [org.utbot.engine.Traverser.processTaintSink]
278+
*/
279+
var ThrowTaintErrorOnlyForAllMarks = false
280+
281+
/**
282+
* How deep we should analyze the throwables.
275283
*/
276-
val exploreExceptionsDepth: ExploreExceptionsDepth
284+
val exploreThrowableDepth: ExploreThrowableDepth
277285
get() =
278286
if (useTaintAnalysis)
279-
ExploreExceptionsDepth.EXPLORE_ALL_STATEMENTS
287+
ExploreThrowableDepth.EXPLORE_ALL_STATEMENTS
280288
else
281-
ExploreExceptionsDepth.SKIP_ALL_STATEMENTS
289+
ExploreThrowableDepth.SKIP_ALL_STATEMENTS
282290

283291
// region engine process debug
284292

@@ -697,17 +705,17 @@ enum class SummariesGenerationType {
697705
}
698706

699707
/**
700-
* Enum to describe how deep we should analyze the exceptions.
708+
* Enum to describe how deep we should analyze the throwables.
701709
*/
702-
enum class ExploreExceptionsDepth {
710+
enum class ExploreThrowableDepth {
703711

704712
/**
705-
* Skip all statements between exception's `new` and `<init>` statements.
713+
* Skip all statements between throwable's `new` and `<init>` statements.
706714
*/
707715
SKIP_ALL_STATEMENTS,
708716

709717
/**
710-
* Skip only exception's <init> statement.
718+
* Skip only throwable's <init> statement.
711719
*/
712720
SKIP_INIT_STATEMENT,
713721

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ data class Step(
102102
}
103103
}
104104

105+
/**
106+
* One symbolic step.
107+
*
108+
* @see UtSymbolicExecution.symbolicSteps
109+
*/
105110
data class SymbolicStep(
106111
val method: SootMethod,
107112
val lineNumber: Int,
@@ -158,7 +163,7 @@ class UtSymbolicExecution(
158163
summary: List<DocStatement>? = null,
159164
testMethodName: String? = null,
160165
displayName: String? = null,
161-
val symbolicSteps: List<SymbolicStep> = listOf(),
166+
/** Convenient view of the full symbolic path */ val symbolicSteps: List<SymbolicStep> = listOf(),
162167
) : UtExecution(stateBefore, stateAfter, result, coverage, summary, testMethodName, displayName) {
163168
/**
164169
* By design the 'before' and 'after' states contain info about the same fields.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ val ExecutableId.humanReadableName: String
545545
return "$executableName($parameters)"
546546
}
547547

548+
val ExecutableId.simpleNameWithClass: String
549+
get() = "${classId.simpleName}.${name}"
550+
548551
val Constructor<*>.displayName: String
549552
get() = executableId.humanReadableName
550553

utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintBranchingTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.TaintAnalysisError
55
import org.utbot.taint.TaintConfigurationProviderResources
66
import org.utbot.testcheckers.eq
7-
import org.utbot.testcheckers.ge
87
import org.utbot.testing.UtValueTestCaseCheckerForTaint
98
import org.utbot.testing.isException
109

@@ -16,16 +15,17 @@ internal class TaintBranchingTest : UtValueTestCaseCheckerForTaint(
1615
fun testTaintBad() {
1716
checkWithException(
1817
TaintBranching::bad,
19-
ge(2), // success & taint error
20-
{ cond, r -> cond == r.isException<TaintAnalysisError>() }
18+
eq(3), // success (x2) & taint error
19+
{ cond, r -> cond == r.isException<TaintAnalysisError>() },
2120
)
2221
}
2322

2423
@Test
2524
fun testTaintGood() {
26-
check(
25+
checkWithException(
2726
TaintBranching::good,
2827
eq(2), // success in both cases
28+
{ _, r -> r.isSuccess },
2929
)
3030
}
3131
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintCleanerConditionsTest.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.TaintAnalysisError
55
import org.utbot.taint.TaintConfigurationProviderResources
66
import org.utbot.testcheckers.eq
7-
import org.utbot.testcheckers.ge
87
import org.utbot.testing.UtValueTestCaseCheckerForTaint
98
import org.utbot.testing.isException
109

@@ -16,50 +15,56 @@ internal class TaintCleanerConditionsTest : UtValueTestCaseCheckerForTaint(
1615
fun testTaintBadArg() {
1716
checkWithException(
1817
TaintCleanerConditions::badArg,
19-
ge(2), // success & taint error
18+
eq(2), // success & taint error
2019
{ r -> r.isException<TaintAnalysisError>() },
20+
{ r -> r.isSuccess },
2121
)
2222
}
2323

2424
@Test
2525
fun testTaintBadReturn() {
2626
checkWithException(
2727
TaintCleanerConditions::badReturn,
28-
ge(2), // success & taint error
28+
eq(2), // success & taint error
2929
{ r -> r.isException<TaintAnalysisError>() },
30+
{ r -> r.isSuccess },
3031
)
3132
}
3233

3334
@Test
3435
fun testTaintBadThis() {
3536
checkWithException(
3637
TaintCleanerConditions::badThis,
37-
ge(2), // success & taint error
38+
eq(2), // success & taint error
3839
{ r -> r.isException<TaintAnalysisError>() },
40+
{ r -> r.isSuccess },
3941
)
4042
}
4143

4244
@Test
4345
fun testTaintGoodArg() {
44-
check(
46+
checkWithException(
4547
TaintCleanerConditions::goodArg,
4648
eq(1), // only success
49+
{ r -> r.isSuccess },
4750
)
4851
}
4952

5053
@Test
5154
fun testTaintGoodReturn() {
52-
check(
55+
checkWithException(
5356
TaintCleanerConditions::goodReturn,
5457
eq(1), // only success
58+
{ r -> r.isSuccess },
5559
)
5660
}
5761

5862
@Test
5963
fun testTaintGoodThis() {
60-
check(
64+
checkWithException(
6165
TaintCleanerConditions::goodThis,
6266
eq(1), // only success
67+
{ r -> r.isSuccess },
6368
)
6469
}
6570
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintCleanerSimpleTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.TaintAnalysisError
55
import org.utbot.taint.TaintConfigurationProviderResources
66
import org.utbot.testcheckers.eq
7-
import org.utbot.testcheckers.ge
87
import org.utbot.testing.UtValueTestCaseCheckerForTaint
98
import org.utbot.testing.isException
109

@@ -16,16 +15,18 @@ internal class TaintCleanerSimpleTest : UtValueTestCaseCheckerForTaint(
1615
fun testTaintBad() {
1716
checkWithException(
1817
TaintCleanerSimple::bad,
19-
ge(2), // success & taint error
18+
eq(2), // success & taint error
2019
{ r -> r.isException<TaintAnalysisError>() },
20+
{ r -> r.isSuccess },
2121
)
2222
}
2323

2424
@Test
2525
fun testTaintGood() {
26-
check(
26+
checkWithException(
2727
TaintCleanerSimple::good,
2828
eq(1), // only success
29+
{ r -> r.isSuccess },
2930
)
3031
}
3132
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintLongPathTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.TaintAnalysisError
55
import org.utbot.taint.TaintConfigurationProviderResources
66
import org.utbot.testcheckers.eq
7-
import org.utbot.testcheckers.ge
87
import org.utbot.testing.UtValueTestCaseCheckerForTaint
98
import org.utbot.testing.isException
109

@@ -16,16 +15,18 @@ internal class TaintLongPathTest : UtValueTestCaseCheckerForTaint(
1615
fun testTaintBad() {
1716
checkWithException(
1817
TaintLongPath::bad,
19-
ge(2), // success & taint error
20-
{ r -> r.isException<TaintAnalysisError>() }
18+
eq(2), // success & taint error
19+
{ r -> r.isException<TaintAnalysisError>() },
20+
{ r -> r.isSuccess },
2121
)
2222
}
2323

2424
@Test
2525
fun testTaintGood() {
26-
check(
26+
checkWithException(
2727
TaintLongPath::good,
2828
eq(1), // only success
29+
{ r -> r.isSuccess },
2930
)
3031
}
3132
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintOtherClassTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.TaintAnalysisError
55
import org.utbot.taint.TaintConfigurationProviderResources
66
import org.utbot.testcheckers.eq
7-
import org.utbot.testcheckers.ge
87
import org.utbot.testing.UtValueTestCaseCheckerForTaint
98
import org.utbot.testing.isException
109

@@ -16,16 +15,18 @@ internal class TaintOtherClassTest : UtValueTestCaseCheckerForTaint(
1615
fun testTaintBad() {
1716
checkWithException(
1817
TaintOtherClass::bad,
19-
ge(2), // success & taint error
18+
eq(2), // success & taint error
2019
{ r -> r.isException<TaintAnalysisError>() },
20+
{ r -> r.isSuccess },
2121
)
2222
}
2323

2424
@Test
2525
fun testTaintGood() {
26-
check(
26+
checkWithException(
2727
TaintOtherClass::good,
2828
eq(1), // only success
29+
{ r -> r.isSuccess },
2930
)
3031
}
3132
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintPassConditionsTest.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.TaintAnalysisError
55
import org.utbot.taint.TaintConfigurationProviderResources
66
import org.utbot.testcheckers.eq
7-
import org.utbot.testcheckers.ge
87
import org.utbot.testing.UtValueTestCaseCheckerForTaint
98
import org.utbot.testing.isException
109

@@ -16,50 +15,56 @@ internal class TaintPassConditionsTest : UtValueTestCaseCheckerForTaint(
1615
fun testTaintBadArg() {
1716
checkWithException(
1817
TaintPassConditions::badArg,
19-
ge(2), // success & taint error
18+
eq(2), // success & taint error
2019
{ r -> r.isException<TaintAnalysisError>() },
20+
{ r -> r.isSuccess },
2121
)
2222
}
2323

2424
@Test
2525
fun testTaintBadReturn() {
2626
checkWithException(
2727
TaintPassConditions::badReturn,
28-
ge(2), // success & taint error
28+
eq(2), // success & taint error
2929
{ r -> r.isException<TaintAnalysisError>() },
30+
{ r -> r.isSuccess },
3031
)
3132
}
3233

3334
@Test
3435
fun testTaintBadThis() {
3536
checkWithException(
3637
TaintPassConditions::badThis,
37-
ge(2), // success & taint error
38+
eq(2), // success & taint error
3839
{ r -> r.isException<TaintAnalysisError>() },
40+
{ r -> r.isSuccess },
3941
)
4042
}
4143

4244
@Test
4345
fun testTaintGoodArg() {
44-
check(
46+
checkWithException(
4547
TaintPassConditions::goodArg,
4648
eq(1), // only success
49+
{ r -> r.isSuccess },
4750
)
4851
}
4952

5053
@Test
5154
fun testTaintGoodReturn() {
52-
check(
55+
checkWithException(
5356
TaintPassConditions::goodReturn,
5457
eq(1), // only success
58+
{ r -> r.isSuccess },
5559
)
5660
}
5761

5862
@Test
5963
fun testTaintGoodThis() {
60-
check(
64+
checkWithException(
6165
TaintPassConditions::goodThis,
6266
eq(1), // only success
67+
{ r -> r.isSuccess },
6368
)
6469
}
6570
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintPassSimpleTest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.TaintAnalysisError
55
import org.utbot.taint.TaintConfigurationProviderResources
66
import org.utbot.testcheckers.eq
7-
import org.utbot.testcheckers.ge
87
import org.utbot.testing.UtValueTestCaseCheckerForTaint
98
import org.utbot.testing.isException
109

@@ -16,25 +15,28 @@ internal class TaintPassSimpleTest : UtValueTestCaseCheckerForTaint(
1615
fun testTaintBad() {
1716
checkWithException(
1817
TaintPassSimple::bad,
19-
ge(2), // success & taint error
18+
eq(2), // success & taint error
2019
{ r -> r.isException<TaintAnalysisError>() },
20+
{ r -> r.isSuccess },
2121
)
2222
}
2323

2424
@Test
2525
fun testTaintBadDoublePass() {
2626
checkWithException(
2727
TaintPassSimple::badDoublePass,
28-
ge(2), // success & taint error
28+
eq(2), // success & taint error
2929
{ r -> r.isException<TaintAnalysisError>() },
30+
{ r -> r.isSuccess },
3031
)
3132
}
3233

3334
@Test
3435
fun testTaintGood() {
35-
check(
36+
checkWithException(
3637
TaintPassSimple::good,
3738
eq(1), // only success
39+
{ r -> r.isSuccess },
3840
)
3941
}
4042
}

0 commit comments

Comments
 (0)