From 968bf424b49df9a98699567834cb51ea53d826a1 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Fri, 28 Apr 2023 17:10:07 +0000 Subject: [PATCH] [K/N] Fix interop_objc_kt56402 with different GCs ^KT-56402 Merge-request: KT-MR-9865 Merged-by: Alexander Shabalin --- kotlin-native/backend.native/tests/build.gradle | 4 +++- .../backend.native/tests/interop/objc/kt56402/main.kt | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 69fa5910230..3bbdea75cb7 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -5291,7 +5291,9 @@ if (PlatformInfo.isAppleTarget(project)) { interopTest("interop_objc_kt56402") { // Test depends on macOS-specific AppKit - enabled = (project.testTarget == 'macos_x64' || project.testTarget == 'macos_arm64' || project.testTarget == null) && isExperimentalMM + enabled = (project.testTarget == 'macos_x64' || project.testTarget == 'macos_arm64' || project.testTarget == null) + && isExperimentalMM + && !isNoopGC // requires some GC source = 'interop/objc/kt56402/main.kt' interop = "objc_kt56402" flags = ["-tr", "-e", "runAllTests"] // Generate test suites, but use custom entrypoint. diff --git a/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt b/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt index 70ca83b05e1..eca4bdee3ae 100644 --- a/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt +++ b/kotlin-native/backend.native/tests/interop/objc/kt56402/main.kt @@ -53,7 +53,12 @@ fun alloc(ctor: ((ULong) -> Unit) -> ULong): ULong = autoreleasepool { fun waitDestruction(id: ULong) { assertTrue(isMainThread()) - kotlin.native.internal.GC.collect() + // Make sure the finalizers are not run on the main thread even for STMS. + withWorker { + execute(TransferMode.SAFE, {}) { + kotlin.native.internal.GC.collect() + }.result + } while (true) { spin() if (!(id in aliveObjectIds)) {