JNI for test coverage #3965
This commit is contained in:
parent
dd8eb8bef9
commit
20cf22665e
|
@ -17,6 +17,15 @@ jobs:
|
||||||
- name: Test Compiler
|
- name: Test Compiler
|
||||||
run: javac -version
|
run: javac -version
|
||||||
|
|
||||||
|
- name: Print GCC version
|
||||||
|
working-directory: .
|
||||||
|
run: gcc -v
|
||||||
|
|
||||||
|
- name: Build Native Unit Tests as shared library
|
||||||
|
working-directory: ./unit_tests/
|
||||||
|
# we have a unit test of JNI thus we need to build shared library
|
||||||
|
run: make -j4
|
||||||
|
|
||||||
- name: Build Android
|
- name: Build Android
|
||||||
env:
|
env:
|
||||||
RUSEFI_ANDROID_KEYPASS: ${{ secrets.RUSEFI_ANDROID_KEYPASS }}
|
RUSEFI_ANDROID_KEYPASS: ${{ secrets.RUSEFI_ANDROID_KEYPASS }}
|
||||||
|
|
|
@ -29,7 +29,7 @@ jobs:
|
||||||
working-directory: .
|
working-directory: .
|
||||||
run: gcc -v
|
run: gcc -v
|
||||||
|
|
||||||
- name: Build Tests
|
- name: Build Native Unit Tests as shared library
|
||||||
working-directory: ./unit_tests/
|
working-directory: ./unit_tests/
|
||||||
# we have a unit test of JNI thus we need to build shared library
|
# we have a unit test of JNI thus we need to build shared library
|
||||||
run: make -j4
|
run: make -j4
|
||||||
|
|
|
@ -8,6 +8,10 @@ configurations {
|
||||||
all*.exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
all*.exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(Test) {
|
||||||
|
systemProperty "java.library.path", "../../unit_tests/build"
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation libs.javaxJson
|
implementation libs.javaxJson
|
||||||
implementation project(':inifile')
|
implementation project(':inifile')
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Arrays;
|
||||||
*/
|
*/
|
||||||
public class JniSandbox {
|
public class JniSandbox {
|
||||||
|
|
||||||
private static final String LIBNAME = "lib_rusefi_test";
|
private static final String LIBNAME = "_rusefi_test";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
loadLibrary();
|
loadLibrary();
|
||||||
|
@ -22,7 +22,8 @@ public class JniSandbox {
|
||||||
|
|
||||||
public static void loadLibrary() {
|
public static void loadLibrary() {
|
||||||
String libPath = System.getProperty("java.library.path");
|
String libPath = System.getProperty("java.library.path");
|
||||||
String[] list = new File(libPath).list((dir, name) -> name.startsWith(LIBNAME));
|
System.out.println("Checking " + libPath);
|
||||||
|
String[] list = new File(libPath).list((dir, name) -> name.contains(LIBNAME));
|
||||||
System.out.println(" " + Arrays.toString(list));
|
System.out.println(" " + Arrays.toString(list));
|
||||||
System.loadLibrary(LIBNAME);
|
System.loadLibrary(LIBNAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package com.rusefi.native_;
|
package com.rusefi.native_;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
public class JniUnitTest {
|
public class JniUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void run() {
|
public void run() {
|
||||||
JniSandbox.loadLibrary();
|
JniSandbox.loadLibrary();
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,14 @@ ifeq ($(BUILDDIR),.)
|
||||||
BUILDDIR = build
|
BUILDDIR = build
|
||||||
endif
|
endif
|
||||||
BINARY_OUTPUT = $(BUILDDIR)/$(PROJECT)
|
BINARY_OUTPUT = $(BUILDDIR)/$(PROJECT)
|
||||||
SHARED_OUTPUT = $(BUILDDIR)/lib_$(PROJECT)
|
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
# todo: something is not right here how can we avoid explicit suffix?
|
# todo: something is not right here how can we avoid explicit suffix?
|
||||||
# should not gcc figure it out based on 'shared' option?
|
# should not gcc figure it out based on 'shared' option?
|
||||||
|
SHARED_OUTPUT = $(BUILDDIR)/_$(PROJECT)
|
||||||
SHARED_OUTPUT_OPT = $(SHARED_OUTPUT).dll
|
SHARED_OUTPUT_OPT = $(SHARED_OUTPUT).dll
|
||||||
else
|
else
|
||||||
|
SHARED_OUTPUT = $(BUILDDIR)/lib_$(PROJECT)
|
||||||
SHARED_OUTPUT_OPT = $(SHARED_OUTPUT).so
|
SHARED_OUTPUT_OPT = $(SHARED_OUTPUT).so
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ PCHSUB = unit_tests
|
||||||
include $(PROJECT_DIR)/rusefi_rules.mk
|
include $(PROJECT_DIR)/rusefi_rules.mk
|
||||||
|
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
SANITIZE = yes
|
# at the moment lib asan breaks JNI static library
|
||||||
|
SANITIZE = no
|
||||||
else
|
else
|
||||||
SANITIZE = no
|
SANITIZE = no
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in New Issue