[K/N] Added test for checking C callback set with Kotlin function throwing exception

This commit is contained in:
Elena Lepilkina
2021-10-25 17:15:14 +03:00
committed by Space
parent 751f1a3b91
commit 23e5079391
4 changed files with 38 additions and 0 deletions
@@ -4338,6 +4338,11 @@ createInterop("exceptions_throwThroughBridge") {
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.
*/
@@ -5127,6 +5132,14 @@ dynamicTest("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) {
def dir = buildDir.absolutePath
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))
}