diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-03 00:03:27 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-03 00:03:27 +0000 |
commit | 25563d5c1a11fbdde5fba0abadb2ef4da7901aea (patch) | |
tree | b105ac049a6618cbf1d702808e7acfb85032c62b | |
parent | b4a8d934138942b33e3b3978cf84830608058038 (diff) | |
parent | b91bec28703b345093880c4f117eddc2eb943af5 (diff) | |
download | vndk-simpleperf-release.tar.gz |
Snap for 11400057 from b91bec28703b345093880c4f117eddc2eb943af5 to simpleperf-releasesimpleperf-release
Change-Id: I1886bada255c1663338eeb08f0f07687d8c0094a
-rw-r--r-- | abi/vts_vndk_abi_test.py | 23 | ||||
-rw-r--r-- | dependency/vts_vndk_dependency_test.py | 40 | ||||
-rw-r--r-- | files/vts_vndk_files_test.py | 76 | ||||
-rw-r--r-- | golden/vndk_data.py | 48 | ||||
-rw-r--r-- | utils.py | 13 |
5 files changed, 126 insertions, 74 deletions
diff --git a/abi/vts_vndk_abi_test.py b/abi/vts_vndk_abi_test.py index a8633bf..b085dfb 100644 --- a/abi/vts_vndk_abi_test.py +++ b/abi/vts_vndk_abi_test.py @@ -307,6 +307,10 @@ class VtsVndkAbiTest(unittest.TestCase): Args: bitness: 32 or 64, the bitness of the tested libraries. """ + if not self._dut.GetCpuAbiList(bitness): + logging.info("Skip the test as the device doesn't support %d-bit " + "ABI.", bitness) + return if not vndk_utils.IsVndkRequired(self._dut): logging.info("Skip the test as the device does not require VNDK.") return @@ -317,14 +321,11 @@ class VtsVndkAbiTest(unittest.TestCase): dump_version = self._dut.GetVndkVersion() self.assertTrue(dump_version, "Cannot determine VNDK version.") - # VNDK 35 will not be frozen. - try: - if int(dump_version) > 34: - logging.info("Skip the test. version: %s ABI: %s bitness: %d", - dump_version, primary_abi, bitness) - return - except ValueError: - pass + if vndk_utils.IsVndkInstalledInVendor(self._dut): + logging.info("Skip the test as VNDK should be installed in vendor " + "partition. version: %s ABI: %s bitness: %d", + dump_version, primary_abi, bitness) + return dump_paths = vndk_data.GetAbiDumpPathsFromResources( dump_version, @@ -363,11 +364,7 @@ class VtsVndkAbiTest(unittest.TestCase): def testAbiCompatibility64(self): """Checks ABI compliance of 64-bit VNDK libraries.""" - if self._dut.GetCpuAbiList(64): - self._TestAbiCompatibility(64) - else: - logging.info("Skip the test as the device doesn't support 64-bit " - "ABI.") + self._TestAbiCompatibility(64) if __name__ == "__main__": diff --git a/dependency/vts_vndk_dependency_test.py b/dependency/vts_vndk_dependency_test.py index e829558..7abe2d7 100644 --- a/dependency/vts_vndk_dependency_test.py +++ b/dependency/vts_vndk_dependency_test.py @@ -33,6 +33,7 @@ class VtsVndkDependencyTest(unittest.TestCase): Attributes: _dut: The AndroidDevice under test. + _vndk_version: The VNDK version of the device. _ll_ndk: Set of strings. The names of low-level NDK libraries in /system/lib[64]. _sp_hal: List of patterns. The names of the same-process HAL libraries @@ -106,8 +107,9 @@ class VtsVndkDependencyTest(unittest.TestCase): self._dut = utils.AndroidDevice() self.assertTrue(self._dut.IsRoot(), "This test requires adb root.") + self._vndk_version = self._dut.GetVndkVersion() vndk_lists = vndk_data.LoadVndkLibraryListsFromResources( - self._dut.GetVndkVersion(), + self._vndk_version, vndk_data.SP_HAL, vndk_data.LL_NDK, vndk_data.VNDK, @@ -116,8 +118,14 @@ 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 = vndk_lists[1] + if vndk_utils.IsVndkInstalledInVendor(self._dut): + (self._vndk, self._vndk_sp) = ([], []) + else: + (self._vndk, self._vndk_sp) = vndk_lists[2:] + else: + self._ll_ndk = self._dut.GetLlndkList() (self._vndk, self._vndk_sp) = ([], []) logging.debug("LL_NDK: %s", self._ll_ndk) @@ -233,9 +241,8 @@ class VtsVndkDependencyTest(unittest.TestCase): target_path) continue if not self._IsElfObjectBuiltForAndroid(elf, target_path): - logging.warning("%s is not built for Android, which is no " - "longer exempted.", target_path) - + logging.warning("%s is not built for Android", target_path) + continue deps, runpaths = elf.ListDependencies() except elf_parser.ElfError as e: elf_error_handler(target_path, e) @@ -359,6 +366,17 @@ class VtsVndkDependencyTest(unittest.TestCase): sp_hal_namespace = self._FindLibsInLinkPaths( bitness, self._VENDOR_PERMITTED_PATHS, objs) + if vndk_utils.IsVndkInstalledInVendor(self._dut): + vndk_in_vendor = [ + os.path.basename(lib_path) for lib_path in + self._dut.FindFiles( + vndk_utils.GetVndkDirectory(bitness, self._vndk_version), + "*", "!", "-type", "d")] + logging.info("%d-bit VNDK libraries installed in vendor: %s", + bitness, vndk_in_vendor) + else: + vndk_in_vendor = [] + # Find same-process HAL and dependencies sp_hal_libs = set() for link_path in sp_hal_link_paths: @@ -391,7 +409,7 @@ class VtsVndkDependencyTest(unittest.TestCase): obj not in vndk_sp_ext_deps} dep_errors = self._FindDisallowedDependencies( vendor_objs, vendor_namespace, vendor_link_paths, - self._ll_ndk, self._vndk, self._vndk_sp) + self._ll_ndk, self._vndk, self._vndk_sp, vndk_in_vendor) # A VNDK-SP extension library/dependency is allowed to depend on # LL-NDK @@ -406,7 +424,7 @@ class VtsVndkDependencyTest(unittest.TestCase): # restrictions are the same. dep_errors.extend(self._FindDisallowedDependencies( vndk_sp_ext_deps - sp_hal_libs, vendor_namespace, - vendor_link_paths, self._ll_ndk, self._vndk_sp)) + vendor_link_paths, self._ll_ndk, self._vndk_sp, vndk_in_vendor)) if not vndk_utils.IsVndkRuntimeEnforced(self._dut): logging.warning("Ignore dependency errors: %s", dep_errors) @@ -418,7 +436,7 @@ class VtsVndkDependencyTest(unittest.TestCase): # 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)) + self._ll_ndk, self._vndk_sp, vndk_in_vendor)) return dep_errors def testElfDependency(self): @@ -431,7 +449,9 @@ class VtsVndkDependencyTest(unittest.TestCase): target_dir, abi_list, lambda p, e: read_errors.append((p, str(e)))) - dep_errors = self._TestElfDependency(32, objs) + dep_errors = [] + if self._dut.GetCpuAbiList(32): + dep_errors.extend(self._TestElfDependency(32, objs)) if self._dut.GetCpuAbiList(64): dep_errors.extend(self._TestElfDependency(64, objs)) diff --git a/files/vts_vndk_files_test.py b/files/vts_vndk_files_test.py index 777cd94..f9c76cd 100644 --- a/files/vts_vndk_files_test.py +++ b/files/vts_vndk_files_test.py @@ -101,31 +101,31 @@ 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.""" + if not self._dut.GetCpuAbiList(bitness): + logging.info("Skip the test as the device doesn't support %d-bit " + "ABI.", bitness) + return if not vndk_utils.IsVndkRuntimeEnforced(self._dut): logging.info("Skip the test as VNDK runtime is not enforced on " "the device.") @@ -133,6 +133,10 @@ class VtsVndkFilesTest(unittest.TestCase): if not vndk_utils.IsVndkRequired(self._dut): logging.info("Skip the test as the device does not require VNDK.") return + if vndk_utils.IsVndkInstalledInVendor(self._dut): + logging.info("Skip the test as VNDK %s should be installed in " + "vendor partition.", self._vndk_version) + return self._TestVndkDirectory( vndk_utils.GetVndkDirectory(bitness, self._vndk_version), (vndk_data.VNDK, vndk_data.VNDK_PRIVATE, vndk_data.VNDK_SP, @@ -144,18 +148,16 @@ class VtsVndkFilesTest(unittest.TestCase): def testVndkCoreDirectory64(self): """Runs _TestVndkCoreDirectory for 64-bit libraries.""" - if self._dut.GetCpuAbiList(64): - self._TestVndkCoreDirectory(64) - else: - logging.info("Skip the test as the device doesn't support 64-bit " - "ABI.") + self._TestVndkCoreDirectory(64) 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) + if not self._dut.GetCpuAbiList(bitness): + logging.info("Skip the test as the device doesn't support %d-bit " + "ABI.", bitness) + return + self._TestNoLlndkInDirectory( + vndk_utils.FormatVndkPath(self._TARGET_VENDOR_LIB, bitness)) def testNoLlndkInVendor32(self): """Runs _TestNoLlndkInVendor for 32-bit libraries.""" @@ -163,18 +165,16 @@ class VtsVndkFilesTest(unittest.TestCase): def testNoLlndkInVendor64(self): """Runs _TestNoLlndkInVendor for 64-bit libraries.""" - if self._dut.GetCpuAbiList(64): - self._TestNoLlndkInVendor(64) - else: - logging.info("Skip the test as the device doesn't support 64-bit " - "ABI.") + self._TestNoLlndkInVendor(64) 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) + if not self._dut.GetCpuAbiList(bitness): + logging.info("Skip the test as the device doesn't support %d-bit " + "ABI.", bitness) + return + self._TestNoLlndkInDirectory( + vndk_utils.FormatVndkPath(self._TARGET_ODM_LIB, bitness)) def testNoLlndkInOdm32(self): """Runs _TestNoLlndkInOdm for 32-bit libraries.""" @@ -182,11 +182,7 @@ class VtsVndkFilesTest(unittest.TestCase): def testNoLlndkInOdm64(self): """Runs _TestNoLlndkInOdm for 64-bit libraries.""" - if self._dut.GetCpuAbiList(64): - self._TestNoLlndkInOdm(64) - else: - logging.info("Skip the test as the device doesn't support 64-bit " - "ABI.") + self._TestNoLlndkInOdm(64) if __name__ == "__main__": diff --git a/golden/vndk_data.py b/golden/vndk_data.py index 3dbcd22..bb1a8d7 100644 --- a/golden/vndk_data.py +++ b/golden/vndk_data.py @@ -137,32 +137,51 @@ def GetAbiDumpPathsFromResources(version, binder_bitness, abi_name, abi_bitness) return dump_paths -def _LoadVndkLibraryListsFile(vndk_lists, tags, vndk_lib_list_file): +def _LoadVndkLibraryListsFile(vndk_lists, tags, vndk_lib_list_file, + change_history_file=None): """Load VNDK libraries from the file to the specified tuple. Args: vndk_lists: The output tuple of lists containing library names. tags: Strings, the tags of the libraries to find. vndk_lib_list_file: The file object containing the VNDK library list. + change_history_file: The file object containing the VNDK list change + history. It adds the vndk files that are removed. """ - - lib_sets = collections.defaultdict(set) - - # Load VNDK tags from the list. - for line in vndk_lib_list_file: + def ReadTagAndFile(line): # Ignore comments. if line.startswith('#'): - continue + return None, None # Split columns. cells = line.split(': ', 1) if len(cells) < 2: - continue - tag = cells[0] - lib_name = cells[1].strip() + return None, None + return cells[0].strip(), cells[1].strip() + lib_sets = collections.defaultdict(set) + + # Load VNDK tags from the list. + for line in vndk_lib_list_file: + tag, lib_name = ReadTagAndFile(line) + if not tag: + continue lib_sets[tag].add(lib_name) + if change_history_file: + for line in change_history_file: + tag, lib_name = ReadTagAndFile(line) + if not tag: + continue + + # In the history file, tag has '+' prefix if the file is added and + # '-' prefix if removed. + # To relax the test, include the removed files to the list. + if tag[0] != '-': + continue + tag = tag[1:] + lib_sets[tag].add(lib_name) + # Compute VNDK-core-private and VNDK-SP-private. private = lib_sets.get('VNDK-private', set()) @@ -204,6 +223,9 @@ def LoadVndkLibraryListsFromResources(version, *tags): vndk_lib_list_name = version_str + ".txt" vndk_lib_list = resources.files(_RESOURCE_PACKAGE).joinpath( vndk_lib_list_name) + vndk_lib_list_history_name = version_str + "_history.txt" + vndk_lib_list_history = resources.files(_RESOURCE_PACKAGE).joinpath( + vndk_lib_list_history_name) vndk_lib_extra_list_name = "vndk-lib-extra-list-" + version_str + ".txt" vndk_lib_extra_list = resources.files(_RESOURCE_PACKAGE).joinpath( vndk_lib_extra_list_name) @@ -219,7 +241,11 @@ def LoadVndkLibraryListsFromResources(version, *tags): vndk_lists = tuple([] for x in tags) with vndk_lib_list.open("r") as f: - _LoadVndkLibraryListsFile(vndk_lists, tags, f) + if vndk_lib_list_history.is_file(): + with vndk_lib_list_history.open("r") as history: + _LoadVndkLibraryListsFile(vndk_lists, tags, f, history) + else: + _LoadVndkLibraryListsFile(vndk_lists, tags, f) with vndk_lib_extra_list.open("r") as f: _LoadVndkLibraryListsFile(vndk_lists, tags, f) return vndk_lists @@ -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") |