From 5e1bc0367a8530836fde7cf8fc2c141b1af05ef4 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Tue, 28 Jul 2020 13:47:21 +0800 Subject: 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: run vts -m VtsVndkDependency -t VtsVndkDependency#testElfDependency Change-Id: I73d102ce61d723d80919fd0ca8c29585afb371a0 --- dependency/VtsVndkDependencyTest.py | 43 +++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/dependency/VtsVndkDependencyTest.py b/dependency/VtsVndkDependencyTest.py index 0302220..28e87c9 100644 --- a/dependency/VtsVndkDependencyTest.py +++ b/dependency/VtsVndkDependencyTest.py @@ -52,6 +52,7 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): /system/lib[64]/vndk-sp-${VER}. _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_ROOT_DIR = "/" _TARGET_ODM_DIR = "/odm" @@ -65,6 +66,9 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): "/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" ] @@ -290,9 +294,10 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): Args: objs: A collection of ElfObject, the libraries/executables. - is_allowed_dependency: A function that takes the library name as the - argument and returns whether objs can depend - on the library. + is_allowed_dependency: A function that takes a library name and an + ElfObject as the arguments, and returns + whether the object can depend on the + library. Returns: List of tuples (path, disallowed_dependencies). The library with @@ -301,7 +306,7 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): dep_errors = [] for obj in objs: disallowed_libs = [ - x for x in obj.deps if not is_allowed_dependency(x)] + x for x in obj.deps if not is_allowed_dependency(x, obj)] if disallowed_libs: dep_errors.append((obj.target_path, disallowed_libs)) return dep_errors @@ -326,10 +331,20 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): List of tuples (path, disallowed_dependencies). """ vendor_lib_names = set(x.name for x in vendor_libs) - is_allowed_dep = lambda x: (x in self._ll_ndk or - x in self._vndk or - x in self._vndk_sp or - x in vendor_lib_names) + # b/123216664 App libraries depend on those in the same directory. + vendor_app_lib_names = {} + for obj in vendor_objs: + if any(obj.target_dir.startswith(app_dir + "/") for app_dir in + self._VENDOR_APP_DIRS): + vendor_app_lib_names.setdefault( + obj.target_dir, set()).add(obj.name) + + is_allowed_dep = lambda name, obj: ( + name in self._ll_ndk or + name in self._vndk or + name in self._vndk_sp or + name in vendor_lib_names or + name in vendor_app_lib_names.get(obj.target_dir, ())) return self._FilterDisallowedDependencies(vendor_objs, is_allowed_dep) def _TestVndkSpExtDependency(self, vndk_sp_ext_deps, vendor_libs): @@ -353,9 +368,9 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): List of tuples (path, disallowed_dependencies). """ vendor_lib_names = set(x.name for x in vendor_libs) - is_allowed_dep = lambda x: (x in self._ll_ndk or - x in self._vndk_sp or - x in vendor_lib_names) + is_allowed_dep = lambda x, obj: (x in self._ll_ndk or + x in self._vndk_sp or + x in vendor_lib_names) return self._FilterDisallowedDependencies( vndk_sp_ext_deps, is_allowed_dep) @@ -375,9 +390,9 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): List of tuples (path, disallowed_dependencies). """ sp_hal_lib_names = set(x.name for x in sp_hal_libs) - is_allowed_dep = lambda x: (x in self._ll_ndk or - x in self._vndk_sp or - x in sp_hal_lib_names) + is_allowed_dep = lambda x, obj: (x in self._ll_ndk or + x in self._vndk_sp or + x in sp_hal_lib_names) return self._FilterDisallowedDependencies(sp_hal_libs, is_allowed_dep) def _TestElfDependency(self, bitness, objs): -- cgit v1.2.3 From 6ffac6996080d50f5fbfad80e7d6eda2d8834099 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Fri, 18 Sep 2020 10:12:13 +0800 Subject: Show debug logs for vts-vndk Test: LD_LIBRARY_PATH=$ANDROID_HOST_OUT/lib64 atest vts_vndk_dependency_test Bug: 168728771 Change-Id: Ia7f3c0efbd7465198615d82ed102e9b8d4a0a209 --- abi/vts_vndk_abi_test.py | 2 +- dependency/vts_vndk_dependency_test.py | 2 +- files/vts_vndk_files_test.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/abi/vts_vndk_abi_test.py b/abi/vts_vndk_abi_test.py index a14c9bb..140c1c4 100644 --- a/abi/vts_vndk_abi_test.py +++ b/abi/vts_vndk_abi_test.py @@ -361,7 +361,7 @@ class VtsVndkAbiTest(unittest.TestCase): if __name__ == "__main__": # The logs are written to stdout so that TradeFed test runner can parse the # results from stderr. - logging.basicConfig(stream=sys.stdout) + logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) # Setting verbosity is required to generate output that the TradeFed test # runner can parse. unittest.main(verbosity=3) diff --git a/dependency/vts_vndk_dependency_test.py b/dependency/vts_vndk_dependency_test.py index 3152ad3..228a373 100644 --- a/dependency/vts_vndk_dependency_test.py +++ b/dependency/vts_vndk_dependency_test.py @@ -479,7 +479,7 @@ class VtsVndkDependencyTest(unittest.TestCase): if __name__ == "__main__": # The logs are written to stdout so that TradeFed test runner can parse the # results from stderr. - logging.basicConfig(stream=sys.stdout) + logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) # Setting verbosity is required to generate output that the TradeFed test # runner can parse. unittest.main(verbosity=3) diff --git a/files/vts_vndk_files_test.py b/files/vts_vndk_files_test.py index 51da520..017ae9c 100644 --- a/files/vts_vndk_files_test.py +++ b/files/vts_vndk_files_test.py @@ -183,7 +183,7 @@ class VtsVndkFilesTest(unittest.TestCase): if __name__ == "__main__": # The logs are written to stdout so that TradeFed test runner can parse the # results from stderr. - logging.basicConfig(stream=sys.stdout) + logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) # Setting verbosity is required to generate output that the TradeFed test # runner can parse. unittest.main(verbosity=3) -- cgit v1.2.3 From 8522b76f55becef3a0f843e8e762331ed72f93fb Mon Sep 17 00:00:00 2001 From: Snild Dolkow Date: Wed, 23 Sep 2020 10:34:03 +0200 Subject: Disable compression in AdbPull() Compression makes adb pull slower, enough to make the /vendor pull in vts_vndk_dependency_test time out on some devices. Commit I9ed6f37bc55b1d55ae7c0c29a70a0e79b91ff683 updates the default for adb pull, but VTS may run with an older version. Setting the ADB_COMPRESSION environment variable to 0 will disable compression for all versions supporting it, and does no harm otherwise. This change takes vts_vndk_dependency_test from 396 to 181 seconds on my device, allowing it to finish within the 6-minute deadline. Change-Id: Ic0a5e5e5ac07a78f593619487c66376ab1a417df (cherry picked from commit cfcccf314d6ebd2d641205684ad4c69cba741789) --- utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index c6e13c2..08bd58f 100644 --- a/utils.py +++ b/utils.py @@ -32,7 +32,10 @@ class AndroidDevice(object): def AdbPull(self, src, dst): cmd = ["adb", "-s", self._serial_number, "pull", src, dst] - subprocess.check_call(cmd, shell=False, stdin=subprocess.PIPE, + env = os.environ.copy() + if "ADB_COMPRESSION" not in env: + env["ADB_COMPRESSION"] = "0" + subprocess.check_call(cmd, shell=False, env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) def Execute(self, *args): -- cgit v1.2.3 From af63b762c541c2803420d45a439473da3cead1e5 Mon Sep 17 00:00:00 2001 From: Salini Venate Date: Sun, 11 Apr 2021 16:18:19 +0530 Subject: Correct dump_path for x86 vndk libraries Correct the reference lsdump path for 1) 64 bit binaries running on 64 bit machine to x86_64 2) 32 bit binaries running in 64 bit machine to x86_x86_64. Bug ID: 183998268 Signed-off-by: Salini Venate Test: run vts -m vts_vndk_abi_test Change-Id: I5a9d5d6e02dcf33789e177af9fdda62416d35fcf (cherry picked from commit ccc18234e932f72cc1eeccca59a76db2f9dd4824) --- golden/vndk_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/golden/vndk_data.py b/golden/vndk_data.py index 5e971aa..56ed5d4 100644 --- a/golden/vndk_data.py +++ b/golden/vndk_data.py @@ -52,8 +52,8 @@ _ABI_LIST = ( ("arm64", 64, "arm64_armv8-a"), ("arm64", 32, "arm_armv8-a"), ("arm", 32, "arm_armv7-a-neon"), - ("x86_64", 64, "x86_x86_64"), - ("x86_64", 32, "x86_64"), + ("x86_64", 64, "x86_64"), + ("x86_64", 32, "x86_x86_64"), ("x86", 32, "x86"), ) -- cgit v1.2.3 From c58fb038ab06da78a1e0827e9413e20cfdccc6c2 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Mon, 18 Nov 2019 11:05:40 +0800 Subject: Search runpaths for ELF dependencies This commit extends VtsVndkDependency to load runpaths from ELF. If an ELF object has runpaths under the permitted link paths, the linker searches the runpaths and the default paths for dependencies. Test: vts-tradefed run vts -m VtsVndkDependency -a arm64-v8a Bug: 144316411 Bug: 185363536 Change-Id: Ib25399267e8eb3ee2b3d3c016560ce7554a83182 Merged-In: Ib25399267e8eb3ee2b3d3c016560ce7554a83182 (cherry picked from commit 7b2cdca6e74ff5ec21a159a7af551300bff5548f) --- dependency/VtsVndkDependencyTest.py | 278 +++++++++++++++++------------------- 1 file changed, 131 insertions(+), 147 deletions(-) diff --git a/dependency/VtsVndkDependencyTest.py b/dependency/VtsVndkDependencyTest.py index 28e87c9..47b4e64 100644 --- a/dependency/VtsVndkDependencyTest.py +++ b/dependency/VtsVndkDependencyTest.py @@ -15,8 +15,10 @@ # limitations under the License. # +import collections import logging import os +import posixpath as target_path_module import re import shutil import tempfile @@ -54,6 +56,7 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): _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 = "/" _TARGET_ODM_DIR = "/odm" _TARGET_VENDOR_DIR = "/vendor" @@ -82,14 +85,27 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): target_dir: String. The directory containing the ELF file on target. 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): + def __init__(self, target_path, bitness, deps, runpaths, + custom_link_paths): self.target_path = target_path self.name = path_utils.TargetBaseName(target_path) self.target_dir = path_utils.TargetDirName(target_path) self.bitness = bitness self.deps = deps + # Format runpaths + self.runpaths = [] + lib_dir_name = "lib64" if bitness == 64 else "lib" + for runpath in runpaths: + path = runpath.replace("${LIB}", lib_dir_name) + path = path.replace("$LIB", lib_dir_name) + 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 setUpClass(self): """Initializes device, temporary directory, and VNDK lists.""" @@ -235,7 +251,7 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): logging.info("%s is not built for Android", target_path) continue - deps = elf.ListDependencies() + deps, runpaths = elf.ListDependencies() except elf_parser.ElfError as e: elf_error_handler(target_path, e) continue @@ -243,158 +259,93 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): elf.Close() logging.info("%s depends on: %s", target_path, ", ".join(deps)) - objs.append(self.ElfObject(target_path, elf.bitness, deps)) + 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, custom_link_paths)) return objs - def _DfsDependencies(self, lib, searched, searchable): + def _FindLibsInLinkPaths(self, bitness, link_paths, objs): + """Finds libraries in link paths. + + Args: + bitness: 32 or 64, the bitness of the returned libraries. + link_paths: List of strings, the default link paths. + objs: List of ElfObject, the libraries/executables to be filtered + by bitness and path. + + Returns: + A defaultdict, {dir: {name: obj}} where obj is an ElfObject, dir + is obj.target_dir, and name is obj.name. + """ + namespace = collections.defaultdict(dict) + for obj in objs: + if (obj.bitness == bitness and + any(obj.target_path.startswith(link_path + + self._TARGET_DIR_SEP) + for link_path in link_paths)): + namespace[obj.target_dir][obj.name] = obj + return namespace + + def _DfsDependencies(self, lib, searched, namespace, link_paths): """Depth-first-search for library dependencies. Args: - lib: ElfObject. The library to search dependencies. + lib: ElfObject, the library to search for dependencies. searched: The set of searched libraries. - searchable: The dictionary that maps file names to libraries. + namespace: Defaultdict, {dir: {name: obj}} containing all + searchable libraries. + link_paths: List of strings, the default link paths. """ if lib in searched: return searched.add(lib) for dep_name in lib.deps: - if dep_name in searchable: - self._DfsDependencies(searchable[dep_name], searched, - searchable) + 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) + break - def _FindLibsInSpHalNamespace(self, bitness, objs): - """Finds libraries in SP-HAL link paths. + def _FindDisallowedDependencies(self, objs, namespace, link_paths, + *vndk_lists): + """Tests if libraries/executables have disallowed dependencies. Args: - bitness: 32 or 64, the bitness of the returned libraries. - objs: List of ElfObject, the libraries/executables in odm and - vendor partitions. + objs: Collection of ElfObject, the libraries/executables under + test. + namespace: Defaultdict, {dir: {name: obj}} containing all libraries + in the linker namespace. + link_paths: List of strings, the default link paths. + vndk_lists: Collections of library names in VNDK, VNDK-SP, etc. Returns: - Dict of {string: ElfObject}, the library name and the first library - in SP-HAL link paths. - """ - sp_hal_link_paths = [vndk_utils.FormatVndkPath(x, bitness) for - x in self._SP_HAL_LINK_PATHS] - vendor_libs = [obj for obj in objs if - obj.bitness == bitness and - obj.target_dir in sp_hal_link_paths] - linkable_libs = dict() - for obj in vendor_libs: - if obj.name not in linkable_libs: - linkable_libs[obj.name] = obj - else: - linkable_libs[obj.name] = min( - linkable_libs[obj.name], obj, - key=lambda x: sp_hal_link_paths.index(x.target_dir)) - return linkable_libs - - def _FilterDisallowedDependencies(self, objs, is_allowed_dependency): - """Returns libraries with disallowed dependencies. - - Args: - objs: A collection of ElfObject, the libraries/executables. - is_allowed_dependency: A function that takes a library name and an - ElfObject as the arguments, and returns - whether the object can depend on the - library. - - Returns: - List of tuples (path, disallowed_dependencies). The library with - disallowed dependencies and list of the dependencies. + List of tuples (path, disallowed_dependencies). """ dep_errors = [] for obj in objs: - disallowed_libs = [ - x for x in obj.deps if not is_allowed_dependency(x, obj)] + disallowed_libs = [] + for dep_name in obj.deps: + 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.custom_link_paths + obj.runpaths + link_paths): + continue + disallowed_libs.append(dep_name) + if disallowed_libs: dep_errors.append((obj.target_path, disallowed_libs)) return dep_errors - def _TestVendorDependency(self, vendor_objs, vendor_libs): - """Tests if vendor libraries/executables have disallowed dependencies. - - A vendor library/executable is allowed to depend on - - LL-NDK - - VNDK - - VNDK-SP - - Other libraries in vendor link paths. - - Args: - vendor_objs: Collection of ElfObject, the libraries/executables in - odm and vendor partitions, excluding VNDK-SP extension - and SP-HAL. - vendor_libs: Set of ElfObject, the libraries in vendor link paths, - including SP-HAL. - - Returns: - List of tuples (path, disallowed_dependencies). - """ - vendor_lib_names = set(x.name for x in vendor_libs) - # b/123216664 App libraries depend on those in the same directory. - vendor_app_lib_names = {} - for obj in vendor_objs: - if any(obj.target_dir.startswith(app_dir + "/") for app_dir in - self._VENDOR_APP_DIRS): - vendor_app_lib_names.setdefault( - obj.target_dir, set()).add(obj.name) - - is_allowed_dep = lambda name, obj: ( - name in self._ll_ndk or - name in self._vndk or - name in self._vndk_sp or - name in vendor_lib_names or - name in vendor_app_lib_names.get(obj.target_dir, ())) - return self._FilterDisallowedDependencies(vendor_objs, is_allowed_dep) - - def _TestVndkSpExtDependency(self, vndk_sp_ext_deps, vendor_libs): - """Tests if VNDK-SP extension libraries have disallowed dependencies. - - A VNDK-SP extension library/dependency is allowed to depend on - - LL-NDK - - VNDK-SP - - Libraries in vendor link paths - - Other VNDK-SP extension libraries, which is a subset of VNDK-SP - - However, it is not allowed to indirectly depend on VNDK. i.e., the - depended vendor libraries must not depend on VNDK. - - Args: - vndk_sp_ext_deps: Collection of ElfObject, the VNDK-SP extension - libraries and dependencies. - vendor_libs: Set of ElfObject, the libraries in vendor link paths. - - Returns: - List of tuples (path, disallowed_dependencies). - """ - vendor_lib_names = set(x.name for x in vendor_libs) - is_allowed_dep = lambda x, obj: (x in self._ll_ndk or - x in self._vndk_sp or - x in vendor_lib_names) - return self._FilterDisallowedDependencies( - vndk_sp_ext_deps, is_allowed_dep) - - def _TestSpHalDependency(self, sp_hal_libs): - """Tests if SP-HAL libraries have disallowed dependencies. - - A same-process HAL library is allowed to depend on - - LL-NDK - - VNDK-SP - - Other same-process HAL libraries and dependencies - - Args: - sp_hal_libs: Set of ElfObject, the Same-process HAL libraries and - the dependencies. - - Returns: - List of tuples (path, disallowed_dependencies). - """ - sp_hal_lib_names = set(x.name for x in sp_hal_libs) - is_allowed_dep = lambda x, obj: (x in self._ll_ndk or - x in self._vndk_sp or - x in sp_hal_lib_names) - return self._FilterDisallowedDependencies(sp_hal_libs, is_allowed_dep) - def _TestElfDependency(self, bitness, objs): """Tests vendor libraries/executables and SP-HAL dependencies. @@ -407,22 +358,31 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): List of tuples (path, disallowed_dependencies). """ vndk_sp_ext_dirs = vndk_utils.GetVndkSpExtDirectories(bitness) + vendor_link_paths = [vndk_utils.FormatVndkPath(x, bitness) for x in self._VENDOR_LINK_PATHS] + 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)): + vendor_namespace.pop(vndk_ext_dir, None) + logging.info("%d-bit odm, vendor, and SP-HAL libraries:", bitness) + for dir_path, libs in vendor_namespace.iteritems(): + logging.info("%s: %s", dir_path, ",".join(libs.iterkeys())) - vendor_libs = set(obj for obj in objs if - obj.bitness == bitness and - obj.target_dir in vendor_link_paths) - logging.info("%d-bit odm and vendor libraries including SP-HAL: %s", - bitness, ", ".join(x.name for x in vendor_libs)) - - sp_hal_namespace = self._FindLibsInSpHalNamespace(bitness, objs) + sp_hal_link_paths = [vndk_utils.FormatVndkPath(x, bitness) for + x in self._SP_HAL_LINK_PATHS] + sp_hal_namespace = self._FindLibsInLinkPaths(bitness, + sp_hal_link_paths, objs) # Find same-process HAL and dependencies sp_hal_libs = set() - for obj in sp_hal_namespace.itervalues(): - if any(x.match(obj.target_path) for x in self._sp_hal): - self._DfsDependencies(obj, sp_hal_libs, sp_hal_namespace) + for link_path in sp_hal_link_paths: + for obj in sp_hal_namespace[link_path].itervalues(): + if any(x.match(obj.target_path) for x in self._sp_hal): + self._DfsDependencies(obj, sp_hal_libs, sp_hal_namespace, + sp_hal_link_paths) logging.info("%d-bit SP-HAL libraries: %s", bitness, ", ".join(x.name for x in sp_hal_libs)) @@ -432,26 +392,50 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): obj.target_dir in vndk_sp_ext_dirs) vndk_sp_ext_deps = set() for lib in vndk_sp_ext_libs: - self._DfsDependencies(lib, vndk_sp_ext_deps, sp_hal_namespace) + self._DfsDependencies(lib, vndk_sp_ext_deps, sp_hal_namespace, + sp_hal_link_paths) logging.info("%d-bit VNDK-SP extension libraries and dependencies: %s", bitness, ", ".join(x.name for x in vndk_sp_ext_deps)) + # A vendor library/executable is allowed to depend on + # LL-NDK + # VNDK + # VNDK-SP + # Other libraries in vendor link paths vendor_objs = {obj for obj in objs if obj.bitness == bitness and obj not in sp_hal_libs and obj not in vndk_sp_ext_deps} - dep_errors = self._TestVendorDependency(vendor_objs, vendor_libs) - + dep_errors = self._FindDisallowedDependencies( + vendor_objs, vendor_namespace, vendor_link_paths, + self._ll_ndk, self._vndk, self._vndk_sp) + + # A VNDK-SP extension library/dependency is allowed to depend on + # LL-NDK + # VNDK-SP + # Libraries in vendor link paths + # Other VNDK-SP extension libraries, which is a subset of VNDK-SP + # + # However, it is not allowed to indirectly depend on VNDK. i.e., the + # depended vendor libraries must not depend on VNDK. + # # vndk_sp_ext_deps and sp_hal_libs may overlap. Their dependency # restrictions are the same. - dep_errors.extend(self._TestVndkSpExtDependency( - vndk_sp_ext_deps - sp_hal_libs, vendor_libs)) + dep_errors.extend(self._FindDisallowedDependencies( + vndk_sp_ext_deps - sp_hal_libs, vendor_namespace, + vendor_link_paths, self._ll_ndk, self._vndk_sp)) if not vndk_utils.IsVndkRuntimeEnforced(self._dut): logging.warning("Ignore dependency errors: %s", dep_errors) dep_errors = [] - dep_errors.extend(self._TestSpHalDependency(sp_hal_libs)) + # A same-process HAL library is allowed to depend on + # LL-NDK + # VNDK-SP + # Other same-process HAL libraries and dependencies + dep_errors.extend(self._FindDisallowedDependencies( + sp_hal_libs, sp_hal_namespace, sp_hal_link_paths, + self._ll_ndk, self._vndk_sp)) return dep_errors def testElfDependency(self): -- cgit v1.2.3 From a33274db2922f007fd1278272ca20a31e0a828ec Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Fri, 11 Jun 2021 10:26:18 +0800 Subject: Allow dependencies on non-default link paths The dependency test differentiates default link paths and permitted paths. Vendor objects may depend on libraries in non-default link paths. The test allows the dependencies if the objects have RUNPATHs in vendor or odm partition. Test: vts-tradefed run vts -m VtsVndkDependency Bug: 185363536 Change-Id: I3383ebfb5321290245ac8ba2d05a59df881b9c64 --- dependency/VtsVndkDependencyTest.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dependency/VtsVndkDependencyTest.py b/dependency/VtsVndkDependencyTest.py index 47b4e64..5c214ba 100644 --- a/dependency/VtsVndkDependencyTest.py +++ b/dependency/VtsVndkDependencyTest.py @@ -52,8 +52,12 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): /system/lib[64]/vndk-${VER}. _vndk_sp: Set of strings. The names of VNDK-SP libraries in /system/lib[64]/vndk-sp-${VER}. - _SP_HAL_LINK_PATHS: Format strings of same-process HAL's link paths. - _VENDOR_LINK_PATHS: Format strings of vendor processes' link paths. + _SP_HAL_LINK_PATHS: Format strings of same-process HAL's default link + paths. + _VENDOR_LINK_PATHS: Format strings of vendor processes' default link + paths. + _VENDOR_PERMITTED_PATHS: Same-process HAL and vendor processes' + permitted link paths. _VENDOR_APP_DIRS: The app directories in vendor partitions. """ _TARGET_DIR_SEP = "/" @@ -69,6 +73,9 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): "/odm/{LIB}/hw", "/odm/{LIB}/egl", "/odm/{LIB}", "/vendor/{LIB}/hw", "/vendor/{LIB}/egl", "/vendor/{LIB}" ] + _VENDOR_PERMITTED_PATHS = [ + "/odm", "/vendor" + ] _VENDOR_APP_DIRS = [ "/vendor/app", "/vendor/priv-app", "/odm/app", "/odm/priv-app" ] @@ -362,7 +369,7 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): vendor_link_paths = [vndk_utils.FormatVndkPath(x, bitness) for x in self._VENDOR_LINK_PATHS] vendor_namespace = self._FindLibsInLinkPaths( - bitness, vendor_link_paths + self._VENDOR_APP_DIRS, objs) + bitness, self._VENDOR_PERMITTED_PATHS, objs) # Exclude VNDK and VNDK-SP extensions from vendor libraries. for vndk_ext_dir in (vndk_utils.GetVndkExtDirectories(bitness) + vndk_utils.GetVndkSpExtDirectories(bitness)): @@ -373,8 +380,8 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): sp_hal_link_paths = [vndk_utils.FormatVndkPath(x, bitness) for x in self._SP_HAL_LINK_PATHS] - sp_hal_namespace = self._FindLibsInLinkPaths(bitness, - sp_hal_link_paths, objs) + sp_hal_namespace = self._FindLibsInLinkPaths( + bitness, self._VENDOR_PERMITTED_PATHS, objs) # Find same-process HAL and dependencies sp_hal_libs = set() -- cgit v1.2.3 From e91eff43317df69d1f1f23fa240c1e96905635a3 Mon Sep 17 00:00:00 2001 From: qianyou Date: Thu, 12 Aug 2021 10:16:40 +0800 Subject: fix no test results caused by timeout In our project, running command vts_vndk_dependency_test takes about 7 minutes. The timeout of this case was set to 6 minutes, which caused the process execution to be cancelled, and finally there is no test result. So we should increase the test-timeout to 10 minutes. Bug:196522394 Test:run vts -m vts_vndk_dependency_test Signed-off-by: qianyou Change-Id: Ibc3b6268f1bd2ca79b5f43a8d7820a700b6e90b3 --- dependency/vts_vndk_dependency_test.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependency/vts_vndk_dependency_test.xml b/dependency/vts_vndk_dependency_test.xml index f0f37c7..0a15678 100644 --- a/dependency/vts_vndk_dependency_test.xml +++ b/dependency/vts_vndk_dependency_test.xml @@ -17,7 +17,7 @@ -- cgit v1.2.3