blob: e11b7fa0128a9d793e0e4183787a569fd802c6ca [file] [log] [blame]
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03001/*
2 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
Sergey Mashkoveab5c252017-11-20 11:43:45 +03005package kotlinx.coroutines.experimental.io
6
7import com.devexperts.dxlab.lincheck.*
8import com.devexperts.dxlab.lincheck.annotations.*
9import com.devexperts.dxlab.lincheck.stress.*
10import kotlinx.coroutines.experimental.*
11import org.junit.*
12
Sergey Mashkoveab5c252017-11-20 11:43:45 +030013@OpGroupConfigs(
14 OpGroupConfig(name = "write", nonParallel = true),
15 OpGroupConfig(name = "read", nonParallel = true)
16)
Roman Elizarov6129c942018-01-10 17:34:40 +030017class BufferReleaseLinearizabilityTest : TestBase() {
Sergey Mashkoveab5c252017-11-20 11:43:45 +030018 private lateinit var ch: ByteChannel
19
20 private val lr = LinTesting()
21
22 @Reset
23 fun reset() {
24 ch = ByteChannel(false)
25 }
26
27 @Operation(group = "read", runOnce = true)
28 fun read() = lr.run("read") {
29 ch.readLong()
30 }
31
32 @Operation(group = "write", runOnce = true)
33 fun write() = lr.run("write") {
34 ch.writeLong(11111)
35 }
36
37 @Operation
38 fun test1() = lr.run("isClosedForRead") {
39 ch.isClosedForRead
40 }
41
42 @Test
43 fun test() {
Roman Elizarov6129c942018-01-10 17:34:40 +030044 val options = StressOptions()
45 .iterations(100)
46 .invocationsPerIteration(1000 * stressTestMultiplier)
47 .addThread(1, 2)
48 .addThread(1, 2)
49 LinChecker.check(BufferReleaseLinearizabilityTest::class.java, options)
Sergey Mashkoveab5c252017-11-20 11:43:45 +030050 }
51}