Skip to content

Commit 4687658

Browse files
committed
Increase Lincheck version to 3.0
1 parent ff489dd commit 4687658

10 files changed

+25
-44
lines changed

buildSrc/src/main/kotlin/CommunityProjectsBuild.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ fun isSnapshotTrainEnabled(project: Project): Boolean {
147147
val firstPartyDependencies = listOf(
148148
"kotlin",
149149
"atomicfu",
150+
"lincheck"
150151
)
151152

152153
fun shouldUseLocalMaven(project: Project): Boolean {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ benchmarks_jmh_version=1.37
1313
junit_version=4.12
1414
junit5_version=5.7.0
1515
knit_version=0.5.0
16-
lincheck_version=2.18.1
16+
lincheck_version=3.0
1717
dokka_version=1.9.20
1818
byte_buddy_version=1.10.9
1919
reactor_version=3.4.1

kotlinx-coroutines-core/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ kotlin {
5656
}
5757
jvmTest {
5858
dependencies {
59-
api("org.jetbrains.kotlinx:lincheck:${version("lincheck")}")
59+
api("org.jetbrains.lincheck:lincheck:${version("lincheck")}")
6060
api("org.jetbrains.kotlinx:kotlinx-knit-test:${version("knit")}")
6161
implementation(project(":android-unit-tests"))
6262
implementation("org.openjdk.jol:jol-core:0.16")
@@ -251,6 +251,7 @@ kover {
251251

252252
// lincheck has NPE error on `ManagedStrategyStateHolder` class
253253
excludedClasses.addAll("org.jetbrains.kotlinx.lincheck.*")
254+
excludedClasses.addAll("org.jetbrains.lincheck.*")
254255
}
255256
sources {
256257
excludedSourceSets.addAll("benchmark")

kotlinx-coroutines-core/jvm/test/AbstractLincheckTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package kotlinx.coroutines
22

33
import kotlinx.coroutines.testing.*
4-
import org.jetbrains.kotlinx.lincheck.*
5-
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.*
6-
import org.jetbrains.kotlinx.lincheck.strategy.stress.*
4+
import org.jetbrains.lincheck.datastructures.*
75
import org.junit.*
86

97
abstract class AbstractLincheckTest {

kotlinx-coroutines-core/jvm/test/internal/OnDemandAllocatingPoolLincheckTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package kotlinx.coroutines.internal
22

33
import kotlinx.atomicfu.*
44
import kotlinx.coroutines.*
5-
import org.jetbrains.kotlinx.lincheck.*
6-
import org.jetbrains.kotlinx.lincheck.annotations.*
5+
import org.jetbrains.lincheck.datastructures.*
76

87
/**
98
* Test that:

kotlinx-coroutines-core/jvm/test/lincheck/ChannelsLincheckTest.kt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22

33
package kotlinx.coroutines.lincheck
44

5-
import kotlinx.coroutines.testing.*
65
import kotlinx.coroutines.*
76
import kotlinx.coroutines.channels.*
87
import kotlinx.coroutines.channels.Channel.Factory.CONFLATED
98
import kotlinx.coroutines.channels.Channel.Factory.RENDEZVOUS
109
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
1110
import kotlinx.coroutines.selects.*
12-
import org.jetbrains.kotlinx.lincheck.*
13-
import org.jetbrains.kotlinx.lincheck.annotations.*
14-
import org.jetbrains.kotlinx.lincheck.annotations.Operation
15-
import org.jetbrains.kotlinx.lincheck.paramgen.*
16-
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.*
11+
import org.jetbrains.lincheck.datastructures.*
1712

1813
class RendezvousChannelLincheckTest : ChannelLincheckTestBaseWithOnSend(
1914
c = Channel(RENDEZVOUS),
@@ -80,7 +75,7 @@ abstract class ChannelLincheckTestBaseWithOnSend(
8075
sequentialSpecification: Class<*>,
8176
obstructionFree: Boolean = true
8277
) : ChannelLincheckTestBase(c, sequentialSpecification, obstructionFree) {
83-
@Operation(allowExtraSuspension = true, blocking = true)
78+
@Operation(blocking = true)
8479
suspend fun sendViaSelect(@Param(name = "value") value: Int): Any = try {
8580
select<Unit> { c.onSend(value) {} }
8681
} catch (e: NumberedCancellationException) {
@@ -98,7 +93,7 @@ abstract class ChannelLincheckTestBase(
9893
private val obstructionFree: Boolean = true
9994
) : AbstractLincheckTest() {
10095

101-
@Operation(allowExtraSuspension = true, blocking = true)
96+
@Operation(blocking = true)
10297
suspend fun send(@Param(name = "value") value: Int): Any = try {
10398
c.send(value)
10499
} catch (e: NumberedCancellationException) {
@@ -114,14 +109,14 @@ abstract class ChannelLincheckTestBase(
114109
else false
115110
}
116111

117-
@Operation(allowExtraSuspension = true, blocking = true)
112+
@Operation(blocking = true)
118113
suspend fun receive(): Any = try {
119114
c.receive()
120115
} catch (e: NumberedCancellationException) {
121116
e.testResult
122117
}
123118

124-
@Operation(allowExtraSuspension = true, blocking = true)
119+
@Operation(blocking = true)
125120
suspend fun receiveCatching(): Any = c.receiveCatching()
126121
.onSuccess { return it }
127122
.onClosed { e -> return (e as NumberedCancellationException).testResult }
@@ -132,17 +127,17 @@ abstract class ChannelLincheckTestBase(
132127
.onSuccess { return it }
133128
.onFailure { return if (it is NumberedCancellationException) it.testResult else null }
134129

135-
@Operation(allowExtraSuspension = true, blocking = true)
130+
@Operation(blocking = true)
136131
suspend fun receiveViaSelect(): Any = try {
137132
select<Int> { c.onReceive { it } }
138133
} catch (e: NumberedCancellationException) {
139134
e.testResult
140135
}
141136

142-
@Operation(causesBlocking = true, blocking = true)
137+
@Operation(blocking = true)
143138
fun close(@Param(name = "closeToken") token: Int): Boolean = c.close(NumberedCancellationException(token))
144139

145-
@Operation(causesBlocking = true, blocking = true)
140+
@Operation(blocking = true)
146141
fun cancel(@Param(name = "closeToken") token: Int) = c.cancel(NumberedCancellationException(token))
147142

148143
// @Operation TODO non-linearizable in BufferedChannel
@@ -154,9 +149,6 @@ abstract class ChannelLincheckTestBase(
154149
// @Operation TODO non-linearizable in BufferedChannel
155150
open fun isEmpty() = c.isEmpty
156151

157-
@StateRepresentation
158-
fun state() = (c as? BufferedChannel<*>)?.toStringDebug() ?: c.toString()
159-
160152
@Validate
161153
fun validate() {
162154
(c as? BufferedChannel<*>)?.checkSegmentStructureInvariants()

kotlinx-coroutines-core/jvm/test/lincheck/LockFreeTaskQueueLincheckTest.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ package kotlinx.coroutines.lincheck
44

55
import kotlinx.coroutines.*
66
import kotlinx.coroutines.internal.*
7-
import org.jetbrains.kotlinx.lincheck.*
8-
import org.jetbrains.kotlinx.lincheck.annotations.*
9-
import org.jetbrains.kotlinx.lincheck.annotations.Operation
10-
import org.jetbrains.kotlinx.lincheck.paramgen.*
11-
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.*
12-
import org.jetbrains.kotlinx.lincheck.verifier.quiescent.*
7+
import org.jetbrains.lincheck.datastructures.*
8+
import org.jetbrains.lincheck.datastructures.verifier.QuiescentConsistencyVerifier
9+
import org.jetbrains.lincheck.datastructures.verifier.QuiescentConsistent
1310

1411
@Param(name = "value", gen = IntGen::class, conf = "1:3")
1512
internal abstract class AbstractLockFreeTaskQueueWithoutRemoveLincheckTest(

kotlinx-coroutines-core/jvm/test/lincheck/MutexLincheckTest.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ package kotlinx.coroutines.lincheck
44
import kotlinx.coroutines.*
55
import kotlinx.coroutines.selects.*
66
import kotlinx.coroutines.sync.*
7-
import org.jetbrains.kotlinx.lincheck.*
8-
import org.jetbrains.kotlinx.lincheck.annotations.*
9-
import org.jetbrains.kotlinx.lincheck.annotations.Operation
10-
import org.jetbrains.kotlinx.lincheck.paramgen.*
7+
import org.jetbrains.lincheck.datastructures.*
118

129
@Param(name = "owner", gen = IntGen::class, conf = "0:2")
1310
class MutexLincheckTest : AbstractLincheckTest() {
1411
private val mutex = Mutex()
1512

16-
@Operation(handleExceptionsAsResult = [IllegalStateException::class])
13+
@Operation
1714
fun tryLock(@Param(name = "owner") owner: Int) = mutex.tryLock(owner.asOwnerOrNull)
1815

1916
// TODO: `lock()` with non-null owner is non-linearizable
@@ -22,10 +19,10 @@ class MutexLincheckTest : AbstractLincheckTest() {
2219

2320
// TODO: `onLock` with non-null owner is non-linearizable
2421
// onLock may suspend in case of clause re-registration.
25-
@Operation(allowExtraSuspension = true, promptCancellation = true)
22+
@Operation(promptCancellation = true)
2623
suspend fun onLock() = select<Unit> { mutex.onLock(null) {} }
2724

28-
@Operation(handleExceptionsAsResult = [IllegalStateException::class])
25+
@Operation
2926
fun unlock(@Param(name = "owner") owner: Int) = mutex.unlock(owner.asOwnerOrNull)
3027

3128
@Operation

kotlinx-coroutines-core/jvm/test/lincheck/ResizableAtomicArrayLincheckTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package kotlinx.coroutines.lincheck
22

33
import kotlinx.coroutines.*
44
import kotlinx.coroutines.internal.*
5-
import org.jetbrains.kotlinx.lincheck.annotations.*
6-
import org.jetbrains.kotlinx.lincheck.paramgen.*
5+
import org.jetbrains.lincheck.datastructures.*
76

87
@Param(name = "index", gen = IntGen::class, conf = "0:4")
98
@Param(name = "value", gen = IntGen::class, conf = "1:5")

kotlinx-coroutines-core/jvm/test/lincheck/SemaphoreLincheckTest.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
@file:Suppress("unused")
22
package kotlinx.coroutines.lincheck
33

4-
import kotlinx.coroutines.testing.*
54
import kotlinx.coroutines.*
65
import kotlinx.coroutines.sync.*
7-
import org.jetbrains.kotlinx.lincheck.*
8-
import org.jetbrains.kotlinx.lincheck.annotations.Operation
9-
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.*
6+
import org.jetbrains.lincheck.datastructures.*
107

118
abstract class SemaphoreLincheckTestBase(permits: Int) : AbstractLincheckTest() {
129
private val semaphore = SemaphoreAndMutexImpl(permits = permits, acquiredPermits = 0)
1310

1411
@Operation
1512
fun tryAcquire() = semaphore.tryAcquire()
1613

17-
@Operation(promptCancellation = true, allowExtraSuspension = true)
14+
@Operation(promptCancellation = true)
1815
suspend fun acquire() = semaphore.acquire()
1916

20-
@Operation(handleExceptionsAsResult = [IllegalStateException::class])
17+
@Operation
2118
fun release() = semaphore.release()
2219

2320
override fun <O : Options<O, *>> O.customize(isStressTest: Boolean): O =

0 commit comments

Comments
 (0)