diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-04-01 07:24:01 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-04-01 07:24:01 +0000 |
commit | c5205c7ddfecadf7220eb74d0e41d7fb839ac587 (patch) | |
tree | eafc829216e992f5ac993a6714ef377fe7fa3b45 | |
parent | de46efd26c7895a078a21310e1242ed23d9933b4 (diff) | |
parent | c9e20ef329ed5d410c88f67629c145e5523f2584 (diff) | |
download | vndk-c5205c7ddfecadf7220eb74d0e41d7fb839ac587.tar.gz |
Snap for 4693621 from c9e20ef329ed5d410c88f67629c145e5523f2584 to pi-release
Change-Id: I6970aa7f09026753af8b8e875c8fa56b29c6a23a
-rw-r--r-- | abi/VtsVndkAbiTest.py | 7 | ||||
-rwxr-xr-x | golden/dump_abi.py | 49 | ||||
-rw-r--r-- | golden/vndk_data.py | 45 |
3 files changed, 80 insertions, 21 deletions
diff --git a/abi/VtsVndkAbiTest.py b/abi/VtsVndkAbiTest.py index bc1b975..d277073 100644 --- a/abi/VtsVndkAbiTest.py +++ b/abi/VtsVndkAbiTest.py @@ -249,10 +249,13 @@ class VtsVndkAbiTest(base_test.BaseTestClass): """Checks ABI compliance of VNDK libraries.""" primary_abi = self._dut.getCpuAbiList()[0] dump_version = (self._vndk_version if self._vndk_version else - vndk_data.DEFAULT_VNDK_VERSION) + vndk_data.LoadDefaultVndkVersion(self.data_file_path)) + asserts.assertTrue(dump_version, + "Cannot load default VNDK version.") + dump_dir = vndk_data.GetAbiDumpDirectory( self.data_file_path, - self._vndk_version, + dump_version, primary_abi, self.abi_bitness) asserts.assertTrue( diff --git a/golden/dump_abi.py b/golden/dump_abi.py index 8ca30e8..cbfc04b 100755 --- a/golden/dump_abi.py +++ b/golden/dump_abi.py @@ -16,6 +16,7 @@ # import argparse +import csv import importlib import os import subprocess @@ -193,23 +194,54 @@ def DumpVtables(lib_path, dump_path, dumper_dir, include_symbols): return dump_string +def _LoadLibraryNamesFromCsv(csv_file): + """Loads VNDK and VNDK-SP library names from an eligible list. + + Args: + csv_file: A file object of eligible-list.csv. + + Returns: + A list of strings, the VNDK and VNDK-SP library names with vndk/vndk-sp + directory prefixes. + """ + lib_names = [] + # Skip header + next(csv_file) + reader = csv.reader(csv_file) + for cells in reader: + if cells[1] not in ("VNDK", "VNDK-SP"): + continue + lib_name = os.path.normpath(cells[0]).replace("/system/${LIB}/", "", 1) + if not (lib_name.startswith("vndk") or lib_name.startswith("vndk-sp")): + continue + lib_name = lib_name.replace("${VNDK_VER}", "{VNDK_VER}") + lib_names.append(lib_name) + return lib_names + + def _LoadLibraryNames(file_names): """Loads library names from files. - Each element in the input list can be a .so file or a text file which - contains list of library names. The returned list consists of the .so file - names in the input list, and the non-empty lines in the text files. + Each element in the input list can be a .so file, a text file, or a .csv + file. The returned list consists of: + - The .so file names in the input list. + - The non-empty lines in the text files. + - The libraries tagged with VNDK or VNDK-SP in the CSV. Args: file_names: A list of strings, the library or text file names. Returns: - A list of strings, the library names. + A list of strings, the library names (probably with vndk/vndk-sp + directory prefixes). """ lib_names = [] for file_name in file_names: if file_name.endswith(".so"): lib_names.append(file_name) + elif file_name.endswith(".csv"): + with open(file_name, "r") as csv_file: + lib_names.extend(_LoadLibraryNamesFromCsv(csv_file)) else: with open(file_name, "r") as lib_list: lib_names.extend(line.strip() for line in lib_list @@ -270,8 +302,13 @@ def main(): # Parse arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument("file", nargs="*", - help="the library to dump. Can be .so file or a" - "text file containing list of libraries.") + help="the libraries to dump. Each file can be " + ".so, text, or .csv. The text file contains " + "a list of paths. The CSV file follows the" + "format of eligible list output from VNDK" + "definition tool. {VNDK_VER} in the library" + "paths is replaced with " + "\"-\" + PLATFORM_VNDK_VERSION.") arg_parser.add_argument("--dumper-dir", "-d", action="store", help="the path to the directory containing " "bin/vndk-vtable-dumper.") diff --git a/golden/vndk_data.py b/golden/vndk_data.py index 3ad4620..e177e0b 100644 --- a/golden/vndk_data.py +++ b/golden/vndk_data.py @@ -41,9 +41,6 @@ VNDK_SP = "VNDK-SP" # VNDK-SP dependencies that vendor modules cannot directly access. VNDK_SP_PRIVATE = "VNDK-SP-Private" -# The name of the data directory for devices with no VNDK version. -DEFAULT_VNDK_VERSION = "P" - # The ABI dump directories. 64-bit comes before 32-bit in order to sequentially # search for longest prefix. _ABI_NAMES = ("arm64", "arm", "mips64", "mips", "x86_64", "x86") @@ -52,6 +49,25 @@ _ABI_NAMES = ("arm64", "arm", "mips64", "mips", "x86_64", "x86") _GOLDEN_DIR = os.path.join("vts", "testcases", "vndk", "golden") +def LoadDefaultVndkVersion(data_file_path): + """Loads the name of the data directory for devices with no VNDK version. + + Args: + data_file_path: The path to VTS data directory. + + Returns: + A string, the directory name. + None if fails to load the name. + """ + try: + with open(os.path.join(data_file_path, _GOLDEN_DIR, + "platform_vndk_version.txt"), "r") as f: + return f.read().strip() + except IOError: + logging.error("Cannot load default VNDK version.") + return None + + def GetAbiDumpDirectory(data_file_path, version, abi_name, abi_bitness): """Returns the VNDK dump directory on host. @@ -71,12 +87,13 @@ def GetAbiDumpDirectory(data_file_path, version, abi_name, abi_bitness): logging.warning("Unknown ABI %s.", abi_name) return None - dump_dir = os.path.join( - data_file_path, - _GOLDEN_DIR, - version if version else DEFAULT_VNDK_VERSION, - abi_dir, - "lib64" if str(abi_bitness) == "64" else "lib") + version_dir = (version if version else + LoadDefaultVndkVersion(data_file_path)) + if not version_dir: + return None + + dump_dir = os.path.join(data_file_path, _GOLDEN_DIR, version_dir, abi_dir, + "lib64" if str(abi_bitness) == "64" else "lib") if not os.path.isdir(dump_dir): logging.warning("%s is not a directory.", dump_dir) @@ -99,11 +116,13 @@ def LoadVndkLibraryLists(data_file_path, version, *tags): expressions. None if the spreadsheet for the version is not found. """ + version_dir = (version if version else + LoadDefaultVndkVersion(data_file_path)) + if not version_dir: + return None + path = os.path.join( - data_file_path, - _GOLDEN_DIR, - version if version else DEFAULT_VNDK_VERSION, - "eligible-list.csv") + data_file_path, _GOLDEN_DIR, version_dir, "eligible-list.csv") if not os.path.isfile(path): logging.warning("Cannot load %s.", path) return None |