From b1811a8bf6b716fbd2782471a5264047a487dc0e Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 12 Jul 2012 11:50:40 +0000 Subject: [PATCH] HW compatibility tests added; Arm-v7a neon package support enabled. --- android/service/engine/jni/Android.mk | 4 +- .../engine/jni/NativeService/PackageInfo.cpp | 36 +++++++----------- .../engine/jni/Tests/OpenCVEngineTest.cpp | 38 +++++++++++++++++++ android/service/engine/jni/Tests/Tests.mk | 4 +- 4 files changed, 55 insertions(+), 27 deletions(-) diff --git a/android/service/engine/jni/Android.mk b/android/service/engine/jni/Android.mk index ded931f57a..be73f6c5bd 100644 --- a/android/service/engine/jni/Android.mk +++ b/android/service/engine/jni/Android.mk @@ -24,8 +24,8 @@ LOCAL_C_INCLUDES := \ $(TOP)/system/core/include LOCAL_CFLAGS += -DPLATFORM_ANDROID +LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES #LOCAL_CFLAGS += -D__SUPPORT_TEGRA3 -#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES #LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES LOCAL_PRELINK_MODULE := false @@ -65,8 +65,8 @@ LOCAL_C_INCLUDES := \ LOCAL_PRELINK_MODULE := false LOCAL_CFLAGS += -DPLATFORM_ANDROID +LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES #LOCAL_CFLAGS += -D__SUPPORT_TEGRA3 -#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES #LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES LOCAL_MODULE := libOpenCVEngine_jni diff --git a/android/service/engine/jni/NativeService/PackageInfo.cpp b/android/service/engine/jni/NativeService/PackageInfo.cpp index fc6e43df0f..65828e7402 100644 --- a/android/service/engine/jni/NativeService/PackageInfo.cpp +++ b/android/service/engine/jni/NativeService/PackageInfo.cpp @@ -206,21 +206,19 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::s { if (ARCH_X86 & CpuID) { - LOGD("Found processor with x86 arch"); + LOGD("PackageInfo::PackageInfo: package arch x86"); FullName += string("_") + ARCH_X86_NAME; #ifdef __SUPPORT_INTEL_FEATURES string features = JoinIntelFeatures(CpuID); -#else - string features; -#endif if (!features.empty()) { FullName += string("_") + features; } +#endif } else if (ARCH_X64 & CpuID) { - LOGD("Found processor with x64 arch"); + LOGD("PackageInfo::PackageInfo: package arch x64"); #ifdef __SUPPORT_INTEL_x64 FullName += string("_") + ARCH_X64_NAME; #else @@ -228,61 +226,53 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::s #endif #ifdef __SUPPORT_INTEL_FEATURES string features = JoinIntelFeatures(CpuID); -#else - string features; -#endif if (!features.empty()) { FullName += string("_") + features; } +#endif } else if (ARCH_ARMv5 & CpuID) { - LOGD("Found processor with ARMv5 arch"); + LOGD("PackageInfo::PackageInfo: package arch ARMv5"); FullName += string("_") + ARCH_ARMv5_NAME; #ifdef __SUPPORT_ARMEABI_FEATURES string features = JoinARMFeatures(CpuID); -#else - string features; -#endif if (!features.empty()) { FullName += string("_") + features; } +#endif } else if (ARCH_ARMv6 & CpuID) { - LOGD("Found processor with ARMv6 arch"); + LOGD("PackageInfo::PackageInfo: package arch ARMv6"); // NOTE: ARM v5 used instead ARM v6 //FullName += string("_") + ARCH_ARMv6_NAME; FullName += string("_") + ARCH_ARMv5_NAME; #ifdef __SUPPORT_ARMEABI_FEATURES string features = JoinARMFeatures(CpuID); -#else - string features; -#endif if (!features.empty()) { FullName += string("_") + features; } +#endif } else if (ARCH_ARMv7 & CpuID) { - LOGD("Found processor with ARMv7 arch"); + LOGD("PackageInfo::PackageInfo: package arch ARMv7"); FullName += string("_") + ARCH_ARMv7_NAME; #ifdef __SUPPORT_ARMEABI_V7A_FEATURES string features = JoinARMFeatures(CpuID); -#else - string features; -#endif if (!features.empty()) { FullName += string("_") + features; } +#endif } else if (ARCH_ARMv8 & CpuID) { - LOGD("Found processor with ARMv8 arch"); + LOGD("PackageInfo::PackageInfo: package arch ARMv8"); #ifdef __SUPPORT_ARMEABI_V8 FullName += string("_") + ARCH_ARMv8_NAME; #else @@ -296,7 +286,7 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::s } else { - LOGD("Found processor with unknown arch"); + LOGD("PackageInfo::PackageInfo: package arch unknown"); Version.clear(); CpuID = ARCH_UNKNOWN; Platform = PLATFORM_UNKNOWN; @@ -304,7 +294,7 @@ PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::s } else { - LOGD("Found processor with unknown arch"); + LOGD("PackageInfo::PackageInfo: package arch unknown"); Version.clear(); CpuID = ARCH_UNKNOWN; Platform = PLATFORM_UNKNOWN; diff --git a/android/service/engine/jni/Tests/OpenCVEngineTest.cpp b/android/service/engine/jni/Tests/OpenCVEngineTest.cpp index a198a474a9..4ea8b3d2ea 100644 --- a/android/service/engine/jni/Tests/OpenCVEngineTest.cpp +++ b/android/service/engine/jni/Tests/OpenCVEngineTest.cpp @@ -118,6 +118,44 @@ TEST(OpenCVEngineTest, GetPathForUnExistVersion) EXPECT_EQ(0, result.size()); } +TEST(OpenCVEngineTest, GetPathForCompatiblePackage1) +{ + sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv5); + EXPECT_FALSE(NULL == Engine.get()); + String16 result = Engine->GetLibPathByVersion(String16("2.4")); + EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", String8(result).string()); +} + +TEST(OpenCVEngineTest, GetPathForCompatiblePackage2) +{ + sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + EXPECT_FALSE(NULL == Engine.get()); + String16 result = Engine->GetLibPathByVersion(String16("2.4")); +#ifdef __SUPPORT_TEGRA3 + EXPECT_STREQ("/data/data/org.opencv.lib_v24_tegra3/lib", String8(result).string()); +#else +#ifdef __SUPPORT_ARMEABI_V7A_FEATURES + EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a_neon/lib", String8(result).string()); +#else + EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string()); +#endif +#endif +} + +TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1) +{ + sp Engine = InitConnect(); + Starter.PackageManager->InstalledPackages.clear(); + Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X64); + EXPECT_FALSE(NULL == Engine.get()); + String16 result = Engine->GetLibPathByVersion(String16("2.4")); + EXPECT_EQ(0, result.size()); +} + TEST(OpenCVEngineTest, InstallAndGetVersion) { sp Engine = InitConnect(); diff --git a/android/service/engine/jni/Tests/Tests.mk b/android/service/engine/jni/Tests/Tests.mk index 4fe1111849..3dab5f010a 100644 --- a/android/service/engine/jni/Tests/Tests.mk +++ b/android/service/engine/jni/Tests/Tests.mk @@ -17,7 +17,7 @@ LOCAL_SRC_FILES := \ Tests/PackageManagmentTest.cpp \ Tests/PackageInfoTest.cpp \ Tests/OpenCVEngineTest.cpp \ - Tests/TestMain.cpp + Tests/TestMain.cpp # Tests/HardwareDetectionTest.cpp \ LOCAL_C_INCLUDES := \ @@ -31,8 +31,8 @@ LOCAL_C_INCLUDES := \ $(TOP)/system/core/include LOCAL_CFLAGS += -O0 -DGTEST_HAS_CLONE=0 -DGTEST_OS_LINUX_ANDROID=1 -DGTEST_HAS_TR1_TUPLE=0 +LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES #LOCAL_CFLAGS += -D__SUPPORT_TEGRA3 -#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES #LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES LOCAL_LDFLAGS = -Wl,-allow-shlib-undefined