[K/N] Migrate more cinterop tests
^KT-61259
This commit is contained in:
committed by
Space Team
parent
8ed7e31b5f
commit
5f51f5e1fc
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// IGNORE_NATIVE: target=linux_arm64
|
||||
// MODULE: cinterop
|
||||
// FILE: sysstat.def
|
||||
headers = sys/stat.h
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import sysstat.*
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun box(): String {
|
||||
val statBuf = nativeHeap.alloc<stat>()
|
||||
assertEquals(0, stat("/", statBuf.ptr))
|
||||
assertEquals("0", statBuf.st_uid.toString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1019,20 +1019,6 @@ void createInterop(String name, Closure conf) {
|
||||
}
|
||||
}
|
||||
|
||||
createInterop("sysstat") {
|
||||
// FIXME: creates empty file to workaround konan gradle plugin issue (should be able to have no def file)
|
||||
def f = File.createTempFile("sysstat.empty", ".def")
|
||||
it.packageName 'sysstat'
|
||||
// FIXME: this option doesn't work due to an issue in plugin: it tries to resolve header in project dir.
|
||||
//it.headers 'sys/stat.h'
|
||||
f.write("headers = sys/stat.h")
|
||||
it.defFile f
|
||||
}
|
||||
|
||||
createInterop("cstdio") {
|
||||
it.defFile 'interop/basics/cstdio.def'
|
||||
}
|
||||
|
||||
createInterop("sockets") {
|
||||
it.defFile 'interop/basics/sockets.def'
|
||||
}
|
||||
@@ -1342,31 +1328,6 @@ standaloneTest("interop_objc_allocException") {
|
||||
UtilsKt.dependsOnPlatformLibs(it)
|
||||
}
|
||||
|
||||
interopTest("interop0") {
|
||||
disabled = (project.testTarget == 'linux_arm64')
|
||||
useGoldenData = true
|
||||
source = "interop/basics/0.kt"
|
||||
interop = 'sysstat'
|
||||
}
|
||||
|
||||
interopTest("interop2") {
|
||||
useGoldenData = true
|
||||
source = "interop/basics/2.kt"
|
||||
interop = 'cstdio'
|
||||
}
|
||||
|
||||
interopTest("interop4") {
|
||||
useGoldenData = true
|
||||
source = "interop/basics/4.kt"
|
||||
interop = 'cstdio'
|
||||
}
|
||||
|
||||
standaloneTest("interop5") {
|
||||
useGoldenData = true
|
||||
source = "interop/basics/5.kt"
|
||||
UtilsKt.dependsOnPlatformLibs(it)
|
||||
}
|
||||
|
||||
interopTest("interop_concurrentTerminate") {
|
||||
source = "interop/concurrentTerminate/main.kt"
|
||||
interop = 'concurrentTerminate'
|
||||
@@ -1379,34 +1340,6 @@ interopTest("interop_embedStaticLibraries") {
|
||||
interop = 'embedStaticLibraries'
|
||||
}
|
||||
|
||||
interopTest("interop_threadStates") {
|
||||
source = "interop/threadStates/threadStates.kt"
|
||||
flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||
interop = "threadStates"
|
||||
}
|
||||
|
||||
interopTest("interop_threadStates_callbacksWithExceptions") {
|
||||
source = "interop/threadStates/callbacksWithExceptions.kt"
|
||||
interop = "threadStates"
|
||||
flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||
}
|
||||
|
||||
interopTest("interop_threadStates_unhandledException") {
|
||||
source = "interop/threadStates/unhandledException.kt"
|
||||
interop = "threadStates"
|
||||
outputChecker = { it.contains("Error. Runnable state: true") }
|
||||
expectedExitStatusChecker = { it != 0 }
|
||||
flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||
}
|
||||
|
||||
interopTest("interop_threadStates_unhandledExceptionInForeignThread") {
|
||||
source = "interop/threadStates/unhandledExceptionInForeignThread.kt"
|
||||
interop = "threadStates"
|
||||
outputChecker = { it.contains("Error. Runnable state: true") }
|
||||
expectedExitStatusChecker = { it != 0 }
|
||||
flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||
}
|
||||
|
||||
interopTest("interop_withSpaces") {
|
||||
interop ='withSpaces'
|
||||
source = "interop/basics/withSpaces.kt"
|
||||
@@ -1446,11 +1379,6 @@ interopTest("interop_leakMemoryWithRunningThreadChecked") {
|
||||
outputChecker = { s -> s.contains("Cannot run checkers when there are 1 alive runtimes at the shutdown") }
|
||||
}
|
||||
|
||||
standaloneTest("interop_pinning") {
|
||||
source = "interop/basics/pinning.kt"
|
||||
flags = [ "-tr" ]
|
||||
}
|
||||
|
||||
interopTest("interop_cppClass") {
|
||||
disabled = PlatformInfo.isAppleTarget(project) // KT-58422
|
||||
source = "interop/cpp/cppClass.kt"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import sysstat.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val statBuf = nativeHeap.alloc<stat>()
|
||||
val res = stat("/", statBuf.ptr)
|
||||
println(res)
|
||||
println(statBuf.st_uid)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
0
|
||||
0
|
||||
@@ -1,8 +0,0 @@
|
||||
headers = stdio.h
|
||||
compilerOpts.osx = -D_ANSI_SOURCE
|
||||
|
||||
---
|
||||
|
||||
static inline FILE* getStdout() {
|
||||
return stdout;
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
@Test fun pinnedByteArrayAddressOf() {
|
||||
val arr = ByteArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedStringAddressOf() {
|
||||
val str = "0000000000"
|
||||
str.usePinned {
|
||||
it.addressOf(0)
|
||||
it.addressOf(9)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedCharArrayAddressOf() {
|
||||
val arr = CharArray(10) { '0' }
|
||||
arr.usePinned {
|
||||
it.addressOf(0)
|
||||
it.addressOf(9)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedShortArrayAddressOf() {
|
||||
val arr = ShortArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedIntArrayAddressOf() {
|
||||
val arr = IntArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedLongArrayAddressOf() {
|
||||
val arr = LongArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedUByteArrayAddressOf() {
|
||||
val arr = UByteArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedUShortArrayAddressOf() {
|
||||
val arr = UShortArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedUIntArrayAddressOf() {
|
||||
val arr = UIntArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedULongArrayAddressOf() {
|
||||
val arr = ULongArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedFloatArrayAddressOf() {
|
||||
val arr = FloatArray(10) { 0.0f }
|
||||
arr.usePinned {
|
||||
assertEquals(0.0f, it.addressOf(0).pointed.value)
|
||||
assertEquals(0.0f, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pinnedDoubleArrayAddressOf() {
|
||||
val arr = DoubleArray(10) { 0.0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0.0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0.0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
callbackWithException()
|
||||
callbackWithFinally()
|
||||
callbackWithFinallyNoCatch()
|
||||
nestedCallbackWithException()
|
||||
nestedCallbackWithFinally()
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
|
||||
class CustomException() : Exception()
|
||||
|
||||
fun throwException() {
|
||||
assertRunnableThreadState()
|
||||
throw CustomException()
|
||||
}
|
||||
|
||||
fun callbackWithException() {
|
||||
try {
|
||||
runCallback(staticCFunction(::throwException))
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} catch (e: Throwable) {
|
||||
assertRunnableThreadState()
|
||||
fail("Wrong exception type: ${e.message}")
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
|
||||
fun callbackWithFinally() {
|
||||
try {
|
||||
runCallback(staticCFunction(::throwException))
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} finally {
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
|
||||
fun callbackWithFinallyNoCatch() {
|
||||
try {
|
||||
try {
|
||||
runCallback(staticCFunction(::throwException))
|
||||
} finally {
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
assertRunnableThreadState()
|
||||
} catch (_: CustomException) {}
|
||||
}
|
||||
|
||||
fun nestedCallbackWithException() {
|
||||
try {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
runCallback(staticCFunction(::throwException))
|
||||
})
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} catch (e: Throwable) {
|
||||
assertRunnableThreadState()
|
||||
fail("Wrong exception type: ${e.message}")
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
|
||||
fun nestedCallbackWithFinally() {
|
||||
try {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
runCallback(staticCFunction(::throwException))
|
||||
})
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} finally {
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void runInNewThread(void(*callback)(void)) {
|
||||
std::thread t([callback]() {
|
||||
callback();
|
||||
});
|
||||
t.join();
|
||||
}
|
||||
|
||||
extern "C" void runInForeignThread(void(*callback)(void)) {
|
||||
std::thread t([callback]() {
|
||||
// This thread is not attached to the Kotlin runtime.
|
||||
auto future = std::async(std::launch::async, callback);
|
||||
|
||||
// The machinery of the direct interop doesn't filter out a Kotlin exception thrown by the callback.
|
||||
// The get() call will re-throw this exception.
|
||||
future.get();
|
||||
});
|
||||
t.join();
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
language = C
|
||||
|
||||
---
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
int32_t answer() {
|
||||
assertNativeThreadState();
|
||||
return 42;
|
||||
}
|
||||
|
||||
void runInNewThread(void(*callback)(void));
|
||||
void runInForeignThread(void(*callback)(void));
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
nativeCall()
|
||||
callback()
|
||||
nestedCalls()
|
||||
directStaticCFunctionCall()
|
||||
callbackOnSeparateThread()
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
|
||||
fun nativeCall() {
|
||||
answer()
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun callback() {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
})
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun nestedCalls() {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
answer()
|
||||
Unit
|
||||
})
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun directStaticCFunctionCall() {
|
||||
val funPtr = staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
assertRunnableThreadState()
|
||||
funPtr()
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun callbackOnSeparateThread() {
|
||||
runInNewThread(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
})
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
val hook = { throwable: Throwable ->
|
||||
print("${throwable::class.simpleName}. Runnable state: ${Debugging.isThreadStateRunnable}")
|
||||
}
|
||||
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) {
|
||||
hook.freeze()
|
||||
}
|
||||
|
||||
setUnhandledExceptionHook(hook)
|
||||
|
||||
runInNewThread(staticCFunction<Unit> { throw Error("Error") })
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
val hook = { throwable: Throwable ->
|
||||
print("${throwable::class.simpleName}. Runnable state: ${Debugging.isThreadStateRunnable}")
|
||||
}
|
||||
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) {
|
||||
hook.freeze()
|
||||
}
|
||||
|
||||
setUnhandledExceptionHook(hook)
|
||||
|
||||
runInForeignThread(staticCFunction<Unit> { throw Error("Error") })
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(ExperimentalForeignApi::class)
|
||||
package test.kotlinx.cinterop
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
class PinnedTest {
|
||||
@Test
|
||||
fun pinnedByteArrayAddressOf() {
|
||||
val arr = ByteArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedStringAddressOf() {
|
||||
val str = "0000000000"
|
||||
str.usePinned {
|
||||
it.addressOf(0)
|
||||
it.addressOf(9)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedCharArrayAddressOf() {
|
||||
val arr = CharArray(10) { '0' }
|
||||
arr.usePinned {
|
||||
it.addressOf(0)
|
||||
it.addressOf(9)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedShortArrayAddressOf() {
|
||||
val arr = ShortArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedIntArrayAddressOf() {
|
||||
val arr = IntArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedLongArrayAddressOf() {
|
||||
val arr = LongArray(10) { 0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedUByteArrayAddressOf() {
|
||||
val arr = UByteArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedUShortArrayAddressOf() {
|
||||
val arr = UShortArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedUIntArrayAddressOf() {
|
||||
val arr = UIntArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedULongArrayAddressOf() {
|
||||
val arr = ULongArray(10) { 0U }
|
||||
arr.usePinned {
|
||||
assertEquals(0U, it.addressOf(0).pointed.value)
|
||||
assertEquals(0U, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedFloatArrayAddressOf() {
|
||||
val arr = FloatArray(10) { 0.0f }
|
||||
arr.usePinned {
|
||||
assertEquals(0.0f, it.addressOf(0).pointed.value)
|
||||
assertEquals(0.0f, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun pinnedDoubleArrayAddressOf() {
|
||||
val arr = DoubleArray(10) { 0.0 }
|
||||
arr.usePinned {
|
||||
assertEquals(0.0, it.addressOf(0).pointed.value)
|
||||
assertEquals(0.0, it.addressOf(9).pointed.value)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(10)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(-1)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MAX_VALUE)
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
it.addressOf(Int.MIN_VALUE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -2,6 +2,19 @@
|
||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
// OUTPUT_DATA_FILE: fprintf.out
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// MODULE: cinterop
|
||||
// FILE: cstdio.def
|
||||
headers = stdio.h
|
||||
compilerOpts.osx = -D_ANSI_SOURCE
|
||||
---
|
||||
static inline FILE* getStdout() {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import cstdio.*
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
// OUTPUT_DATA_FILE: printf.out
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import platform.posix.printf
|
||||
+8
@@ -2,7 +2,15 @@
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
// OUTPUT_DATA_FILE: puts.out
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// MODULE: cinterop
|
||||
// FILE: cstdio.def
|
||||
headers = stdio.h
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
import cstdio.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// OUTPUT_REGEX: Error. Runnable state:.*
|
||||
// EXIT_CODE: !0
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
#include <stdint.h>
|
||||
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
int32_t answer() {
|
||||
assertNativeThreadState();
|
||||
return 42;
|
||||
}
|
||||
|
||||
void runInNewThread(void(*callback)(void));
|
||||
void runInForeignThread(void(*callback)(void));
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void runInNewThread(void(*callback)(void)) {
|
||||
std::thread t([callback]() {
|
||||
callback();
|
||||
});
|
||||
t.join();
|
||||
}
|
||||
|
||||
extern "C" void runInForeignThread(void(*callback)(void)) {
|
||||
std::thread t([callback]() {
|
||||
// This thread is not attached to the Kotlin runtime.
|
||||
auto future = std::async(std::launch::async, callback);
|
||||
|
||||
// The machinery of the direct interop doesn't filter out a Kotlin exception thrown by the callback.
|
||||
// The get() call will re-throw this exception.
|
||||
future.get();
|
||||
});
|
||||
t.join();
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(FreezingIsDeprecated::class,
|
||||
kotlin.experimental.ExperimentalNativeApi::class,
|
||||
kotlin.native.runtime.NativeRuntimeApi::class,
|
||||
kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.test.*
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
val hook = { throwable: Throwable ->
|
||||
print("${throwable::class.simpleName}. Runnable state: ${Debugging.isThreadStateRunnable}")
|
||||
}
|
||||
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) {
|
||||
hook.freeze()
|
||||
}
|
||||
|
||||
setUnhandledExceptionHook(hook)
|
||||
|
||||
runInNewThread(staticCFunction<Unit> { throw Error("Error") })
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// OUTPUT_REGEX: Error. Runnable state:.*
|
||||
// EXIT_CODE: !0
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
#include <stdint.h>
|
||||
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
int32_t answer() {
|
||||
assertNativeThreadState();
|
||||
return 42;
|
||||
}
|
||||
|
||||
void runInNewThread(void(*callback)(void));
|
||||
void runInForeignThread(void(*callback)(void));
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void runInNewThread(void(*callback)(void)) {
|
||||
std::thread t([callback]() {
|
||||
callback();
|
||||
});
|
||||
t.join();
|
||||
}
|
||||
|
||||
extern "C" void runInForeignThread(void(*callback)(void)) {
|
||||
std::thread t([callback]() {
|
||||
// This thread is not attached to the Kotlin runtime.
|
||||
auto future = std::async(std::launch::async, callback);
|
||||
|
||||
// The machinery of the direct interop doesn't filter out a Kotlin exception thrown by the callback.
|
||||
// The get() call will re-throw this exception.
|
||||
future.get();
|
||||
});
|
||||
t.join();
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(FreezingIsDeprecated::class,
|
||||
kotlin.experimental.ExperimentalNativeApi::class,
|
||||
kotlin.native.runtime.NativeRuntimeApi::class,
|
||||
kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
val hook = { throwable: Throwable ->
|
||||
print("${throwable::class.simpleName}. Runnable state: ${Debugging.isThreadStateRunnable}")
|
||||
}
|
||||
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) {
|
||||
hook.freeze()
|
||||
}
|
||||
|
||||
setUnhandledExceptionHook(hook)
|
||||
|
||||
runInForeignThread(staticCFunction<Unit> { throw Error("Error") })
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
})
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
void runInNewThread(void(*callback)(void));
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <thread>
|
||||
|
||||
extern "C" void runInNewThread(void(*callback)(void)) {
|
||||
std::thread t([callback]() {
|
||||
callback();
|
||||
});
|
||||
t.join();
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
runInNewThread(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
})
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
try {
|
||||
runCallback(staticCFunction(::throwException))
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} catch (e: Throwable) {
|
||||
assertRunnableThreadState()
|
||||
fail("Wrong exception type: ${e.message}")
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
|
||||
class CustomException() : Exception()
|
||||
|
||||
fun throwException() {
|
||||
assertRunnableThreadState()
|
||||
throw CustomException()
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
try {
|
||||
runCallback(staticCFunction(::throwException))
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} finally {
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
|
||||
class CustomException() : Exception()
|
||||
|
||||
fun throwException() {
|
||||
assertRunnableThreadState()
|
||||
throw CustomException()
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
try {
|
||||
try {
|
||||
runCallback(staticCFunction(::throwException))
|
||||
} finally {
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
assertRunnableThreadState()
|
||||
} catch (_: CustomException) {}
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
|
||||
class CustomException() : Exception()
|
||||
|
||||
fun throwException() {
|
||||
assertRunnableThreadState()
|
||||
throw CustomException()
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun main() {
|
||||
val funPtr = staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
assertRunnableThreadState()
|
||||
funPtr()
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
#include <stdint.h>
|
||||
|
||||
void assertNativeThreadState();
|
||||
|
||||
int32_t answer() {
|
||||
assertNativeThreadState();
|
||||
return 42;
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
answer()
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
try {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
runCallback(staticCFunction(::throwException))
|
||||
})
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} catch (e: Throwable) {
|
||||
assertRunnableThreadState()
|
||||
fail("Wrong exception type: ${e.message}")
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
|
||||
class CustomException() : Exception()
|
||||
|
||||
fun throwException() {
|
||||
assertRunnableThreadState()
|
||||
throw CustomException()
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.staticCFunction
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
try {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
runCallback(staticCFunction(::throwException))
|
||||
})
|
||||
} catch (e: CustomException) {
|
||||
assertRunnableThreadState()
|
||||
return
|
||||
} finally {
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
fail("No exception thrown")
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
|
||||
class CustomException() : Exception()
|
||||
|
||||
fun throwException() {
|
||||
assertRunnableThreadState()
|
||||
throw CustomException()
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// MODULE: cinterop
|
||||
// FILE: threadStates.def
|
||||
language = C
|
||||
---
|
||||
#include <stdint.h>
|
||||
|
||||
void assertNativeThreadState();
|
||||
|
||||
void runCallback(void(*callback)(void)) {
|
||||
assertNativeThreadState();
|
||||
callback();
|
||||
assertNativeThreadState();
|
||||
}
|
||||
|
||||
int32_t answer() {
|
||||
assertNativeThreadState();
|
||||
return 42;
|
||||
}
|
||||
|
||||
// FILE: threadStates.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Implemented in the runtime for test purposes.
|
||||
extern "C" bool Kotlin_Debugging_isThreadStateNative();
|
||||
|
||||
extern "C" void assertNativeThreadState() {
|
||||
if (!Kotlin_Debugging_isThreadStateNative()) {
|
||||
printf("Incorrect thread state. Expected native thread state.");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(cinterop)
|
||||
// FILE: main.kt
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
import kotlinx.cinterop.*
|
||||
import threadStates.*
|
||||
|
||||
fun main() {
|
||||
runCallback(staticCFunction { ->
|
||||
assertRunnableThreadState()
|
||||
answer()
|
||||
Unit
|
||||
})
|
||||
assertRunnableThreadState()
|
||||
}
|
||||
|
||||
fun assertRunnableThreadState() {
|
||||
assertTrue(Debugging.isThreadStateRunnable)
|
||||
}
|
||||
+6
@@ -4928,6 +4928,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("statbuf.kt")
|
||||
public void testStatbuf() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/statbuf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("structAnonRecordMember_ExplicitAlignment.kt")
|
||||
public void testStructAnonRecordMember_ExplicitAlignment() throws Exception {
|
||||
|
||||
+6
@@ -5040,6 +5040,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("statbuf.kt")
|
||||
public void testStatbuf() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/statbuf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("structAnonRecordMember_ExplicitAlignment.kt")
|
||||
public void testStructAnonRecordMember_ExplicitAlignment() throws Exception {
|
||||
|
||||
+105
@@ -48,12 +48,30 @@ public class FirNativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/console"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fprintf.kt")
|
||||
public void testFprintf() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/fprintf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("printf.kt")
|
||||
public void testPrintf() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/printf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("println.kt")
|
||||
public void testPrintln() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/println.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("puts.kt")
|
||||
public void testPuts() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/puts.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("readLine.kt")
|
||||
public void testReadLine() throws Exception {
|
||||
@@ -186,6 +204,12 @@ public class FirNativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest
|
||||
runTest("native/native.tests/testData/standalone/termination/terminateWithUnhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledException.kt")
|
||||
public void testUnhandledException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookClosure.kt")
|
||||
public void testUnhandledExceptionHookClosure() throws Exception {
|
||||
@@ -227,5 +251,86 @@ public class FirNativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest
|
||||
public void testUnhandledExceptionHookWithProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookWithProcess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionInForeignThread.kt")
|
||||
public void testUnhandledExceptionInForeignThread() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionInForeignThread.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("native/native.tests/testData/standalone/threadStates")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("standalone")
|
||||
@EnforcedProperty(property = ClassLevelProperty.TEST_KIND, propertyValue = "STANDALONE_NO_TR")
|
||||
@UseStandardTestCaseGroupProvider()
|
||||
@Tag("frontend-fir")
|
||||
@FirPipeline()
|
||||
public class ThreadStates {
|
||||
@Test
|
||||
public void testAllFilesPresentInThreadStates() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/threadStates"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callback.kt")
|
||||
public void testCallback() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callback.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackOnSeparateThread.kt")
|
||||
public void testCallbackOnSeparateThread() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackOnSeparateThread.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackWithException.kt")
|
||||
public void testCallbackWithException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackWithException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackWithFinally.kt")
|
||||
public void testCallbackWithFinally() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackWithFinally.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackWithFinallyNoCatch.kt")
|
||||
public void testCallbackWithFinallyNoCatch() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackWithFinallyNoCatch.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("directStaticCFunctionCall.kt")
|
||||
public void testDirectStaticCFunctionCall() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/directStaticCFunctionCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nativeCall.kt")
|
||||
public void testNativeCall() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nativeCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedCallbackWithException.kt")
|
||||
public void testNestedCallbackWithException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nestedCallbackWithException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedCallbackWithFinally.kt")
|
||||
public void testNestedCallbackWithFinally() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nestedCallbackWithFinally.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedCalls.kt")
|
||||
public void testNestedCalls() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nestedCalls.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -4816,6 +4816,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("statbuf.kt")
|
||||
public void testStatbuf() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/statbuf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("structAnonRecordMember_ExplicitAlignment.kt")
|
||||
public void testStructAnonRecordMember_ExplicitAlignment() throws Exception {
|
||||
|
||||
+6
@@ -4929,6 +4929,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("statbuf.kt")
|
||||
public void testStatbuf() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/basics/statbuf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("structAnonRecordMember_ExplicitAlignment.kt")
|
||||
public void testStructAnonRecordMember_ExplicitAlignment() throws Exception {
|
||||
|
||||
+103
@@ -43,12 +43,30 @@ public class NativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/console"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fprintf.kt")
|
||||
public void testFprintf() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/fprintf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("printf.kt")
|
||||
public void testPrintf() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/printf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("println.kt")
|
||||
public void testPrintln() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/println.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("puts.kt")
|
||||
public void testPuts() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/console/puts.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("readLine.kt")
|
||||
public void testReadLine() throws Exception {
|
||||
@@ -177,6 +195,12 @@ public class NativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest {
|
||||
runTest("native/native.tests/testData/standalone/termination/terminateWithUnhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledException.kt")
|
||||
public void testUnhandledException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookClosure.kt")
|
||||
public void testUnhandledExceptionHookClosure() throws Exception {
|
||||
@@ -218,5 +242,84 @@ public class NativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest {
|
||||
public void testUnhandledExceptionHookWithProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookWithProcess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionInForeignThread.kt")
|
||||
public void testUnhandledExceptionInForeignThread() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionInForeignThread.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("native/native.tests/testData/standalone/threadStates")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("standalone")
|
||||
@EnforcedProperty(property = ClassLevelProperty.TEST_KIND, propertyValue = "STANDALONE_NO_TR")
|
||||
@UseStandardTestCaseGroupProvider()
|
||||
public class ThreadStates {
|
||||
@Test
|
||||
public void testAllFilesPresentInThreadStates() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/threadStates"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callback.kt")
|
||||
public void testCallback() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callback.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackOnSeparateThread.kt")
|
||||
public void testCallbackOnSeparateThread() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackOnSeparateThread.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackWithException.kt")
|
||||
public void testCallbackWithException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackWithException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackWithFinally.kt")
|
||||
public void testCallbackWithFinally() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackWithFinally.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callbackWithFinallyNoCatch.kt")
|
||||
public void testCallbackWithFinallyNoCatch() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/callbackWithFinallyNoCatch.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("directStaticCFunctionCall.kt")
|
||||
public void testDirectStaticCFunctionCall() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/directStaticCFunctionCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nativeCall.kt")
|
||||
public void testNativeCall() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nativeCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedCallbackWithException.kt")
|
||||
public void testNestedCallbackWithException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nestedCallbackWithException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedCallbackWithFinally.kt")
|
||||
public void testNestedCallbackWithFinally() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nestedCallbackWithFinally.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedCalls.kt")
|
||||
public void testNestedCalls() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/threadStates/nestedCalls.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user