Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package kotlinx.coroutines.experimental.channels
- import com.devexperts.dxlab.lincheck.*
- import com.devexperts.dxlab.lincheck.annotations.*
- import com.devexperts.dxlab.lincheck.paramgen.*
- import com.devexperts.dxlab.lincheck.stress.*
- import kotlinx.coroutines.experimental.*
- import org.junit.*
- @Param(name = "value", gen = IntGen::class, conf = "1:3")
- class ConflatedChannelLinearizabilityTest : TestBase() {
- private val lt = LinTesting()
- private lateinit var channel: ConflatedBroadcastChannel<Int>
- @Reset
- fun reset() {
- channel = ConflatedBroadcastChannel()
- }
- @Operation(runOnce = true)
- fun send1(@Param(name = "value") value: Int) = lt.run("send1") { channel.send(value) }
- @Operation(runOnce = true)
- fun send2(@Param(name = "value") value: Int) = lt.run("send2") { channel.send(value) }
- @Operation(runOnce = true)
- fun send3(@Param(name = "value") value: Int) = lt.run("send3") { channel.send(value) }
- @Operation(runOnce = true)
- fun receive1() = lt.run("receive1") { channel.openSubscription().receive() }
- @Operation(runOnce = true)
- fun receive2() = lt.run("receive2") { channel.openSubscription().receive() }
- @Operation(runOnce = true)
- fun receive3() = lt.run("receive3") { channel.openSubscription().receive() }
- @Test
- fun testConflatedChannelLinearizability() {
- val options = StressOptions()
- .iterations(100)
- .invocationsPerIteration(1000 * stressTestMultiplier)
- .addThread(1, 3)
- .addThread(1, 3)
- .addThread(1, 3)
- .verifier(LinVerifier::class.java)
- LinChecker.check(ConflatedChannelLinearizabilityTest::class.java, options)
- }
- }
Add Comment
Please, Sign In to add comment