blob: 9542b5d8dee66695d6bbcc3ccdcd408eee61c5a2 [file] [log] [blame]
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@file:Suppress("unused")
package kotlinx.coroutines.linearizability
import kotlinx.coroutines.*
import kotlinx.coroutines.sync.*
import org.jetbrains.kotlinx.lincheck.annotations.Operation
import org.jetbrains.kotlinx.lincheck.verifier.*
import org.junit.*
class MutexLCStressTest : VerifierState() {
private val mutex = Mutex()
@Operation
fun tryLock() = mutex.tryLock()
@Operation
suspend fun lock() = mutex.lock()
@Operation(handleExceptionsAsResult = [IllegalStateException::class])
fun unlock() = mutex.unlock()
@Test
fun test() = LCStressOptionsDefault()
.actorsBefore(0)
.check(this::class)
override fun extractState() = mutex.isLocked
}