forked from kscience/kmath
testing native exceptions
This commit is contained in:
parent
8e4f7ffce6
commit
cd362c749e
@ -42,8 +42,10 @@ val generateJNIHeader by tasks.registering {
|
|||||||
doLast {
|
doLast {
|
||||||
exec {
|
exec {
|
||||||
workingDir(projectDir.resolve("src/main/java/space/kscience/kmath/noa"))
|
workingDir(projectDir.resolve("src/main/java/space/kscience/kmath/noa"))
|
||||||
commandLine("$javaHome/bin/javac", "-h",
|
commandLine(
|
||||||
projectDir.resolve("src/main/resources") , "JNoa.java")
|
"$javaHome/bin/javac", "-h",
|
||||||
|
projectDir.resolve("src/main/resources"), "JNoa.java"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,12 +80,17 @@ val downloadTorch by tasks.registering(Download::class) {
|
|||||||
overwrite(false)
|
overwrite(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val downloadJNoa by tasks.registering(Download::class) {
|
fun downloadJNoaHelper(update: Boolean) = tasks.registering(Download::class) {
|
||||||
src("https://github.com/grinisrit/noa/archive/refs/heads/kmath.zip")
|
src("https://github.com/grinisrit/noa/archive/refs/heads/kmath.zip")
|
||||||
dest(File("$thirdPartyDir/jnoa", "kmath.zip"))
|
dest(File("$thirdPartyDir/jnoa", "kmath.zip"))
|
||||||
overwrite(false)
|
overwrite(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val downloadJNoa by downloadJNoaHelper(false)
|
||||||
|
|
||||||
|
val reDownloadJNoa by downloadJNoaHelper(true)
|
||||||
|
|
||||||
|
|
||||||
val extractCMake by tasks.registering(Copy::class) {
|
val extractCMake by tasks.registering(Copy::class) {
|
||||||
dependsOn(downloadCMake)
|
dependsOn(downloadCMake)
|
||||||
from(tarTree(resources.gzip(downloadCMake.get().dest)))
|
from(tarTree(resources.gzip(downloadCMake.get().dest)))
|
||||||
|
@ -20,5 +20,6 @@ public class JNoa {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static native void testException();
|
||||||
public static native boolean cudaIsAvailable();
|
public static native boolean cudaIsAvailable();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,14 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: space_kscience_kmath_noa_JNoa
|
||||||
|
* Method: testException
|
||||||
|
* Signature: ()V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_space_kscience_kmath_noa_JNoa_testException
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: space_kscience_kmath_noa_JNoa
|
* Class: space_kscience_kmath_noa_JNoa
|
||||||
* Method: cudaIsAvailable
|
* Method: cudaIsAvailable
|
||||||
|
@ -10,12 +10,16 @@ import kotlin.test.Test
|
|||||||
class TestUtils {
|
class TestUtils {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testExceptions() {
|
fun throwingExceptions() {
|
||||||
try {
|
try {
|
||||||
println(cudaAvailable())
|
JNoa.testException()
|
||||||
} catch(e:NoaException) {
|
} catch(e:NoaException) {
|
||||||
println(e)
|
println("Caught NoaException in JVM\n:$e")
|
||||||
println("ALL GOOD")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun cudaSupport() {
|
||||||
|
println("CUDA support available: ${cudaAvailable()}")
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user