Guest User

Untitled

a guest
Jun 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. package kotlinx.coroutines.experimental.channels
  2.  
  3. import com.devexperts.dxlab.lincheck.*
  4. import com.devexperts.dxlab.lincheck.annotations.*
  5. import com.devexperts.dxlab.lincheck.paramgen.*
  6. import com.devexperts.dxlab.lincheck.stress.*
  7. import kotlinx.coroutines.experimental.*
  8. import org.junit.*
  9.  
  10. @Param(name = "value", gen = IntGen::class, conf = "1:3")
  11. class ConflatedChannelLinearizabilityTest : TestBase() {
  12.  
  13. private val lt = LinTesting()
  14. private lateinit var channel: ConflatedBroadcastChannel<Int>
  15.  
  16. @Reset
  17. fun reset() {
  18. channel = ConflatedBroadcastChannel()
  19. }
  20.  
  21. @Operation(runOnce = true)
  22. fun send1(@Param(name = "value") value: Int) = lt.run("send1") { channel.send(value) }
  23.  
  24. @Operation(runOnce = true)
  25. fun send2(@Param(name = "value") value: Int) = lt.run("send2") { channel.send(value) }
  26.  
  27. @Operation(runOnce = true)
  28. fun send3(@Param(name = "value") value: Int) = lt.run("send3") { channel.send(value) }
  29.  
  30. @Operation(runOnce = true)
  31. fun receive1() = lt.run("receive1") { channel.openSubscription().receive() }
  32.  
  33. @Operation(runOnce = true)
  34. fun receive2() = lt.run("receive2") { channel.openSubscription().receive() }
  35.  
  36. @Operation(runOnce = true)
  37. fun receive3() = lt.run("receive3") { channel.openSubscription().receive() }
  38.  
  39. @Test
  40. fun testConflatedChannelLinearizability() {
  41. val options = StressOptions()
  42. .iterations(100)
  43. .invocationsPerIteration(1000 * stressTestMultiplier)
  44. .addThread(1, 3)
  45. .addThread(1, 3)
  46. .addThread(1, 3)
  47. .verifier(LinVerifier::class.java)
  48. LinChecker.check(ConflatedChannelLinearizabilityTest::class.java, options)
  49. }
  50. }
Add Comment
Please, Sign In to add comment