[K/N][Tests] Migrate test illegal_sharing_with_weak.kt

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-17 22:12:24 +01:00
parent 647a907204
commit 2d0009ff99
9 changed files with 85 additions and 55 deletions
@@ -1165,10 +1165,6 @@ if (PlatformInfo.isAppleTarget(project)) {
it.headers "$projectDir/framework/gh3343/objclib.h"
it.linkerOpts "-lobjcgh3343"
}
createInterop("objc_illegal_sharing_with_weak") {
it.defFile 'interop/objc/illegal_sharing_with_weak/objclib.def'
it.headers "$projectDir/interop/objc/illegal_sharing_with_weak/objclib.h"
}
createInterop("objcKt43517") {
it.defFile 'framework/kt43517/kt43517.def'
}
@@ -1618,13 +1614,6 @@ if (PlatformInfo.isAppleTarget(project)) {
}
}
interopTest("interop_objc_illegal_sharing_with_weak") {
source = "interop/objc/illegal_sharing_with_weak/main.kt"
interop = 'objc_illegal_sharing_with_weak'
// Experimental MM supports arbitrary object sharing.
outputChecker = { it == "Before\nAfter true\n" }
}
interopTest("interop_objc_kt42172") {
enabled = !isNoopGC
source = "interop/objc/kt42172/main.kt"
@@ -1,29 +0,0 @@
@file:OptIn(ObsoleteWorkersApi::class)
import kotlin.native.concurrent.*
import kotlinx.cinterop.autoreleasepool
import objclib.*
fun main() {
autoreleasepool {
run()
}
}
private class NSObjectImpl : NSObject() {
var x = 111
}
fun run() = withWorker {
val obj = NSObjectImpl()
setObject(obj)
println("Before")
val isAlive = try {
execute(TransferMode.SAFE, {}) {
isObjectAliveShouldCrash()
}.result
} catch (e: Throwable) {
false
}
println("After $isAlive")
}
@@ -1,2 +0,0 @@
language = Objective-C
headerFilter = **/objclib.h
@@ -1,13 +0,0 @@
#import <objc/NSObject.h>
static NSObject* __weak globalObject = nil;
void setObject(NSObject* obj) {
globalObject = obj;
}
// Make sure this function persists, because the test expects to find this function in the stack trace.
__attribute__((noinline))
bool isObjectAliveShouldCrash() {
return globalObject != nil;
}