Merge "Show the library names in the assertion messages of vts-vndk"
diff --git a/dependency/VtsVndkDependencyTest.py b/dependency/VtsVndkDependencyTest.py
index 728c29a..81e22b5 100644
--- a/dependency/VtsVndkDependencyTest.py
+++ b/dependency/VtsVndkDependencyTest.py
@@ -154,9 +154,48 @@
         if target_file_utils.IsExecutable(permissions):
             return True
 
-        logging.debug("%s is not for application processor", target_path)
         return False
 
+    def _IsElfObjectBuiltForAndroid(self, elf, target_path):
+        """Checks whether an ELF object is built for Android.
+
+        Some ELF objects in vendor partition require special program
+        interpreters. Such executable files have .interp sections, but shared
+        libraries don't. As there is no reliable way to identify those
+        libraries. This method checks .note.android.ident section which is
+        created by Android build system.
+
+        Args:
+            elf: The object of elf_parser.ElfParser.
+            target_path: The path to the ELF file on target.
+
+        Returns:
+            A boolean, whether the ELF object is built for Android.
+        """
+        # b/133399940 Skip an ELF file if it does not have .note.android.ident
+        # section and meets one of the following conditions:
+        if elf.HasAndroidIdent():
+            return True
+
+        # It's in the specific directory and is a shared library.
+        if (target_path.startswith("/vendor/arib/lib/") and
+                ".so" in target_path and
+                elf.IsSharedObject()):
+            return False
+
+        # It's in the specific directory, requires special program interpreter,
+        # and is executable.
+        if target_path.startswith("/vendor/arib/bin/"):
+            interp = elf.GetProgramInterpreter()
+            if interp and interp not in self._DEFAULT_PROGRAM_INTERPRETERS:
+                permissions = target_file_utils.GetPermission(target_path,
+                                                              self._dut.shell)
+                if (elf.IsExecutable() or
+                        target_file_utils.IsExecutable(permissions)):
+                    return False
+
+        return True
+
     def _LoadElfObjects(self, host_dir, target_dir, abi_list,
                         elf_error_handler):
         """Scans a host directory recursively and loads all ELF files in it.
@@ -185,7 +224,13 @@
                 continue
             try:
                 if not self._IsElfObjectForAp(elf, target_path, abi_list):
+                    logging.info("%s is not for application processor",
+                                 target_path)
                     continue
+                if not self._IsElfObjectBuiltForAndroid(elf, target_path):
+                    logging.info("%s is not built for Android", target_path)
+                    continue
+
                 deps = elf.ListDependencies()
             except elf_parser.ElfError as e:
                 elf_error_handler(target_path, e)
diff --git a/hidl/bufferpool/V1_0/target/AndroidTest.xml b/hidl/bufferpool/V1_0/target/AndroidTest.xml
index a4d2398..b1c11d0 100644
--- a/hidl/bufferpool/V1_0/target/AndroidTest.xml
+++ b/hidl/bufferpool/V1_0/target/AndroidTest.xml
@@ -14,7 +14,7 @@
      limitations under the License.
 -->
 <configuration description="Config for VTS VtsVndkHidlBufferpoolV1_0Target test cases">
-    <option name="config-descriptor:metadata" key="plan" value="vts-vndk" />
+    <option name="config-descriptor:metadata" key="plan" value="vts-library" />
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
         <option name="abort-on-push-failure" value="false"/>
         <option name="push-group" value="HostDrivenTest.push"/>
diff --git a/hidl/bufferpool/V2_0/target/Android.bp b/hidl/bufferpool/V2_0/target/Android.bp
new file mode 100644
index 0000000..9533bab
--- /dev/null
+++ b/hidl/bufferpool/V2_0/target/Android.bp
@@ -0,0 +1,19 @@
+//
+// Copyright (C) 2018 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.
+//
+
+vts_config {
+    name: "VtsVndkHidlBufferpoolV2_0Target",
+}
diff --git a/hidl/bufferpool/V2_0/target/AndroidTest.xml b/hidl/bufferpool/V2_0/target/AndroidTest.xml
new file mode 100644
index 0000000..d3241e9
--- /dev/null
+++ b/hidl/bufferpool/V2_0/target/AndroidTest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+<configuration description="Config for VTS VtsVndkHidlBufferpoolV2_0Target test cases">
+    <option name="config-descriptor:metadata" key="plan" value="vts-library" />
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+        <option name="abort-on-push-failure" value="false"/>
+        <option name="push-group" value="HostDrivenTest.push"/>
+    </target_preparer>
+    <multi_target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+        <option name="test-module-name" value="VtsVndkHidlBufferpoolV2_0Target"/>
+        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsVndkHidlBufferpoolV2_0TargetSingleTest/VtsVndkHidlBufferpoolV2_0TargetSingleTest"/>
+        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsVndkHidlBufferpoolV2_0TargetSingleTest/VtsVndkHidlBufferpoolV2_0TargetSingleTest"/>
+        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsVndkHidlBufferpoolV2_0TargetMultiTest/VtsVndkHidlBufferpoolV2_0TargetMultiTest"/>
+        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsVndkHidlBufferpoolV2_0TargetMultiTest/VtsVndkHidlBufferpoolV2_0TargetMultiTest"/>
+        <option name="binary-test-type" value="gtest_binary_test"/>
+        <option name="test-timeout" value="1m"/>
+    </test>
+</configuration>