diff options
author | Hsin-Yi Chen <hsinyichen@google.com> | 2019-06-20 22:45:20 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-06-20 22:45:20 -0700 |
commit | 81182ebfb48e745ecec9afc2c2541b97c66e8a3d (patch) | |
tree | e1e78550c184f5d7f511cb424cd1e780b7380256 | |
parent | a5db0f348e91c327b70bc53e2b5a0d86694dc317 (diff) | |
parent | ae9db0ecb2ec6f2b6fbdabe6b63b7433a14459b2 (diff) | |
download | vndk-81182ebfb48e745ecec9afc2c2541b97c66e8a3d.tar.gz |
Do not test the ELF objects not built for Android
am: ae9db0ecb2
Change-Id: Ieb24e2a62f77153577c4733556c4f961abf0955b
-rw-r--r-- | dependency/VtsVndkDependencyTest.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/dependency/VtsVndkDependencyTest.py b/dependency/VtsVndkDependencyTest.py index 094d84a..0007970 100644 --- a/dependency/VtsVndkDependencyTest.py +++ b/dependency/VtsVndkDependencyTest.py @@ -158,9 +158,48 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): if target_file_utils.IsExecutable(permissions): return True - logging.debug("%s is not for application processor", target_path) return False + def _IsElfObjectBuiltForAndroid(self, elf, target_path): + """Checks whether an ELF object is built for Android. + + Some ELF objects in vendor partition require special program + interpreters. Such executable files have .interp sections, but shared + libraries don't. As there is no reliable way to identify those + libraries. This method checks .note.android.ident section which is + created by Android build system. + + Args: + elf: The object of elf_parser.ElfParser. + target_path: The path to the ELF file on target. + + Returns: + A boolean, whether the ELF object is built for Android. + """ + # b/133399940 Skip an ELF file if it does not have .note.android.ident + # section and meets one of the following conditions: + if elf.HasAndroidIdent(): + return True + + # It's in the specific directory and is a shared library. + if (target_path.startswith("/vendor/arib/lib/") and + ".so" in target_path and + elf.IsSharedObject()): + return False + + # It's in the specific directory, requires special program interpreter, + # and is executable. + if target_path.startswith("/vendor/arib/bin/"): + interp = elf.GetProgramInterpreter() + if interp and interp not in self._DEFAULT_PROGRAM_INTERPRETERS: + permissions = target_file_utils.GetPermission(target_path, + self._dut.shell) + if (elf.IsExecutable() or + target_file_utils.IsExecutable(permissions)): + return False + + return True + def _LoadElfObjects(self, host_dir, target_dir, abi_list, elf_error_handler): """Scans a host directory recursively and loads all ELF files in it. @@ -189,7 +228,13 @@ class VtsVndkDependencyTest(base_test.BaseTestClass): continue try: if not self._IsElfObjectForAp(elf, target_path, abi_list): + logging.info("%s is not for application processor", + target_path) continue + if not self._IsElfObjectBuiltForAndroid(elf, target_path): + logging.info("%s is not built for Android", target_path) + continue + deps = elf.ListDependencies() except elf_parser.ElfError as e: elf_error_handler(target_path, e) |