blob: 4dd30656108037f88e53aa8ce4e321d325e0c9fd [file] [log] [blame]
Sergey Mashkov9f9b72d2017-11-20 11:46:28 +03001package kotlinx.coroutines.experimental.io
2
3import com.devexperts.dxlab.lincheck.*
4import com.devexperts.dxlab.lincheck.annotations.*
5import com.devexperts.dxlab.lincheck.stress.*
6import kotlinx.coroutines.experimental.*
7import org.junit.*
8
Sergey Mashkov9f9b72d2017-11-20 11:46:28 +03009@OpGroupConfigs(
10 OpGroupConfig(name = "write", nonParallel = true),
11 OpGroupConfig(name = "read", nonParallel = true)
12)
Roman Elizarov6129c942018-01-10 17:34:40 +030013class WriteBlockLinearizabilityTest : TestBase() {
Sergey Mashkov9f9b72d2017-11-20 11:46:28 +030014 private lateinit var ch: ByteChannel
15
16 private val lr = LinTesting()
17
18 @Reset
19 fun reset() {
20 ch = ByteChannel(false)
21 runBlocking {
22 ch.writeLong(111)
23 }
24 }
25
26 @Operation(group = "read")
27 fun read() = lr.run("read") {
28 ch.readLong()
29 }
30
31 @Operation(group = "write")
32 fun write() = lr.run("write") {
33 ch.write(8) {
34 it.putLong(9699)
35 }
36 }
37
38 @Test
39 fun test() {
Roman Elizarov6129c942018-01-10 17:34:40 +030040 val options = StressOptions()
41 .iterations(100)
42 .invocationsPerIteration(1000 * stressTestMultiplier)
43 .addThread(1, 1)
44 .addThread(1, 1)
45 .verifier(LinVerifier::class.java)
46 LinChecker.check(WriteBlockLinearizabilityTest::class.java, options)
Sergey Mashkov9f9b72d2017-11-20 11:46:28 +030047 }
48}