Skip to content

Instantly share code, notes, and snippets.

@qwwdfsad
Created June 18, 2018 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwwdfsad/d98b615d24e70772214f429e073d78cf to your computer and use it in GitHub Desktop.
Save qwwdfsad/d98b615d24e70772214f429e073d78cf to your computer and use it in GitHub Desktop.
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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment