[K/N] Fix possible data races found by thread sanitizer

This commit is contained in:
Pavel Kunyavskiy
2022-07-27 15:47:34 +02:00
committed by Space
parent 828811a47f
commit 18cda8844d
21 changed files with 267 additions and 122 deletions
@@ -48736,6 +48736,16 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/topLevelInitializtion")
@TestDataPath("$PROJECT_ROOT")
public class TopLevelInitializtion {
@Test
public void testAllFilesPresentInTopLevelInitializtion() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/topLevelInitializtion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/topLevelPrivate")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,41 @@
// TARGET_BACKEND: NATIVE
// FILE: 1.kt
val O = if (true) "O" else "F" // to avoid const init
val K = if (true) "K" else "A" // to avoid const init
// FILE: main.kt
import kotlin.native.concurrent.*
val sem = AtomicInt(0)
fun box() : String {
val w1 = Worker.start()
val w2 = Worker.start()
val f1 = w1.execute(
mode = TransferMode.SAFE,
{ },
{
sem.increment();
while (sem.value != 3) {}
O
}
)
val f2 = w2.execute(
mode = TransferMode.SAFE,
{ },
{
sem.increment();
while (sem.value != 3) {}
K
}
)
while (sem.value != 2) {}
sem.value = 3
val result = f1.result + f2.result
w1.requestTermination().result
w2.requestTermination().result
return result
}
@@ -47308,6 +47308,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/topLevelInitializtion")
@TestDataPath("$PROJECT_ROOT")
public class TopLevelInitializtion {
@Test
public void testAllFilesPresentInTopLevelInitializtion() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/topLevelInitializtion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/topLevelPrivate")
@TestDataPath("$PROJECT_ROOT")
@@ -48736,6 +48736,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/topLevelInitializtion")
@TestDataPath("$PROJECT_ROOT")
public class TopLevelInitializtion {
@Test
public void testAllFilesPresentInTopLevelInitializtion() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/topLevelInitializtion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/topLevelPrivate")
@TestDataPath("$PROJECT_ROOT")
@@ -38341,6 +38341,19 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
}
}
@TestMetadata("compiler/testData/codegen/box/topLevelInitializtion")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TopLevelInitializtion extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInTopLevelInitializtion() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/topLevelInitializtion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
}
@TestMetadata("compiler/testData/codegen/box/topLevelPrivate")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)