diff options
author | Hsin-Yi Chen <hsinyichen@google.com> | 2020-07-28 13:47:21 +0800 |
---|---|---|
committer | Hsin-Yi Chen <hsinyichen@google.com> | 2020-09-11 12:13:03 +0800 |
commit | c362225e2414ba8f7bc9b4db3ccf9f1433d9fe4a (patch) | |
tree | 2fc54d0f63b582db41f8e4413f77cee18089a590 | |
parent | 0482d26ce841bff62c8bec7524381304b3badda0 (diff) | |
download | vndk-c362225e2414ba8f7bc9b4db3ccf9f1433d9fe4a.tar.gz |
Add searching path for app internal libraries
testElfDependency checks if each executables/libraries dependencies meet
VNDK requirements by searching standard library paths.
However, in case that some modules use a library which depends on
another one located in same directory, it cannot resolve that dependency
and results in failure due to missing needed library.
Bug: 123216664
Test: LD_LIBRARY_PATH=$ANDROID_HOST_OUT/lib64 \
atest vts_vndk_dependency_test
Change-Id: I8ec9261596887ce8fbaa943484729cbd569d17f5
Merged-In: I8ec9261596887ce8fbaa943484729cbd569d17f5
(cherry picked from commit d1cf5ee0d7b873d80e70d6abce05354058062002)
-rw-r--r-- | dependency/vts_vndk_dependency_test.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/dependency/vts_vndk_dependency_test.py b/dependency/vts_vndk_dependency_test.py index fb0431a..3152ad3 100644 --- a/dependency/vts_vndk_dependency_test.py +++ b/dependency/vts_vndk_dependency_test.py @@ -48,6 +48,7 @@ class VtsVndkDependencyTest(unittest.TestCase): _vndk_sp: Set of strings. The names of VNDK-SP libraries. _SP_HAL_LINK_PATHS: Format strings of same-process HAL's link paths. _VENDOR_LINK_PATHS: Format strings of vendor processes' link paths. + _VENDOR_APP_DIRS: The app directories in vendor partitions. """ _TARGET_DIR_SEP = "/" _TARGET_ROOT_DIR = "/" @@ -62,6 +63,9 @@ class VtsVndkDependencyTest(unittest.TestCase): "/odm/{LIB}/hw", "/odm/{LIB}/egl", "/odm/{LIB}", "/vendor/{LIB}/hw", "/vendor/{LIB}/egl", "/vendor/{LIB}" ] + _VENDOR_APP_DIRS = [ + "/vendor/app", "/vendor/priv-app", "/odm/app", "/odm/priv-app" + ] _DEFAULT_PROGRAM_INTERPRETERS = [ "/system/bin/linker", "/system/bin/linker64" ] @@ -77,9 +81,11 @@ class VtsVndkDependencyTest(unittest.TestCase): bitness: Integer. Bitness of the ELF. deps: List of strings. The names of the depended libraries. runpaths: List of strings. The library search paths. + custom_link_paths: List of strings. The library search paths. """ - def __init__(self, target_path, bitness, deps, runpaths): + def __init__(self, target_path, bitness, deps, runpaths, + custom_link_paths): self.target_path = target_path self.name = target_path_module.basename(target_path) self.target_dir = target_path_module.dirname(target_path) @@ -94,6 +100,7 @@ class VtsVndkDependencyTest(unittest.TestCase): path = path.replace("${ORIGIN}", self.target_dir) path = path.replace("$ORIGIN", self.target_dir) self.runpaths.append(path) + self.custom_link_paths = custom_link_paths def setUp(self): """Initializes device, temporary directory, and VNDK lists.""" @@ -259,8 +266,16 @@ class VtsVndkDependencyTest(unittest.TestCase): if runpaths: logging.info("%s has runpaths: %s", target_path, ":".join(runpaths)) + + # b/123216664 App libraries depend on those in the same directory. + custom_link_paths = [] + if any(target_path.startswith(app_dir + self._TARGET_DIR_SEP) for + app_dir in self._VENDOR_APP_DIRS): + custom_link_paths.append( + target_path_module.dirname(target_path)) + objs.append(self.ElfObject(target_path, elf.bitness, deps, - runpaths)) + runpaths, custom_link_paths)) return objs def _FindLibsInLinkPaths(self, bitness, link_paths, objs): @@ -299,7 +314,7 @@ class VtsVndkDependencyTest(unittest.TestCase): return searched.add(lib) for dep_name in lib.deps: - for link_path in lib.runpaths + link_paths: + for link_path in lib.custom_link_paths + lib.runpaths + link_paths: if dep_name in namespace[link_path]: self._DfsDependencies(namespace[link_path][dep_name], searched, namespace, link_paths) @@ -327,7 +342,7 @@ class VtsVndkDependencyTest(unittest.TestCase): if any((dep_name in vndk_list) for vndk_list in vndk_lists): continue if any((dep_name in namespace[link_path]) for link_path in - obj.runpaths + link_paths): + obj.custom_link_paths + obj.runpaths + link_paths): continue disallowed_libs.append(dep_name) @@ -350,8 +365,8 @@ class VtsVndkDependencyTest(unittest.TestCase): vendor_link_paths = [vndk_utils.FormatVndkPath(x, bitness) for x in self._VENDOR_LINK_PATHS] - vendor_namespace = self._FindLibsInLinkPaths(bitness, - vendor_link_paths, objs) + vendor_namespace = self._FindLibsInLinkPaths( + bitness, vendor_link_paths + self._VENDOR_APP_DIRS, objs) # Exclude VNDK and VNDK-SP extensions from vendor libraries. for vndk_ext_dir in (vndk_utils.GetVndkExtDirectories(bitness) + vndk_utils.GetVndkSpExtDirectories(bitness)): |