diff --git a/core/src/main/kotlin/cmu/pasta/fray/core/GlobalContext.kt b/core/src/main/kotlin/cmu/pasta/fray/core/GlobalContext.kt index 2bbdc4d3..55062b06 100644 --- a/core/src/main/kotlin/cmu/pasta/fray/core/GlobalContext.kt +++ b/core/src/main/kotlin/cmu/pasta/fray/core/GlobalContext.kt @@ -494,7 +494,7 @@ object GlobalContext { } fun lockTryLock(lock: Any) { - lockImpl(lock, false, false, false) + lockImpl(lock, false, false, true) } fun lockImpl(lock: Any, isMonitorLock: Boolean, shouldBlock: Boolean, canInterrupt: Boolean) { @@ -505,6 +505,10 @@ object GlobalContext { context.state = ThreadState.Enabled scheduleNextOperation(true) + if (canInterrupt) { + context.checkInterrupt() + } + /** * We need a while loop here because even a thread unlock this thread and makes this thread * Enabled. It is still possible for a third thread to lock it again. t1 = { diff --git a/core/src/main/kotlin/cmu/pasta/fray/core/TestRunner.kt b/core/src/main/kotlin/cmu/pasta/fray/core/TestRunner.kt index 7a75f287..72593788 100644 --- a/core/src/main/kotlin/cmu/pasta/fray/core/TestRunner.kt +++ b/core/src/main/kotlin/cmu/pasta/fray/core/TestRunner.kt @@ -28,28 +28,32 @@ class TestRunner(val config: Configuration) { } fun run() { - setup() - val time = measureTimeMillis { - var i = 0 - while (i != config.iter) { - println("Starting iteration $i") - try { - Runtime.DELEGATE = RuntimeDelegate() - Runtime.start() - config.executionInfo.executor.execute() - Runtime.onMainExit() - } catch (e: Throwable) { - Runtime.onReportError(e) - Runtime.onMainExit() + if (config.noFray) { + config.executionInfo.executor.execute() + } else { + setup() + val time = measureTimeMillis { + var i = 0 + while (i != config.iter) { + println("Starting iteration $i") + try { + Runtime.DELEGATE = RuntimeDelegate() + Runtime.start() + config.executionInfo.executor.execute() + Runtime.onMainExit() + } catch (e: Throwable) { + Runtime.onReportError(e) + Runtime.onMainExit() + } + if (GlobalContext.bugFound) { + println("Error found at iter: $i") + break + } + i++ } - if (GlobalContext.bugFound) { - println("Error found at iter: $i") - break - } - i++ + GlobalContext.shutDown() } - GlobalContext.shutDown() + println("Analysis done in: $time ms") } - println("Analysis done in: $time ms") } } diff --git a/core/src/main/kotlin/cmu/pasta/fray/core/command/Configuration.kt b/core/src/main/kotlin/cmu/pasta/fray/core/command/Configuration.kt index 1b4e4641..bb4f8ba4 100644 --- a/core/src/main/kotlin/cmu/pasta/fray/core/command/Configuration.kt +++ b/core/src/main/kotlin/cmu/pasta/fray/core/command/Configuration.kt @@ -148,6 +148,7 @@ class MainCommand : CliktCommand() { "pos" to POS(), "random" to Rand(), "pct" to PCT()) + val noFray by option("--no-fray").flag() val runConfig by option() .groupChoice( @@ -166,7 +167,8 @@ class MainCommand : CliktCommand() { iter, scheduler!!.getScheduler(), fullSchedule, - logger!!.getLogger(report, fullSchedule)) + logger!!.getLogger(report, fullSchedule), + noFray) } } @@ -177,4 +179,5 @@ data class Configuration( val scheduler: Scheduler, val fullSchedule: Boolean, val logger: LoggerBase, + val noFray: Boolean = false ) {} diff --git a/integration-tests/src/test/java/cmu/pasta/fray/it/IntegrationTestRunner.java b/integration-tests/src/test/java/cmu/pasta/fray/it/IntegrationTestRunner.java index b584909d..ae149666 100644 --- a/integration-tests/src/test/java/cmu/pasta/fray/it/IntegrationTestRunner.java +++ b/integration-tests/src/test/java/cmu/pasta/fray/it/IntegrationTestRunner.java @@ -42,7 +42,8 @@ public String runTest(Function0 exec, Scheduler scheduler, int iter) { iter, scheduler, true, - new JsonLogger("/tmp/report", false) + new JsonLogger("/tmp/report", false), + false ); TestRunner runner = new TestRunner(config); runner.run();