Skip to content

Commit 8e2a84d

Browse files
ndkovalelizarov
authored andcommitted
Make Semaphore and Mutex stress tests concurrent
Fixes #1478
1 parent f0c2c5b commit 8e2a84d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

kotlinx-coroutines-core/jvm/test/sync/MutexStressTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import kotlin.test.*
99

1010
class MutexStressTest : TestBase() {
1111
@Test
12-
fun testStress() = runTest {
12+
fun testStress() = runBlocking(Dispatchers.Default) {
1313
val n = 1000 * stressTestMultiplier
1414
val k = 100
1515
var shared = 0

kotlinx-coroutines-core/jvm/test/sync/SemaphoreStressTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package kotlinx.coroutines.sync
22

33
import kotlinx.coroutines.*
44
import org.junit.Test
5-
import org.junit.After
65
import kotlin.test.assertEquals
76

87
class SemaphoreStressTest : TestBase() {
98

109
@Test
11-
fun stressTestAsMutex() = runTest {
10+
fun stressTestAsMutex() = runBlocking(Dispatchers.Default) {
1211
val n = 10_000 * stressTestMultiplier
1312
val k = 100
1413
var shared = 0
@@ -27,7 +26,7 @@ class SemaphoreStressTest : TestBase() {
2726
}
2827

2928
@Test
30-
fun stressTest() = runTest {
29+
fun stressTest() = runBlocking(Dispatchers.Default) {
3130
val n = 10_000 * stressTestMultiplier
3231
val k = 100
3332
val semaphore = Semaphore(10)
@@ -43,7 +42,7 @@ class SemaphoreStressTest : TestBase() {
4342
}
4443

4544
@Test
46-
fun stressCancellation() = runTest {
45+
fun stressCancellation() = runBlocking(Dispatchers.Default) {
4746
val n = 10_000 * stressTestMultiplier
4847
val semaphore = Semaphore(1)
4948
semaphore.acquire()

0 commit comments

Comments
 (0)