rusefi/java_console/io/src/test/java/com/rusefi/native_/JniSandbox.java

41 lines
1.3 KiB
Java
Raw Normal View History

2022-02-26 14:48:07 -08:00
package com.rusefi.native_;
2022-11-26 13:33:27 -08:00
import com.rusefi.FileLog;
import javax.xml.bind.SchemaOutputResolver;
2022-02-28 09:29:02 -08:00
import java.io.File;
import java.util.Arrays;
2022-02-26 14:48:07 -08:00
/**
* Following VM option is needed to launch:
* -Djava.library.path=../unit_tests/build
*/
public class JniSandbox {
2022-02-28 09:29:02 -08:00
2022-03-12 21:25:10 -08:00
private static final String LIBNAME = "_rusefi_test";
2022-02-28 09:29:02 -08:00
2022-02-26 14:48:07 -08:00
public static void main(String[] args) {
2022-02-28 21:27:13 -08:00
loadLibrary();
2022-02-28 09:29:02 -08:00
2022-02-26 14:48:07 -08:00
EngineLogic engineLogic = new EngineLogic();
System.out.println(engineLogic.getVersion());
2022-03-12 20:47:38 -08:00
engineLogic.setSensor("clt", 90);
2022-02-28 09:29:02 -08:00
engineLogic.setConfiguration(new byte[4], 24, 14);
2022-02-26 14:48:07 -08:00
}
2022-02-28 21:27:13 -08:00
public static void loadLibrary() {
String libPath = System.getProperty("java.library.path");
2022-11-26 13:33:27 -08:00
System.out.println("Looking for libraries at " + libPath);
2022-03-12 21:25:10 -08:00
String[] list = new File(libPath).list((dir, name) -> name.contains(LIBNAME));
2022-11-26 13:33:27 -08:00
System.out.println("Matching files: " + Arrays.toString(list));
if (list.length == 0) {
if (FileLog.isWindows()) {
System.out.println("Have you invoked `make -j4 SANITIZE=no build/_rusefi_test'?");
} else {
System.out.println("Have you invoked `make -j4 SANITIZE=no build/lib_rusefi_test`?");
}
}
2022-02-28 21:27:13 -08:00
System.loadLibrary(LIBNAME);
}
2022-02-26 14:48:07 -08:00
}