summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsin-Yi Chen <hsinyichen@google.com>2018-02-12 17:20:44 +0800
committerHsin-Yi Chen <hsinyichen@google.com>2018-02-14 16:25:08 +0800
commit2e4beb14d5b0b17970730110bb352f01e8b49989 (patch)
tree3d8a5a1f493f83f5f99d68f7bce254dffb6ec5f4
parent483afb29482b1c7b4cfc015b74c6cea5799677da (diff)
downloadvndk-2e4beb14d5b0b17970730110bb352f01e8b49989.tar.gz
Add test that ensures odm and vendor don't contain LL-NDK
Bug: 73219016 Test: vts-tradefed run commandAndExit vts -m VtsVndkFiles Change-Id: Ifaafeff8c85be7f3b3a12111c5cde1374403f798
-rw-r--r--files/VtsVndkFilesTest.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/files/VtsVndkFilesTest.py b/files/VtsVndkFilesTest.py
index ab2c8d5..1ed1c7f 100644
--- a/files/VtsVndkFilesTest.py
+++ b/files/VtsVndkFilesTest.py
@@ -23,6 +23,7 @@ from vts.runners.host import keys
from vts.runners.host import test_runner
from vts.testcases.vndk.golden import vndk_data
from vts.utils.python.file import target_file_utils
+from vts.utils.python.os import path_utils
from vts.utils.python.vndk import vndk_utils
@@ -35,6 +36,14 @@ class VtsVndkFilesTest(base_test.BaseTestClass):
_shell: The ShellMirrorObject that executes commands.
_vndk_version: The VNDK version of the device.
"""
+ # Some LL-NDK libraries may load the implementations with the same names
+ # from /vendor/lib. Since a vendor may install an implementation of an
+ # LL-NDK library with the same name, testNoLlndkInVendor doesn't raise
+ # errors on these LL-NDK libraries.
+ _LL_NDK_COLLIDING_NAMES = ("libEGL.so", "libGLESv1_CM.so", "libGLESv2.so",
+ "libGLESv3.so")
+ _TARGET_ODM_LIB = "/odm/{LIB}"
+ _TARGET_VENDOR_LIB = "/vendor/{LIB}"
def setUpClass(self):
"""Initializes the data file path and shell."""
@@ -53,6 +62,9 @@ class VtsVndkFilesTest(base_test.BaseTestClass):
Returns:
A list of strings, the file paths in the directory.
"""
+ if not target_file_utils.Exists(dir_path, self._shell):
+ logging.info("%s not found", dir_path)
+ return []
return target_file_utils.FindFiles(self._shell, dir_path, "*",
"! -type d")
@@ -74,6 +86,30 @@ class VtsVndkFilesTest(base_test.BaseTestClass):
logging.error("Unexpected files:\n%s", "\n".join(unexpected))
asserts.fail("Total number of errors: %d" % len(unexpected))
+ def _TestNotInVndkDirecotory(self, vndk_dir, vndk_list_names, except_libs):
+ """Verifies that VNDK directory doesn't contain specific files.
+
+ Args:
+ vndk_dir, The path to the VNDK directory on device.
+ vndk_list_names: A list of strings, the categories of the VNDK
+ libraries that should not be in the directory.
+ except_libs: A set of strings, the file names of the libraries that
+ are exceptions to this test.
+ """
+ vndk_lists = vndk_data.LoadVndkLibraryLists(
+ self.data_file_path, self._vndk_version, *vndk_list_names)
+ asserts.assertTrue(vndk_lists, "Cannot load VNDK library lists.")
+ vndk_set = set()
+ for vndk_list in vndk_lists:
+ vndk_set.update(path_utils.TargetBaseName(x) for x in vndk_list)
+ vndk_set.difference_update(except_libs)
+ logging.debug("vndk set: %s", vndk_set)
+ unexpected = [x for x in self._ListFiles(vndk_dir) if
+ path_utils.TargetBaseName(x) in vndk_set]
+ if unexpected:
+ logging.error("Unexpected files:\n%s", "\n".join(unexpected))
+ asserts.fail("Total number of errors: %d" % len(unexpected))
+
def testVndkCoreDirectory(self):
"""Verifies that VNDK-core directory doesn't contain extra files."""
asserts.skipIf(not vndk_utils.IsVndkRuntimeEnforced(self._dut),
@@ -92,6 +128,21 @@ class VtsVndkFilesTest(base_test.BaseTestClass):
vndk_data.VNDK_SP_INDIRECT,
vndk_data.VNDK_SP_INDIRECT_PRIVATE)
+ def testNoLlndkInVendor(self):
+ """Verifies that vendor partition has no LL-NDK libraries."""
+ self._TestNotInVndkDirecotory(
+ vndk_utils.FormatVndkPath(
+ self._TARGET_VENDOR_LIB, self.abi_bitness),
+ (vndk_data.LL_NDK,),
+ self._LL_NDK_COLLIDING_NAMES)
+
+ def testNoLlndkInOdm(self):
+ """Verifies that odm partition has no LL-NDK libraries."""
+ self._TestNotInVndkDirecotory(
+ vndk_utils.FormatVndkPath(self._TARGET_ODM_LIB, self.abi_bitness),
+ (vndk_data.LL_NDK,),
+ self._LL_NDK_COLLIDING_NAMES)
+
if __name__ == "__main__":
test_runner.main()