summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt6
-rw-r--r--opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt7
-rw-r--r--opendc-kernel-omega/src/test/kotlin/com/atlarge/opendc/omega/SmokeTest.kt5
3 files changed, 10 insertions, 8 deletions
diff --git a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt
index 0954868a..14ce5a1a 100644
--- a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt
@@ -63,12 +63,16 @@ interface Simulation<M> {
/**
* Step through one cycle in the simulation. This method will process all events in a single tick, update the
* internal clock and then return the control to the user.
+ *
+ * This method will throw if a process running during the cycle throws an exception.
*/
fun step()
/**
* Run a simulation over the specified model.
* This method will step through multiple cycles in the simulation until no more message exist in the queue.
+ *
+ * This method will throw if a process running during a cycle throws an exception.
*/
fun run()
@@ -76,6 +80,8 @@ interface Simulation<M> {
* Run a simulation over the specified model, stepping through cycles until the specified clock tick has
* occurred. The control is then handed back to the user.
*
+ * This method will throw if a process running during a cycle throws an exception.
+ *
* @param until The point in simulation time at which the simulation should be paused and the control is handed
* back to the user.
*/
diff --git a/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt b/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt
index fbb4a270..03861864 100644
--- a/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt
+++ b/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt
@@ -430,11 +430,6 @@ internal class OmegaSimulation<M>(bootstrap: Bootstrap<M>) : Simulation<M>, Boot
*
* @param exception The exception to resume with.
*/
- override fun resumeWithException(exception: Throwable) {
- // Deregister process from registry in order to have the GC collect this context:w
- registry.remove(process)
-
- logger.error(exception) { "An exception occurred during the execution of a process" }
- }
+ override fun resumeWithException(exception: Throwable) = throw exception
}
}
diff --git a/opendc-kernel-omega/src/test/kotlin/com/atlarge/opendc/omega/SmokeTest.kt b/opendc-kernel-omega/src/test/kotlin/com/atlarge/opendc/omega/SmokeTest.kt
index 74d6e2de..b056837c 100644
--- a/opendc-kernel-omega/src/test/kotlin/com/atlarge/opendc/omega/SmokeTest.kt
+++ b/opendc-kernel-omega/src/test/kotlin/com/atlarge/opendc/omega/SmokeTest.kt
@@ -34,6 +34,7 @@ import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.channels.consumeEach
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
/**
* This test suite checks for smoke when running a large amount of simulations.
@@ -98,7 +99,7 @@ internal class SmokeTest {
object CrashProcess : Process<Unit, Unit> {
override val initialState = Unit
override suspend fun Context<Unit, Unit>.run() {
- TODO("This process should crash")
+ throw RuntimeException("This process should crash")
}
}
@@ -116,7 +117,7 @@ internal class SmokeTest {
}
val simulation = OmegaKernel.create(bootstrap)
- simulation.run()
+ assertThrows<RuntimeException> { simulation.run() }
}
class ModelProcess(private val value: Int) : Process<Boolean, Int> {