summaryrefslogtreecommitdiff
path: root/opendc-kernel-omega/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-kernel-omega/src/test')
-rw-r--r--opendc-kernel-omega/src/test/kotlin/com/atlarge/opendc/omega/SmokeTest.kt35
1 files changed, 31 insertions, 4 deletions
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 c47f9a26..42ca05ec 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
@@ -27,8 +27,13 @@ package com.atlarge.opendc.omega
import com.atlarge.opendc.simulator.Bootstrap
import com.atlarge.opendc.simulator.Context
import com.atlarge.opendc.simulator.Process
+import com.atlarge.opendc.simulator.instrumentation.Instrument
+import com.atlarge.opendc.simulator.kernel.Kernel
+import com.atlarge.opendc.simulator.kernel.Simulation
+import kotlinx.coroutines.experimental.Unconfined
+import kotlinx.coroutines.experimental.async
+import kotlinx.coroutines.experimental.channels.*
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
/**
@@ -123,6 +128,7 @@ internal class SmokeTest {
hold(10)
}
}
+
/**
* Test if the kernel allows access to the simulation model object.
*/
@@ -135,9 +141,30 @@ internal class SmokeTest {
value
}
- val simulation = OmegaKernel.create(bootstrap)
- simulation.run(5)
+ val kernel = OmegaKernel.create(bootstrap)
+ kernel.run(5)
+ }
+
+
+ @Test
+ fun `instrumentation works`() {
+ val instrument: Instrument<Int, Unit> = {
+ var value = 0
+
+ for (i in 1..10) {
+ send(value)
+ value += 10
+ hold(20)
+ }
+ }
+
+ val simulation: Simulation<Unit> = OmegaKernel.create(Bootstrap.create { Unit })
+ val stream = simulation.install(instrument)
+
+ val res = async(Unconfined) {
+ stream.consumeEach { println(it) }
+ }
- assertTrue(simulation.run { process.state })
+ simulation.run(100)
}
}