Skip to content

Commit

Permalink
Merge pull request #119 from edwin1729/master
Browse files Browse the repository at this point in the history
Coverage and minimization bug fixes
  • Loading branch information
AbdullinAM authored Aug 15, 2024
2 parents 8a9704c + f1c6bc1 commit 9dc261c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import org.vorpal.research.kex.trace.symbolic.SymbolicState
import org.vorpal.research.kex.trace.symbolic.persistentSymbolicState
import org.vorpal.research.kex.trace.symbolic.protocol.ExecutionCompletedResult
import org.vorpal.research.kex.trace.symbolic.protocol.ExecutionResult
import org.vorpal.research.kex.util.compiledCodeDirectory
import org.vorpal.research.kex.util.newFixedThreadPoolContextWithMDC
import org.vorpal.research.kex.util.testcaseDirectory
import org.vorpal.research.kfg.ClassManager
import org.vorpal.research.kfg.ir.Method
import org.vorpal.research.kthelper.assert.unreachable
Expand All @@ -49,6 +51,7 @@ import org.vorpal.research.kthelper.tryOrNull
import java.nio.file.Path
import java.util.concurrent.atomic.AtomicInteger
import kotlin.io.path.deleteIfExists
import kotlin.io.path.relativeTo
import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime

Expand Down Expand Up @@ -171,8 +174,12 @@ class InstructionConcolicChecker(
testWithAssertions = testWithAssertionsGenerator.emit()
compilerHelper.compileFile(testWithAssertions)

// delete the original test in the end, only if there were no errors with assertions
// delete the original test in the end (.java file), only if there were no errors with assertions
testFile.deleteIfExists()
// deleting .class file
val classFqnPath =
testFile.relativeTo(kexConfig.testcaseDirectory).toString().replaceAfterLast('.', "class")
kexConfig.compiledCodeDirectory.resolve(classFqnPath).deleteIfExists()
}
} catch (e: Throwable) {
testWithAssertions?.deleteIfExists()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vorpal.research.kex.jacoco.minimization

import org.vorpal.research.kex.config.kexConfig
import java.nio.file.Path

private class Test(
Expand Down Expand Up @@ -39,7 +40,8 @@ class GreedyTestReductionImpl : TestSuiteMinimizer {

var satisfiedReq = 0
val importantTests = mutableSetOf<Path>()
while (satisfiedReq < requestSet.size) {
val maxTests = kexConfig.getIntValue("testGen", "maxTests", Integer.MAX_VALUE)
while (satisfiedReq < requestSet.size && importantTests.size < maxTests) {
val (maxTestPath, maxTest) = tests.maxByOrNull { it.value.power } ?: break
if (maxTest.power == 0) break

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EqualityUtilsPrinter(
val testDirectory = kexConfig.testcaseDirectory
return equalityUtilsInstances.getOrPut(testDirectory to packageName) {
val utils = EqualityUtilsPrinter(packageName)
val targetFileName = "EqualityUtils.java"
val targetFileName = "$EQUALITY_UTILS_CLASS.java"
val targetFile = testDirectory
.resolve(packageName.asmString)
.resolve(targetFileName)
Expand All @@ -39,7 +39,11 @@ class EqualityUtilsPrinter(
}
}

fun equalityUtilsClasses(): Set<Path> = equalityUtilsInstances.mapTo(mutableSetOf()) { it.key.first }
fun equalityUtilsClasses(): Set<Path> = equalityUtilsInstances.mapTo(mutableSetOf()) {
it.key.first.resolve(it.key.second.asmString).resolve(
"$EQUALITY_UTILS_CLASS.java"
)
}

@Suppress("unused")
fun invalidateAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ReflectionUtilsPrinter(
val testDirectory = kexConfig.testcaseDirectory
return reflectionUtilsInstances.getOrPut(testDirectory to packageName) {
val utils = ReflectionUtilsPrinter(packageName)
val targetFileName = "ReflectionUtils.java"
val targetFileName = "$REFLECTION_UTILS_CLASS.java"
val targetFile = testDirectory
.resolve(packageName.asmString)
.resolve(targetFileName)
Expand All @@ -49,7 +49,11 @@ class ReflectionUtilsPrinter(
}
}

fun reflectionUtilsClasses(): Set<Path> = reflectionUtilsInstances.mapTo(mutableSetOf()) { it.key.first }
fun reflectionUtilsClasses(): Set<Path> = reflectionUtilsInstances.mapTo(mutableSetOf()) {
it.key.first.resolve(it.key.second.asmString).resolve(
"$REFLECTION_UTILS_CLASS.java"
)
}

@Suppress("unused")
fun invalidateAll() {
Expand Down
1 change: 1 addition & 0 deletions kex.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
;suppress inspection "DuplicateKeyInSection" for whole file
[kex]
minimizeTestSuite = false
runtimeDepsPath = runtime-deps/
libPath = lib/
rtVersion = 1.8
Expand Down

0 comments on commit 9dc261c

Please sign in to comment.