JNI for test coverage #3965
This commit is contained in:
parent
c60e4231e1
commit
82686cfb9f
|
@ -1,13 +1,23 @@
|
||||||
package com.rusefi.native_;
|
package com.rusefi.native_;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Following VM option is needed to launch:
|
* Following VM option is needed to launch:
|
||||||
* -Djava.library.path=../unit_tests/build
|
* -Djava.library.path=../unit_tests/build
|
||||||
*/
|
*/
|
||||||
public class JniSandbox {
|
public class JniSandbox {
|
||||||
|
|
||||||
|
private static final String LIBNAME = "lib_rusefi_test";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.loadLibrary("lib_rusefi_test");
|
String[] list = new File(".").list((dir, name) -> name.startsWith(LIBNAME));
|
||||||
|
System.out.println(" " + Arrays.toString(list));
|
||||||
|
System.loadLibrary(LIBNAME);
|
||||||
|
|
||||||
EngineLogic engineLogic = new EngineLogic();
|
EngineLogic engineLogic = new EngineLogic();
|
||||||
System.out.println(engineLogic.getVersion());
|
System.out.println(engineLogic.getVersion());
|
||||||
|
engineLogic.setConfiguration(new byte[4], 24, 14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,24 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "com_rusefi_native__EngineLogic.h"
|
#include "com_rusefi_native__EngineLogic.h"
|
||||||
|
|
||||||
|
//static EngineTestHelper eth(TEST_ENGINE);
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion(JNIEnv * env, jobject) {
|
JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion(JNIEnv * env, jobject) {
|
||||||
const char msg[60] = "Hello from unit tests";
|
const char msg[60] = "Hello from unit tests";
|
||||||
const char* fileName = msg;
|
const char* fileName = msg;
|
||||||
jstring result = env->NewStringUTF(msg);
|
jstring result = env->NewStringUTF(msg);
|
||||||
|
printf("[native] hello\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getConfiguration(JNIEnv *env, jobject) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setConfiguration(JNIEnv *env, jobject instance,
|
||||||
|
jbyteArray data, jint offset, jint size) {
|
||||||
|
|
||||||
|
printf("[native] setConfiguration %d %d\n", offset, size);
|
||||||
|
// printf("[native] engine %d %d\n", engineConfiguration->engineType);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue