From a3039535d8e2cd557c6db734f96d6ffb0b4c4241 Mon Sep 17 00:00:00 2001 From: Alan Stokes Date: Fri, 25 Jan 2019 14:07:23 +0000 Subject: Support multi-ABI in tests. Build the test .so for all ABIs and then pick the right one to load at runtime. (The executable doesn't need this, since it runs in its own process.) Bug: 123281572 Test: atest DexLoggerIntegrationTests Test: atest DexLoggerIntegrationTests -- --abi armeabi-v7a Change-Id: I0696ef75e42834b13524abde619dc0f8e79c8363 --- tests/DexLoggerIntegrationTests/Android.mk | 11 ++++++----- .../com/android/server/pm/dex/DexLoggerIntegrationTests.java | 11 +++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/DexLoggerIntegrationTests/Android.mk b/tests/DexLoggerIntegrationTests/Android.mk index 979d13ac9405..ee02a72b6819 100644 --- a/tests/DexLoggerIntegrationTests/Android.mk +++ b/tests/DexLoggerIntegrationTests/Android.mk @@ -35,7 +35,6 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_MODULE := DexLoggerNativeTestLibrary -LOCAL_MULTILIB := first LOCAL_SRC_FILES := src/cpp/com_android_dcl_Jni.cpp LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE) @@ -44,8 +43,6 @@ LOCAL_NDK_STL_VARIANT := c++_static include $(BUILD_SHARED_LIBRARY) -dexloggertest_so := $(LOCAL_BUILT_MODULE) - # And a standalone native executable that we can exec. include $(CLEAR_VARS) @@ -73,11 +70,15 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-test \ truth-prebuilt \ +# Include both versions of the .so if we have 2 arch +LOCAL_MULTILIB := both +LOCAL_JNI_SHARED_LIBRARIES := \ + DexLoggerNativeTestLibrary \ + # This gets us the javalib.jar built by DexLoggerTestLibrary above as well as the various # native binaries. LOCAL_JAVA_RESOURCE_FILES := \ $(dexloggertest_jar) \ - $(dexloggertest_so) \ - $(dexloggertest_executable) + $(dexloggertest_executable) \ include $(BUILD_PACKAGE) diff --git a/tests/DexLoggerIntegrationTests/src/com/android/server/pm/dex/DexLoggerIntegrationTests.java b/tests/DexLoggerIntegrationTests/src/com/android/server/pm/dex/DexLoggerIntegrationTests.java index d68769b378b9..e92cc56322eb 100644 --- a/tests/DexLoggerIntegrationTests/src/com/android/server/pm/dex/DexLoggerIntegrationTests.java +++ b/tests/DexLoggerIntegrationTests/src/com/android/server/pm/dex/DexLoggerIntegrationTests.java @@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import android.app.UiAutomation; import android.content.Context; +import android.os.Build; import android.os.ParcelFileDescriptor; import android.os.SystemClock; import android.support.test.InstrumentationRegistry; @@ -147,7 +148,7 @@ public final class DexLoggerIntegrationTests { String expectedNameHash = "996223BAD4B4FE75C57A3DEC61DB9C0B38E0A7AD479FC95F33494F4BC55A0F0E"; String expectedContentHash = - copyAndHashResource("/DexLoggerNativeTestLibrary.so", privateCopyFile); + copyAndHashResource(libraryPath("DexLoggerNativeTestLibrary.so"), privateCopyFile); System.load(privateCopyFile.toString()); @@ -170,7 +171,7 @@ public final class DexLoggerIntegrationTests { String expectedNameHash = "8C39990C560B4F36F83E208E279F678746FE23A790E4C50F92686584EA2041CA"; String expectedContentHash = - copyAndHashResource("/DexLoggerNativeTestLibrary.so", privateCopyFile); + copyAndHashResource(libraryPath("DexLoggerNativeTestLibrary.so"), privateCopyFile); System.load(privateCopyFile.toString()); @@ -307,6 +308,12 @@ public final class DexLoggerIntegrationTests { return new File(sContext.getDir("dcl", Context.MODE_PRIVATE), name); } + private String libraryPath(final String libraryName) { + // This may be deprecated. but it tells us the ABI of this process which is exactly what we + // want. + return "/lib/" + Build.CPU_ABI + "/" + libraryName; + } + private static String copyAndHashResource(String resourcePath, File copyTo) throws Exception { MessageDigest hasher = MessageDigest.getInstance("SHA-256"); -- cgit v1.2.3-59-g8ed1b