[K/N][Tests] Migrate framework and objcexport tests

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-22 20:12:14 +01:00
committed by Space Team
parent f00a145dd7
commit 025771460c
136 changed files with 698 additions and 416 deletions
@@ -0,0 +1,4 @@
enum class SimpleEnum {
ONE,
TWO
}
@@ -0,0 +1,49 @@
import Kt56233
func threadRoutine(pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? {
autoreleasepool {
let f = pointer.bindMemory(to: (() -> ()).self, capacity: 1).pointee
f()
}
return nil
}
func launchThreads(
_ f: @convention(c) () -> (),
threadCount: Int = 4
) throws {
var threads: [pthread_t] = []
for _ in 0..<threadCount {
let fPtr = UnsafeMutablePointer<() -> ()>.allocate(capacity: 1)
fPtr.initialize(to: f)
var thread: pthread_t? = nil
let result = pthread_create(&thread, nil, threadRoutine, fPtr)
try assertEquals(actual: result, expected: 0)
threads.append(thread!)
}
for thread in threads {
pthread_join(thread, nil)
}
}
func kt56233() {
#if AGGRESSIVE_GC
let count = 50_000
#else
let count = 50_000_000
#endif
// Stress testing for race conditions.
for _ in 0..<count {
_ = Kt56233.SimpleEnum.two.ordinal
}
}
// -------- Execution of the test --------
class Kt56233Tests : SimpleTestProvider {
override init() {
super.init()
test("Kt56233", { try launchThreads(kt56233) })
}
}