Merge "fmq_test using static passthrough libs" am: 4e5a2a5a92 am: 0a4676d0dd
am: 9a97c5fe90

Change-Id: I0e1c8c796374d544a149d7eb32cb1e2a5db51152
diff --git a/Android.bp b/Android.bp
index 664c60d..5b7459f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,6 +12,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+subdirs = [
+    "tests",
+]
+
 cc_library_shared {
     name: "libfmq",
     shared_libs: [
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..ab2b2ce
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,65 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_test {
+    name: "mq_test_client",
+    srcs: ["msgq_test_client.cpp"],
+
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libfmq",
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+    ],
+
+    // Allow dlsym'ing self for statically linked passthrough implementations
+    ldflags: ["-rdynamic"],
+
+    // These are static libs only for testing purposes and portability. Shared
+    // libs should be used on device.
+    static_libs: ["android.hardware.tests.msgq@1.0"],
+    whole_static_libs: ["android.hardware.tests.msgq@1.0-impl"],
+}
+
+cc_test {
+    name: "mq_test",
+
+    srcs: ["mq_test.cpp"],
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libfmq",
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+    ],
+
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+}
diff --git a/tests/Android.mk b/tests/Android.mk
index 673d485..718a33b 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -29,42 +29,6 @@
 include $(BUILD_PREBUILT)
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
-    msgq_test_client.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-    libhidlbase \
-    libhidltransport  \
-    libhwbinder \
-    libcutils \
-    libutils \
-    libbase \
-    libfmq \
-    liblog
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES += android.hardware.tests.msgq@1.0 libfmq
-LOCAL_MODULE := mq_test_client
-LOCAL_REQUIRED_MODULES := \
-    android.hardware.tests.msgq@1.0-impl_32 \
-    android.hardware.tests.msgq@1.0-impl
-
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
-    mq_test.cpp
-LOCAL_STATIC_LIBRARIES := libutils libcutils liblog
-LOCAL_SHARED_LIBRARIES := \
-    libhidlbase \
-    libhidltransport \
-    libhwbinder \
-    libbase \
-    libfmq
-LOCAL_MODULE := mq_test
-LOCAL_CFLAGS := -Wall -Werror
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
 
 LOCAL_MODULE := VtsFmqUnitTests
 VTS_CONFIG_SRC_DIR := system/libfmq/tests
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
index f861a10..70df24d 100644
--- a/tests/AndroidTest.xml
+++ b/tests/AndroidTest.xml
@@ -22,19 +22,12 @@
         <option name="push" value="DATA/nativetest/mq_test_client/mq_test_client->/data/nativetest/mq_test_client/mq_test_client" />
         <option name="push" value="DATA/nativetest64/mq_test_client/mq_test_client->/data/nativetest64/mq_test_client/mq_test_client" />
         <option name="push" value="DATA/nativetest64/hidl_test_helper->/data/nativetest64/hidl_test_helper" />
-        <option name="push" value="DATA/lib/android.hardware.tests.msgq@1.0.so->/data/local/tmp/system/lib/android.hardware.tests.msgq@1.0.so" />
-        <option name="push" value="DATA/lib64/android.hardware.tests.msgq@1.0.so->/data/local/tmp/system/lib64/android.hardware.tests.msgq@1.0.so" />
-        <option name="push" value="DATA/lib/hw/android.hardware.tests.msgq@1.0-impl.so->/data/local/tmp/system/lib/hw/android.hardware.tests.msgq@1.0-impl.so" />
-        <option name="push" value="DATA/lib64/hw/android.hardware.tests.msgq@1.0-impl.so->/data/local/tmp/system/lib64/hw/android.hardware.tests.msgq@1.0-impl.so" />
     </target_preparer>
     <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
     <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
         <option name="test-module-name" value="VtsFmqUnitTests" />
         <option name="binary-test-type" value="binary_test" />
         <option name="binary-test-source" value="DATA/nativetest64/fmq_test->/data/nativetest64/fmq_test" />
-        <option name="binary-test-envp" value="VTS_ROOT_PATH=/data/local/tmp" />
-        <option name="binary-test-args" value="-x /data/local/tmp/system/lib" />
-        <option name="binary-test-args" value="-y /data/local/tmp/system/lib64" />
         <option name="test-timeout" value="1m"/>
     </test>
 </configuration>