Skip to content

Commit 1e5d9b8

Browse files
committed
Run on real project, filter out methods with empty cfg
1 parent c84a4b3 commit 1e5d9b8

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

usvm-ts/src/test/kotlin/org/usvm/samples/checkers/UnreachableCodeDetector.kt

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.usvm.samples.checkers
22

3-
import org.jacodb.ets.model.EtsScene
4-
import org.jacodb.ets.utils.loadEtsFileAutoConvert
3+
import org.jacodb.ets.utils.loadEtsProjectFromIR
54
import org.junit.jupiter.api.Test
65
import org.usvm.UMachineOptions
76
import org.usvm.api.checkers.UnreachableCodeDetector
@@ -12,21 +11,27 @@ import org.usvm.util.getResourcePath
1211
class UnreachableCodeDetectorTest {
1312
@Test
1413
fun testUnreachableCode() {
15-
val scene = run {
16-
val name = "UnreachableCode.ts"
17-
val path = getResourcePath("/samples/checkers/$name")
18-
val file = loadEtsFileAutoConvert(
19-
path,
20-
useArkAnalyzerTypeInference = 1
21-
)
22-
EtsScene(listOf(file))
23-
}
14+
// val scene = run {
15+
// val name = "UnreachableCode.ts"
16+
// val path = getResourcePath("/samples/checkers/$name")
17+
// val file = loadEtsFileAutoConvert(
18+
// path,
19+
// useArkAnalyzerTypeInference = 1
20+
// )
21+
// EtsScene(listOf(file))
22+
// }
23+
24+
val path = getResourcePath("/projects/Demo_Calc/etsir")
25+
val scene = loadEtsProjectFromIR(path, null)
2426

2527
val options = UMachineOptions()
2628
val tsOptions = TsOptions(interproceduralAnalysis = false)
2729
val observer = UnreachableCodeDetector()
2830
val machine = TsMachine(scene, options, tsOptions, observer, observer)
29-
val methods = scene.projectClasses.flatMap { it.methods }.filter { it.name == "simpleUnreachableBranch" }
31+
val methods = scene.projectClasses
32+
.flatMap { it.methods }
33+
.filterNot { it.cfg.stmts.isEmpty() }
34+
//.filter { it.name == "simpleUnreachableBranch" }
3035
val results = machine.analyze(methods)
3136

3237
check(results.isNotEmpty())

0 commit comments

Comments
 (0)