Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullinAM committed Aug 4, 2023
1 parent d804074 commit 3787e42
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package org.vorpal.research.kex.launcher

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.InternalSerializationApi
import org.vorpal.research.kex.config.FileConfig
Expand All @@ -10,6 +11,7 @@ import org.vorpal.research.kex.util.getPathSeparator
import org.vorpal.research.kex.worker.ExecutorMaster
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.concurrent.thread

@ExperimentalSerializationApi
@InternalSerializationApi
Expand Down Expand Up @@ -45,6 +47,7 @@ class MasterLauncher(args: Array<String>) {
val logName = kexConfig.getStringValue("kex", "log", "kex-executor-master.log")
kexConfig.initLog(logName)
}

fun main() {
val master = ExecutorMaster(
MasterProtocolSocketHandler(port),
Expand All @@ -53,12 +56,9 @@ class MasterLauncher(args: Array<String>) {
numberOfWorkers
)

val shutdownHook = object : Thread() {
override fun run() {
master.destroy()
}
}
Runtime.getRuntime().addShutdownHook(shutdownHook)
Runtime.getRuntime().addShutdownHook(thread {
master.destroy()
})

master.run()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import org.vorpal.research.kex.launcher.AnalysisLevel
import org.vorpal.research.kex.launcher.ClassLevel
import org.vorpal.research.kex.launcher.MethodLevel
import org.vorpal.research.kex.launcher.PackageLevel
import org.vorpal.research.kex.util.PermanentCoverageInfo
import org.vorpal.research.kex.util.PermanentSaturationCoverageInfo
import org.vorpal.research.kex.util.asmString
import org.vorpal.research.kex.util.compiledCodeDirectory
import org.vorpal.research.kex.util.deleteOnExit
Expand All @@ -37,7 +39,7 @@ import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.attribute.BasicFileAttributes
import java.util.SortedMap
import java.util.*
import kotlin.io.path.exists
import kotlin.io.path.inputStream
import kotlin.io.path.name
Expand Down Expand Up @@ -485,3 +487,30 @@ class CoverageReporter(
}
}
}

fun reportCoverage(containers: List<Container>, cm: ClassManager, analysisLevel: AnalysisLevel) {
if (kexConfig.getBooleanValue("kex", "computeCoverage", true)) {
val coverageInfo = when {
kexConfig.getBooleanValue("kex", "computeSaturationCoverage", true) -> {
val saturationCoverage = CoverageReporter(containers)
.computeSaturationCoverage(cm, analysisLevel)
PermanentSaturationCoverageInfo.putNewInfo(
"concolic",
analysisLevel.toString(),
saturationCoverage.toList()
)
PermanentSaturationCoverageInfo.emit()
saturationCoverage[saturationCoverage.lastKey()]!!
}

else -> CoverageReporter(containers).execute(cm, analysisLevel)
}

log.info(
coverageInfo.print(kexConfig.getBooleanValue("kex", "printDetailedCoverage", false))
)

PermanentCoverageInfo.putNewInfo("concolic", analysisLevel.toString(), coverageInfo)
PermanentCoverageInfo.emit()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import org.vorpal.research.kex.asm.analysis.concolic.InstructionConcolicChecker
import org.vorpal.research.kex.asm.transform.SymbolicTraceInstrumenter
import org.vorpal.research.kex.asm.util.ClassWriter
import org.vorpal.research.kex.config.kexConfig
import org.vorpal.research.kex.jacoco.CoverageReporter
import org.vorpal.research.kex.jacoco.reportCoverage
import org.vorpal.research.kex.trace.runner.ExecutorMasterController
import org.vorpal.research.kex.util.PermanentCoverageInfo
import org.vorpal.research.kex.util.PermanentSaturationCoverageInfo
import org.vorpal.research.kex.util.instrumentedCodeDirectory
import org.vorpal.research.kfg.ir.Method
import org.vorpal.research.kfg.visitor.Pipeline
import org.vorpal.research.kthelper.logging.log
import kotlin.time.ExperimentalTime

@ExperimentalTime
Expand Down Expand Up @@ -43,30 +40,6 @@ class ConcolicLauncher(classPaths: List<String>, targetName: String) : KexAnalys
InstructionConcolicChecker.run(context, setOfTargets)
}
}

if (kexConfig.getBooleanValue("kex", "computeCoverage", true)) {
val coverageInfo = when {
kexConfig.getBooleanValue("kex", "computeSaturationCoverage", true) -> {
val saturationCoverage = CoverageReporter(containers)
.computeSaturationCoverage(context.cm, analysisLevel)
PermanentSaturationCoverageInfo.putNewInfo(
"concolic",
analysisLevel.toString(),
saturationCoverage.toList()
)
PermanentSaturationCoverageInfo.emit()
saturationCoverage[saturationCoverage.lastKey()]!!
}

else -> CoverageReporter(containers).execute(context.cm, analysisLevel)
}

log.info(
coverageInfo.print(kexConfig.getBooleanValue("kex", "printDetailedCoverage", false))
)

PermanentCoverageInfo.putNewInfo("concolic", analysisLevel.toString(), coverageInfo)
PermanentCoverageInfo.emit()
}
reportCoverage(containers, context.cm, analysisLevel)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.InternalSerializationApi
import org.vorpal.research.kex.ExecutionContext
import org.vorpal.research.kex.asm.analysis.symbolic.InstructionSymbolicChecker
import org.vorpal.research.kex.config.kexConfig
import org.vorpal.research.kex.jacoco.CoverageReporter
import org.vorpal.research.kex.util.PermanentCoverageInfo
import org.vorpal.research.kex.jacoco.reportCoverage
import org.vorpal.research.kfg.ir.Method
import org.vorpal.research.kfg.visitor.Pipeline
import org.vorpal.research.kthelper.logging.log
import kotlin.time.ExperimentalTime

@ExperimentalTime
Expand All @@ -32,15 +29,6 @@ class SymbolicLauncher(classPaths: List<String>, targetName: String) : KexAnalys
for (setOfTargets in batchedTargets) {
InstructionSymbolicChecker.run(context, setOfTargets)
}

if (kexConfig.getBooleanValue("kex", "computeCoverage", true)) {
val coverageInfo = CoverageReporter(containers).execute(context.cm, analysisLevel)
log.info(
coverageInfo.print(kexConfig.getBooleanValue("kex", "printDetailedCoverage", false))
)

PermanentCoverageInfo.putNewInfo("symbolic", analysisLevel.toString(), coverageInfo)
PermanentCoverageInfo.emit()
}
reportCoverage(containers, context.cm, analysisLevel)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import kotlinx.serialization.InternalSerializationApi
import org.vorpal.research.kex.ExecutionContext
import org.vorpal.research.kex.config.kexConfig
import org.vorpal.research.kex.serialization.KexSerializer
import org.vorpal.research.kex.trace.symbolic.protocol.ExecutionCompletedResult
import org.vorpal.research.kex.trace.symbolic.protocol.ExecutionResult
import org.vorpal.research.kex.trace.symbolic.protocol.Client2MasterConnection
import org.vorpal.research.kex.trace.symbolic.protocol.Client2MasterSocketConnection
import org.vorpal.research.kex.trace.symbolic.protocol.ExecutionCompletedResult
import org.vorpal.research.kex.trace.symbolic.protocol.ExecutionResult
import org.vorpal.research.kex.trace.symbolic.protocol.TestExecutionRequest
import org.vorpal.research.kex.util.getIntrinsics
import org.vorpal.research.kex.util.getJunit
Expand All @@ -20,6 +20,7 @@ import org.vorpal.research.kfg.ClassManager
import org.vorpal.research.kthelper.logging.log
import java.net.ServerSocket
import java.nio.file.Paths
import kotlin.concurrent.thread

@ExperimentalSerializationApi
@InternalSerializationApi
Expand All @@ -34,6 +35,9 @@ internal object ExecutorMasterController : AutoCloseable {
tempSocket.close()
// this is fucked up
Thread.sleep(2000)
Runtime.getRuntime().addShutdownHook(thread {
if (process.isAlive) process.destroy()
})
}

fun start(ctx: ExecutionContext) {
Expand Down

0 comments on commit 3787e42

Please sign in to comment.