JNI for test coverage #3965

This commit is contained in:
rusefillc 2022-03-13 00:25:10 -05:00
parent dd8eb8bef9
commit 20cf22665e
7 changed files with 21 additions and 7 deletions

View File

@ -17,6 +17,15 @@ jobs:
- name: Test Compiler
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
env:
RUSEFI_ANDROID_KEYPASS: ${{ secrets.RUSEFI_ANDROID_KEYPASS }}

View File

@ -29,7 +29,7 @@ jobs:
working-directory: .
run: gcc -v
- name: Build Tests
- 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

View File

@ -8,6 +8,10 @@ configurations {
all*.exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
tasks.withType(Test) {
systemProperty "java.library.path", "../../unit_tests/build"
}
dependencies {
implementation libs.javaxJson
implementation project(':inifile')

View File

@ -9,7 +9,7 @@ import java.util.Arrays;
*/
public class JniSandbox {
private static final String LIBNAME = "lib_rusefi_test";
private static final String LIBNAME = "_rusefi_test";
public static void main(String[] args) {
loadLibrary();
@ -22,7 +22,8 @@ public class JniSandbox {
public static void loadLibrary() {
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.loadLibrary(LIBNAME);
}

View File

@ -1,13 +1,11 @@
package com.rusefi.native_;
import org.junit.Ignore;
import org.junit.Test;
import static junit.framework.Assert.assertTrue;
public class JniUnitTest {
@Test
@Ignore
public void run() {
JniSandbox.loadLibrary();

View File

@ -9,13 +9,14 @@ ifeq ($(BUILDDIR),.)
BUILDDIR = build
endif
BINARY_OUTPUT = $(BUILDDIR)/$(PROJECT)
SHARED_OUTPUT = $(BUILDDIR)/lib_$(PROJECT)
ifeq ($(OS),Windows_NT)
# todo: something is not right here how can we avoid explicit suffix?
# should not gcc figure it out based on 'shared' option?
SHARED_OUTPUT = $(BUILDDIR)/_$(PROJECT)
SHARED_OUTPUT_OPT = $(SHARED_OUTPUT).dll
else
SHARED_OUTPUT = $(BUILDDIR)/lib_$(PROJECT)
SHARED_OUTPUT_OPT = $(SHARED_OUTPUT).so
endif

View File

@ -15,7 +15,8 @@ PCHSUB = unit_tests
include $(PROJECT_DIR)/rusefi_rules.mk
ifneq ($(OS),Windows_NT)
SANITIZE = yes
# at the moment lib asan breaks JNI static library
SANITIZE = no
else
SANITIZE = no
endif