Skip to content

Commit 9f9b72d

Browse files
author
Sergey Mashkov
committed
IO: add linearizability test
1 parent 4ea3cb3 commit 9f9b72d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package kotlinx.coroutines.experimental.io
2+
3+
import com.devexperts.dxlab.lincheck.*
4+
import com.devexperts.dxlab.lincheck.annotations.*
5+
import com.devexperts.dxlab.lincheck.stress.*
6+
import kotlinx.coroutines.experimental.*
7+
import org.junit.*
8+
9+
@StressCTest(iterations = 200, invocationsPerIteration = 2_000, actorsPerThread = arrayOf("1:1", "1:1"), verifier = LinVerifier::class)
10+
@OpGroupConfigs(
11+
OpGroupConfig(name = "write", nonParallel = true),
12+
OpGroupConfig(name = "read", nonParallel = true)
13+
)
14+
class WriteBlockLinearizabilityTest {
15+
private lateinit var ch: ByteChannel
16+
17+
private val lr = LinTesting()
18+
19+
@Reset
20+
fun reset() {
21+
ch = ByteChannel(false)
22+
runBlocking {
23+
ch.writeLong(111)
24+
}
25+
}
26+
27+
@Operation(group = "read")
28+
fun read() = lr.run("read") {
29+
ch.readLong()
30+
}
31+
32+
@Operation(group = "write")
33+
fun write() = lr.run("write") {
34+
ch.write(8) {
35+
it.putLong(9699)
36+
}
37+
}
38+
39+
@Test
40+
fun test() {
41+
LinChecker.check(WriteBlockLinearizabilityTest::class.java)
42+
}
43+
}

0 commit comments

Comments
 (0)