Sergey Mashkov | 8b310cb | 2017-11-10 10:28:30 +0300 | [diff] [blame] | 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 | |
Sergey Mashkov | 8b310cb | 2017-11-10 10:28:30 +0300 | [diff] [blame] | 9 | @OpGroupConfigs( |
| 10 | OpGroupConfig(name = "write", nonParallel = true), |
| 11 | OpGroupConfig(name = "read1", nonParallel = true), |
| 12 | OpGroupConfig(name = "read2", nonParallel = true) |
| 13 | ) |
Roman Elizarov | 6129c94 | 2018-01-10 17:34:40 +0300 | [diff] [blame] | 14 | class ByteChannelJoinLinearizabilityTest : TestBase() { |
Sergey Mashkov | 8b310cb | 2017-11-10 10:28:30 +0300 | [diff] [blame] | 15 | private lateinit var from: ByteChannel |
| 16 | private lateinit var to: ByteChannel |
| 17 | |
| 18 | private val lr = LinTesting() |
| 19 | |
| 20 | @Reset |
| 21 | fun reset() { |
| 22 | // println("============== reset ====================") |
| 23 | from = ByteChannel(true) |
| 24 | to = ByteChannel(true) |
| 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(runOnce = true, group = "read2") |
| 38 | fun joinTo() = lr.run("join") { |
| 39 | from.joinTo(to, true) |
| 40 | } |
| 41 | |
| 42 | @Test |
| 43 | fun test() { |
Roman Elizarov | 6129c94 | 2018-01-10 17:34:40 +0300 | [diff] [blame] | 44 | val options = StressOptions() |
| 45 | .iterations(100) |
| 46 | .invocationsPerIteration(1000 * stressTestMultiplier) |
| 47 | .addThread(1, 1) |
| 48 | .addThread(1, 1) |
| 49 | .addThread(1, 1) |
| 50 | .verifier(LinVerifier::class.java) |
| 51 | LinChecker.check(ByteChannelJoinLinearizabilityTest::class.java, options) |
Sergey Mashkov | 8b310cb | 2017-11-10 10:28:30 +0300 | [diff] [blame] | 52 | } |
| 53 | } |