Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Semaphore and Mutex stress tests concurrent #1559

Merged
merged 1 commit into from
Sep 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/jvm/test/sync/MutexStressTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlin.test.*

class MutexStressTest : TestBase() {
@Test
fun testStress() = runTest {
fun testStress() = runBlocking(Dispatchers.Default) {
val n = 1000 * stressTestMultiplier
val k = 100
var shared = 0
Expand Down
7 changes: 3 additions & 4 deletions kotlinx-coroutines-core/jvm/test/sync/SemaphoreStressTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package kotlinx.coroutines.sync

import kotlinx.coroutines.*
import org.junit.Test
import org.junit.After
import kotlin.test.assertEquals

class SemaphoreStressTest : TestBase() {

@Test
fun stressTestAsMutex() = runTest {
fun stressTestAsMutex() = runBlocking(Dispatchers.Default) {
val n = 10_000 * stressTestMultiplier
val k = 100
var shared = 0
Expand All @@ -27,7 +26,7 @@ class SemaphoreStressTest : TestBase() {
}

@Test
fun stressTest() = runTest {
fun stressTest() = runBlocking(Dispatchers.Default) {
val n = 10_000 * stressTestMultiplier
val k = 100
val semaphore = Semaphore(10)
Expand All @@ -43,7 +42,7 @@ class SemaphoreStressTest : TestBase() {
}

@Test
fun stressCancellation() = runTest {
fun stressCancellation() = runBlocking(Dispatchers.Default) {
val n = 10_000 * stressTestMultiplier
val semaphore = Semaphore(1)
semaphore.acquire()
Expand Down