Skip to content

Commit eab5c25

Browse files
author
Sergey Mashkov
committed
IO: add linearizability test
1 parent 9a6ca1a commit eab5c25

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 = 20_000, actorsPerThread = arrayOf("1:2", "1:2"), verifier = LinVerifier::class)
10+
@OpGroupConfigs(
11+
OpGroupConfig(name = "write", nonParallel = true),
12+
OpGroupConfig(name = "read", nonParallel = true)
13+
)
14+
class BufferReleaseLinearizabilityTest {
15+
private lateinit var ch: ByteChannel
16+
17+
private val lr = LinTesting()
18+
19+
@Reset
20+
fun reset() {
21+
ch = ByteChannel(false)
22+
}
23+
24+
@Operation(group = "read", runOnce = true)
25+
fun read() = lr.run("read") {
26+
ch.readLong()
27+
}
28+
29+
@Operation(group = "write", runOnce = true)
30+
fun write() = lr.run("write") {
31+
ch.writeLong(11111)
32+
}
33+
34+
@Operation
35+
fun test1() = lr.run("isClosedForRead") {
36+
ch.isClosedForRead
37+
}
38+
39+
@Test
40+
fun test() {
41+
LinChecker.check(BufferReleaseLinearizabilityTest::class.java)
42+
}
43+
}

0 commit comments

Comments
 (0)