summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsin-Yi Chen <hsinyichen@google.com>2023-12-11 07:21:50 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-12-11 07:21:50 +0000
commit9072defadccb10be0fbc434112e88f2e5aa0fece (patch)
tree9f82dea68383d596624061422228ff98afbeb761
parente3e2a5ab93b77e9369c5da23977a7e0fbe20a5d7 (diff)
parente1e2ae2ed4c5911dcdb6f82469dc633592b92e53 (diff)
downloadvndk-9072defadccb10be0fbc434112e88f2e5aa0fece.tar.gz
Merge "Load LLNDK list from device" into main
-rw-r--r--dependency/vts_vndk_dependency_test.py6
-rw-r--r--files/vts_vndk_files_test.py42
-rw-r--r--utils.py13
3 files changed, 34 insertions, 27 deletions
diff --git a/dependency/vts_vndk_dependency_test.py b/dependency/vts_vndk_dependency_test.py
index e829558..fff1272 100644
--- a/dependency/vts_vndk_dependency_test.py
+++ b/dependency/vts_vndk_dependency_test.py
@@ -116,8 +116,10 @@ class VtsVndkDependencyTest(unittest.TestCase):
sp_hal_strings = vndk_lists[0]
self._sp_hal = [re.compile(x) for x in sp_hal_strings]
- (self._ll_ndk, self._vndk, self._vndk_sp) = vndk_lists[1:]
- if not vndk_utils.IsVndkRequired(self._dut):
+ if vndk_utils.IsVndkRequired(self._dut):
+ (self._ll_ndk, self._vndk, self._vndk_sp) = vndk_lists[1:]
+ else:
+ self._ll_ndk = self._dut.GetLlndkList()
(self._vndk, self._vndk_sp) = ([], [])
logging.debug("LL_NDK: %s", self._ll_ndk)
diff --git a/files/vts_vndk_files_test.py b/files/vts_vndk_files_test.py
index 1563d24..17539e7 100644
--- a/files/vts_vndk_files_test.py
+++ b/files/vts_vndk_files_test.py
@@ -101,28 +101,24 @@ class VtsVndkFilesTest(unittest.TestCase):
"The above libraries are not %s." %
", ".join(vndk_list_names))
- def _TestNotInVndkDirecotory(self, vndk_dir, vndk_list_names, except_libs):
- """Verifies that VNDK directory doesn't contain specific files.
+ def _TestNoLlndkInDirectory(self, lib_dir):
+ """Verifies that the vendor directory doesn't contain LLNDK libraries.
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.
+ lib_dir: The path to the directory on device.
"""
- vndk_lists = vndk_data.LoadVndkLibraryListsFromResources(
- self._vndk_version, *vndk_list_names)
- self.assertTrue(vndk_lists, "Cannot load VNDK library lists.")
- vndk_set = set().union(*vndk_lists)
- vndk_set.difference_update(except_libs)
- logging.debug("vndk set: %s", vndk_set)
- unexpected = [x for x in self._ListFiles(vndk_dir) if
- target_path_module.basename(x) in vndk_set]
+ if vndk_utils.IsVndkRequired(self._dut):
+ llndk_list = vndk_data.LoadVndkLibraryListsFromResources(
+ self._vndk_version, vndk_data.LL_NDK)[0]
+ else:
+ llndk_list = self._dut.GetLlndkList()
+ llndk_set = set(llndk_list).difference(self._LL_NDK_COLLIDING_NAMES)
+ logging.debug("llndk set: %s", llndk_set)
+ unexpected = [x for x in self._ListFiles(lib_dir) if
+ target_path_module.basename(x) in llndk_set]
if unexpected:
self._Fail(unexpected,
- "%s must not contain %s libraries." %
- (vndk_dir, ", ".join(vndk_list_names)))
+ lib_dir + " must not contain LLNDK libraries.")
def _TestVndkCoreDirectory(self, bitness):
"""Verifies that VNDK directory doesn't contain extra files."""
@@ -159,10 +155,8 @@ class VtsVndkFilesTest(unittest.TestCase):
def _TestNoLlndkInVendor(self, bitness):
"""Verifies that vendor partition has no LL-NDK libraries."""
- self._TestNotInVndkDirecotory(
- vndk_utils.FormatVndkPath(self._TARGET_VENDOR_LIB, bitness),
- (vndk_data.LL_NDK,),
- self._LL_NDK_COLLIDING_NAMES)
+ self._TestNoLlndkInDirectory(
+ vndk_utils.FormatVndkPath(self._TARGET_VENDOR_LIB, bitness))
def testNoLlndkInVendor32(self):
"""Runs _TestNoLlndkInVendor for 32-bit libraries."""
@@ -178,10 +172,8 @@ class VtsVndkFilesTest(unittest.TestCase):
def _TestNoLlndkInOdm(self, bitness):
"""Verifies that odm partition has no LL-NDK libraries."""
- self._TestNotInVndkDirecotory(
- vndk_utils.FormatVndkPath(self._TARGET_ODM_LIB, bitness),
- (vndk_data.LL_NDK,),
- self._LL_NDK_COLLIDING_NAMES)
+ self._TestNoLlndkInDirectory(
+ vndk_utils.FormatVndkPath(self._TARGET_ODM_LIB, bitness))
def testNoLlndkInOdm32(self):
"""Runs _TestNoLlndkInOdm for 32-bit libraries."""
diff --git a/utils.py b/utils.py
index 58c4992..36814ab 100644
--- a/utils.py
+++ b/utils.py
@@ -215,6 +215,19 @@ class AndroidDevice(object):
else:
return 64
+ def GetLlndkList(self):
+ """Loads the list of LLNDK library names from the device.
+
+ Returns:
+ A list of strings, the library names including ".so".
+ """
+ out, err, return_code = self.Execute("cat",
+ "/system/etc/llndk.libraries.txt")
+ if err.strip() or return_code != 0:
+ raise IOError("`cat /system/etc/llndk.libraries.txt` "
+ f"stdout: {out}\nstderr: {err}\n")
+ return out.split()
+
def IsRoot(self):
"""Returns whether adb has root privilege on the device."""
out, err, return_code = self.Execute("id")