Skip to content

Commit 199a04c

Browse files
author
Sergey Mashkov
committed
IO: added linearizability test
1 parent 33d5d13 commit 199a04c

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/ByteChannelJoinLinearizabilityTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.devexperts.dxlab.lincheck.stress.*
66
import kotlinx.coroutines.experimental.*
77
import org.junit.*
88

9-
@StressCTest(iterations = 200, actorsPerThread = arrayOf("1:1", "1:1", "1:1"), verifier = LinVerifier::class)
9+
@StressCTest(iterations = 200, invocationsPerIteration = 2_000, actorsPerThread = arrayOf("1:1", "1:1", "1:1"), verifier = LinVerifier::class)
1010
@OpGroupConfigs(
1111
OpGroupConfig(name = "write", nonParallel = true),
1212
OpGroupConfig(name = "read1", nonParallel = true),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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:2", "1:1", "1:1"), verifier = LinVerifier::class)
10+
@OpGroupConfigs(
11+
OpGroupConfig(name = "write", nonParallel = true),
12+
OpGroupConfig(name = "read1", nonParallel = true),
13+
OpGroupConfig(name = "read2", nonParallel = true)
14+
)
15+
class ByteChannelJoinNoAutoFlushLinearizabilityTest {
16+
private lateinit var from: ByteChannel
17+
private lateinit var to: ByteChannel
18+
19+
private val lr = LinTesting()
20+
21+
@Reset
22+
fun reset() {
23+
from = ByteChannel(false)
24+
to = ByteChannel(false)
25+
}
26+
27+
@Operation(runOnce = true, group = "read1")
28+
fun read() = lr.run("read") {
29+
to.readLong()
30+
}
31+
32+
@Operation(runOnce = true, group = "write")
33+
fun write() = lr.run("write") {
34+
from.writeLong(0x1122334455667788L)
35+
}
36+
37+
@Operation(group = "write")
38+
fun flush() = lr.run("flush") {
39+
from.flush()
40+
}
41+
42+
@Operation(runOnce = true, group = "read2")
43+
fun joinTo() = lr.run("join") {
44+
from.joinTo(to, true)
45+
}
46+
47+
@Test
48+
fun test() {
49+
LinChecker.check(ByteChannelJoinNoAutoFlushLinearizabilityTest::class.java)
50+
}
51+
}

0 commit comments

Comments
 (0)