[K/N] Added test for exceptions behaviour in case of dynamic libs (KT-47828)

This commit is contained in:
Elena Lepilkina
2021-11-15 11:58:21 +03:00
committed by Space
parent 167a4c6b97
commit c06875b8e9
3 changed files with 31 additions and 0 deletions
@@ -5152,6 +5152,15 @@ dynamicTest("interop_exceptions_throwThroughBridge") {
interop = "exceptions_throwThroughBridge"
}
dynamicTest("interop_kotlin_exception_hook") {
disabled = (project.testTarget == 'wasm32') // Uses exceptions + dynamic is unsupported for wasm.
source = "interop/exceptions/exceptionHook.kt"
cSource = "$projectDir/interop/exceptions/exceptionHook.cpp"
clangTool = "clang++"
expectedExitStatusChecker = { it != 0 }
outputChecker = { s -> s.contains("OK. Kotlin unhandled exception hook") }
}
interopTest("interop_exceptions_cCallback") {
disabled = (project.testTarget == 'wasm32') // Uses exceptions
source = "interop/exceptions/cCallback.kt"
@@ -0,0 +1,11 @@
#include "testlib_api.h"
#include <stdio.h>
int main(int argc, char** argv) {
try {
testlib_symbols()->kotlin.root.setHookAndThrow();
} catch (...) {
printf("FAIL. Native catch.\n");
}
}
@@ -0,0 +1,11 @@
import kotlin.native.concurrent.freeze
// KT-47828
fun setHookAndThrow() {
val hook = { _: Throwable ->
println("OK. Kotlin unhandled exception hook")
}
hook.freeze()
setUnhandledExceptionHook(hook)
throw Exception("Error")
}