diff --git a/.github/workflows/build-android.yaml b/.github/workflows/build-android.yaml index 524d9639db..316faa0c2b 100644 --- a/.github/workflows/build-android.yaml +++ b/.github/workflows/build-android.yaml @@ -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 }} diff --git a/.github/workflows/build-rusEFI-console.yaml b/.github/workflows/build-rusEFI-console.yaml index 7ad140811b..8fad26c64f 100644 --- a/.github/workflows/build-rusEFI-console.yaml +++ b/.github/workflows/build-rusEFI-console.yaml @@ -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 diff --git a/java_console/io/build.gradle b/java_console/io/build.gradle index 952f2ce7dc..ed55002d61 100644 --- a/java_console/io/build.gradle +++ b/java_console/io/build.gradle @@ -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') diff --git a/java_console/io/src/test/java/com/rusefi/native_/JniSandbox.java b/java_console/io/src/test/java/com/rusefi/native_/JniSandbox.java index f978a740f1..0675eed2e0 100644 --- a/java_console/io/src/test/java/com/rusefi/native_/JniSandbox.java +++ b/java_console/io/src/test/java/com/rusefi/native_/JniSandbox.java @@ -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); } diff --git a/java_console/io/src/test/java/com/rusefi/native_/JniUnitTest.java b/java_console/io/src/test/java/com/rusefi/native_/JniUnitTest.java index 9bc51b2dda..9326ed4d74 100644 --- a/java_console/io/src/test/java/com/rusefi/native_/JniUnitTest.java +++ b/java_console/io/src/test/java/com/rusefi/native_/JniUnitTest.java @@ -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(); diff --git a/unit_tests/rules.mk b/unit_tests/rules.mk index ff894285cd..398980c83b 100644 --- a/unit_tests/rules.mk +++ b/unit_tests/rules.mk @@ -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 diff --git a/unit_tests/unit_test_rules.mk b/unit_tests/unit_test_rules.mk index 0405540322..686bbf7bb0 100644 --- a/unit_tests/unit_test_rules.mk +++ b/unit_tests/unit_test_rules.mk @@ -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