[K/N] Added test for exceptions behaviour in case of dynamic libs (KT-47828)
This commit is contained in:
@@ -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")
|
||||
}
|
||||
Reference in New Issue
Block a user