|
| 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