From 01ca20e4624d7cb3aaf93bdb2df755ba9b23001c Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Fri, 23 Mar 2018 14:45:29 +0800 Subject: Load default VNDK version from file If the device has no VNDK version, load the PLATFORM_VNDK_VERSION of the VTS package from file and also load the test data of the version. Test: run vts -m VtsVndkDependency Bug: 76080475 Change-Id: Ic7b2b2ab659e3a220b6c1310f3e0afe8995cbeda --- abi/VtsVndkAbiTest.py | 7 +++++-- golden/vndk_data.py | 45 ++++++++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 15 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/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 -- cgit v1.2.3 From c9e20ef329ed5d410c88f67629c145e5523f2584 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Tue, 20 Mar 2018 18:30:20 +0800 Subject: Make dump_abi.py load library names from eligible list Test: ./dump_abi.py \ $ANDROID_BUILD_TOP/development/vndk/tools/definition-tool/datasets/eligible-list-p-release.csv Bug: 73329012 Change-Id: Ia8674e5298ce5a8257db3d451af883abbb792a02 Merged-In: Ia8674e5298ce5a8257db3d451af883abbb792a02 (cherry picked from commit 29065e94e0784d4dca9b42795566e5de037ab8a0) --- golden/dump_abi.py | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) 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.") -- cgit v1.2.3