Skip to content

Commit

Permalink
Introduce no-fray mode (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoli-al authored Nov 21, 2024
1 parent c9e8c18 commit b639ab1
Showing 1 changed file with 16 additions and 40 deletions.
56 changes: 16 additions & 40 deletions core/src/main/kotlin/org/pastalab/fray/core/TestRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.pastalab.fray.core
import java.util.*
import org.pastalab.fray.core.command.Configuration
import org.pastalab.fray.core.randomness.ControlledRandom
import org.pastalab.fray.core.scheduler.RandomScheduler
import org.pastalab.fray.runtime.Runtime

class TestRunner(val config: Configuration) {
Expand Down Expand Up @@ -34,38 +33,15 @@ class TestRunner(val config: Configuration) {

fun run(): Throwable? {
config.executionInfo.executor.beforeExecution()
if (config.noFray) {
config.executionInfo.executor.execute()
} else {
config.frayLogger.info("Fray started.")
var bugsFound = 0
if (config.dummyRun) {
// We want to do a dummy-run first to make sure all variables are initialized
val noExitWhenBugFound = config.noExitWhenBugFound
val scheduler = config.scheduler
val randomnessProvider = config.randomnessProvider
val observers = config.scheduleObservers
Runtime.DELEGATE = RuntimeDelegate(context)
config.noExitWhenBugFound = true
config.scheduler = RandomScheduler(ControlledRandom())
config.randomnessProvider = ControlledRandom(mutableListOf(), mutableListOf(), Random(0))
config.scheduleObservers = mutableListOf()
Runtime.start()
config.frayLogger.info("Fray started.")
var bugsFound = 0
while (config.shouldRun()) {
reportProgress(config.currentIteration, bugsFound)
if (config.noFray) {
try {
config.executionInfo.executor.beforeExecution()
config.executionInfo.executor.execute()
Runtime.onMainExit()
} catch (e: Throwable) {
Runtime.onMainExit()
}
config.executionInfo.executor.afterExecution()
config.noExitWhenBugFound = noExitWhenBugFound
config.scheduler = scheduler
config.randomnessProvider = randomnessProvider
config.scheduleObservers = observers
}
while (config.shouldRun()) {
reportProgress(config.currentIteration, bugsFound)
} catch (e: Throwable) {}
} else {
try {
if (config.currentIteration != 0) {
config.scheduler = config.scheduler.nextIteration()
Expand All @@ -79,17 +55,17 @@ class TestRunner(val config: Configuration) {
Runtime.onReportError(e)
Runtime.onMainExit()
}
if (config.isReplay ||
((context.bugFound != null && context.bugFound !is FrayInternalError) &&
!config.exploreMode))
break
config.currentIteration++
}
context.shutDown()
config.frayLogger.info(
"Run finished. Total iter: ${config.currentIteration}, Elapsed time: ${config.elapsedTime()}ms",
)
if (config.isReplay ||
((context.bugFound != null && context.bugFound !is FrayInternalError) &&
!config.exploreMode))
break
config.currentIteration++
}
context.shutDown()
config.frayLogger.info(
"Run finished. Total iter: ${config.currentIteration}, Elapsed time: ${config.elapsedTime()}ms",
)
config.executionInfo.executor.afterExecution()
return context.bugFound
}
Expand Down

0 comments on commit b639ab1

Please sign in to comment.