summaryrefslogtreecommitdiff
path: root/opendc-omega/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-omega/src/test')
-rw-r--r--opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt51
1 files changed, 50 insertions, 1 deletions
diff --git a/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt b/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt
index fdc7b033..cb2ce643 100644
--- a/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt
+++ b/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt
@@ -24,8 +24,11 @@
package nl.atlarge.opendc
+import nl.atlarge.opendc.kernel.Context
+import nl.atlarge.opendc.kernel.Process
import nl.atlarge.opendc.kernel.omega.OmegaKernel
import nl.atlarge.opendc.topology.AdjacencyList
+import nl.atlarge.opendc.topology.Entity
import nl.atlarge.opendc.topology.machine.Machine
import org.junit.jupiter.api.Test
@@ -44,7 +47,7 @@ internal class SmokeTest {
val builder = AdjacencyList.builder()
repeat(n) {
val root = Machine()
- val topology = AdjacencyList.builder().construct {
+ val topology = builder.construct {
add(root)
val other = Machine()
@@ -63,4 +66,50 @@ internal class SmokeTest {
simulation.run()
}
}
+
+ class NullProcess : Entity<Unit>, Process<NullProcess> {
+ override val initialState = Unit
+ suspend override fun Context<NullProcess>.run() {}
+ }
+
+ /**
+ * Test if the kernel allows sending messages to [Process] instances that have already stopped.
+ */
+ @Test
+ fun `sending message to process that has gracefully stopped`() {
+
+ val builder = AdjacencyList.builder()
+ val process = NullProcess()
+ val topology = builder.construct {
+ add(process)
+ }
+
+ val simulation = OmegaKernel.create(topology)
+ simulation.schedule(0, process)
+ simulation.run()
+ }
+
+ class CrashProcess : Entity<Unit>, Process<NullProcess> {
+ override val initialState = Unit
+ suspend override fun Context<NullProcess>.run() {
+ TODO()
+ }
+ }
+
+ /**
+ * Test if the kernel allows sending messages to [Process] instances that have crashed.
+ */
+ @Test
+ fun `sending message to process that has crashed`() {
+
+ val builder = AdjacencyList.builder()
+ val process = CrashProcess()
+ val topology = builder.construct {
+ add(process)
+ }
+
+ val simulation = OmegaKernel.create(topology)
+ simulation.schedule(0, process)
+ simulation.run()
+ }
}