[K/N] Added test for checking C callback set with Kotlin function throwing exception
This commit is contained in:
@@ -4338,6 +4338,11 @@ createInterop("exceptions_throwThroughBridge") {
|
|||||||
it.extraOpts "-Xcompile-source", "$projectDir/interop/exceptions/throwThroughBridgeInterop.cpp"
|
it.extraOpts "-Xcompile-source", "$projectDir/interop/exceptions/throwThroughBridgeInterop.cpp"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createInterop("exceptions_cCallback") {
|
||||||
|
it.defFile "interop/exceptions/cCallback.def"
|
||||||
|
it.extraOpts "-Xcompile-source", "$projectDir/interop/exceptions/cCallback.cpp"
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a task for the interop test. Configures runner and adds library and test build tasks.
|
* Creates a task for the interop test. Configures runner and adds library and test build tasks.
|
||||||
*/
|
*/
|
||||||
@@ -5127,6 +5132,14 @@ dynamicTest("interop_exceptions_throwThroughBridge") {
|
|||||||
interop = "exceptions_throwThroughBridge"
|
interop = "exceptions_throwThroughBridge"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interopTest("interop_exceptions_cCallback") {
|
||||||
|
disabled = (project.testTarget == 'wasm32') // Uses exceptions
|
||||||
|
source = "interop/exceptions/cCallback.kt"
|
||||||
|
expectedExitStatusChecker = { it == 0 }
|
||||||
|
outputChecker = { s -> s.contains("CATCH IN C++") }
|
||||||
|
interop = "exceptions_cCallback"
|
||||||
|
}
|
||||||
|
|
||||||
tasks.register("library_ir_provider_mismatch", KonanDriverTest) {
|
tasks.register("library_ir_provider_mismatch", KonanDriverTest) {
|
||||||
def dir = buildDir.absolutePath
|
def dir = buildDir.absolutePath
|
||||||
def lib = "$projectDir/link/ir_providers/library/empty.kt"
|
def lib = "$projectDir/link/ir_providers/library/empty.kt"
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern "C" void runAndCatch(void(*f)(void)) {
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (...) {
|
||||||
|
printf("CATCH IN C++!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
language = C
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
void runAndCatch(void(*f)(void));
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import kotlinx.cinterop.staticCFunction
|
||||||
|
import cCallback.runAndCatch
|
||||||
|
|
||||||
|
fun throwingCallback() {
|
||||||
|
throw IllegalStateException("Kotlin Exception!")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
runAndCatch(staticCFunction(::throwingCallback))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user