summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsin-Yi Chen <hsinyichen@google.com>2017-12-14 15:34:41 +0800
committerHsin-Yi Chen <hsinyichen@google.com>2017-12-15 17:28:17 +0800
commit50f63f065cf0a7e343ca5180fc9fdecf1d4c4e9f (patch)
treeebf2bdadb9631357ca7915d23688ed57b1a97c72
parent617bffb8f56789c61df85cf2494c22bfdb89b668 (diff)
downloadvndk-50f63f065cf0a7e343ca5180fc9fdecf1d4c4e9f.tar.gz
Use versioned VNDK directory in vts-vndk
Use versioned VNDK directories in test cases. Skip some tests if VNDK runtime is not required to be enabled on the device. Bug: 68113025 Bug: 70487344 Test: vts-tradefed run commandAndExit vts-vndk Change-Id: I9bfb8e8a970f030ec93364cbe511b03bdfca2f29
-rw-r--r--abi/VtsVndkAbiTest.py21
-rw-r--r--dependency/VtsVndkDependencyTest.py34
-rw-r--r--files/VtsVndkFilesTest.py23
-rw-r--r--golden/vndk_data.py43
-rw-r--r--open_libraries/VtsVndkOpenLibrariesTest.py23
5 files changed, 85 insertions, 59 deletions
diff --git a/abi/VtsVndkAbiTest.py b/abi/VtsVndkAbiTest.py
index 0f81ef7..1a4f5f5 100644
--- a/abi/VtsVndkAbiTest.py
+++ b/abi/VtsVndkAbiTest.py
@@ -25,6 +25,7 @@ from vts.runners.host import base_test
from vts.runners.host import const
from vts.runners.host import keys
from vts.runners.host import test_runner
+from vts.testcases.vndk.golden import vndk_data
from vts.utils.python.controllers import android_device
from vts.utils.python.library import elf_parser
from vts.utils.python.library import vtable_parser
@@ -64,7 +65,6 @@ class VtsVndkAbiTest(base_test.BaseTestClass):
_VENDOR_LIB_DIR_64 = "/vendor/lib64"
_SYSTEM_LIB_DIR_32 = "/system/lib"
_SYSTEM_LIB_DIR_64 = "/system/lib64"
- _DUMP_DIR = os.path.join("vts", "testcases", "vndk", "golden")
def setUpClass(self):
"""Initializes data file path, device, and temporary directory."""
@@ -72,8 +72,7 @@ class VtsVndkAbiTest(base_test.BaseTestClass):
self.getUserParams(required_params)
self._dut = self.android_devices[0]
self._temp_dir = tempfile.mkdtemp()
- self._vndk_version = "current"
- logging.info("VNDK version: %s", self._vndk_version)
+ self._vndk_version = self._dut.vndk_version
def tearDownClass(self):
"""Deletes the temporary directory."""
@@ -234,17 +233,13 @@ class VtsVndkAbiTest(base_test.BaseTestClass):
def testAbiCompatibility(self):
"""Checks ABI compliance of VNDK libraries."""
- abi_dirs = ("arm64", "arm", "mips64", "mips", "x86_64", "x86")
- try:
- abi_dir = next(x for x in abi_dirs if self.abi_name.startswith(x))
- except StopIteration:
- asserts.fail("Unknown ABI: " + self.abi_name)
-
- dump_dir = os.path.join(
- self.data_file_path, self._DUMP_DIR, self._vndk_version, abi_dir)
+ dump_dir = vndk_data.GetAbiDumpDirectory(
+ self.data_file_path, self._vndk_version, self.abi_name)
asserts.assertTrue(
- os.path.isdir(dump_dir),
- "No dump files for VNDK version " + self._vndk_version)
+ dump_dir,
+ "No dump files. version: %s ABI: %s" % (self._vndk_version,
+ self.abi_name))
+ logging.info("dump dir: %s", dump_dir)
vendor_lib_dir = os.path.join(
self._temp_dir, "vendor_lib_dir_" + self.abi_bitness)
diff --git a/dependency/VtsVndkDependencyTest.py b/dependency/VtsVndkDependencyTest.py
index 78c2e17..0c2944e 100644
--- a/dependency/VtsVndkDependencyTest.py
+++ b/dependency/VtsVndkDependencyTest.py
@@ -31,6 +31,7 @@ from vts.utils.python.controllers import android_device
from vts.utils.python.file import target_file_utils
from vts.utils.python.library import elf_parser
from vts.utils.python.os import path_utils
+from vts.utils.python.vndk import vndk_utils
class VtsVndkDependencyTest(base_test.BaseTestClass):
@@ -44,13 +45,13 @@ class VtsVndkDependencyTest(base_test.BaseTestClass):
_ll_ndk: Set of strings. The names of low-level NDK libraries in
/system/lib[64].
_sp_ndk: Set of strings. The names of same-process NDK libraries in
- /system/lib[64]/vndk.
+ /system/lib[64]/vndk-${VER}.
_vndk: Set of strings. The names of VNDK core libraries in
- /system/lib[64]/vndk.
+ /system/lib[64]/vndk-${VER}.
_vndk_sp: Set of strings. The names of VNDK-SP libraries in
- /system/lib[64]/vndk-sp.
+ /system/lib[64]/vndk-sp-${VER}.
_vndk_sp_indirect: Set of strings. The names of VNDK-SP-Indirect
- libraries in /system/lib[64]/vndk-sp
+ libraries in /system/lib[64]/vndk-sp-${VER}.
_SAME_PROCESS_HAL: List of patterns. The names of same-process HAL
libraries expected to be in /vendor/lib[64].
_SP_HAL_LINK_PATHS_32: 32-bit same-process HAL's link paths in
@@ -63,8 +64,6 @@ class VtsVndkDependencyTest(base_test.BaseTestClass):
/vendor/lib64.
"""
_TARGET_VENDOR_DIR = "/vendor"
- _TARGET_VNDK_SP_EXT_DIR_32 = "/vendor/lib/vndk-sp"
- _TARGET_VNDK_SP_EXT_DIR_64 = "/vendor/lib64/vndk-sp"
# copied from development/vndk/tools/definition-tool/vndk_definition_tool.py
_SAME_PROCESS_HAL = [
@@ -119,7 +118,8 @@ class VtsVndkDependencyTest(base_test.BaseTestClass):
self._temp_dir)
logging.debug(pull_output)
vndk_lists = vndk_data.LoadVndkLibraryLists(
- self.data_file_path, "current",
+ self.data_file_path,
+ self._dut.vndk_version,
vndk_data.LL_NDK, vndk_data.SP_NDK, vndk_data.VNDK,
vndk_data.VNDK_SP, vndk_data.VNDK_SP_INDIRECT)
asserts.assertTrue(vndk_lists, "Cannot load VNDK library lists.")
@@ -202,17 +202,6 @@ class VtsVndkDependencyTest(base_test.BaseTestClass):
"""
return getattr(self, "_SP_HAL_LINK_PATHS_" + str(bitness))
- def _GetVndkSpExtDir(self, bitness):
- """Returns 32/64-bit VNDK-SP extension directory on target device.
-
- Args:
- bitness: 32 or 64, the bitness of VNDK-SP extension.
-
- Returns:
- A string, the path to VNDK-SP extension directory.
- """
- return getattr(self, "_TARGET_VNDK_SP_EXT_DIR_" + str(bitness))
-
def _DfsDependencies(self, lib, searched, searchable):
"""Depth-first-search for library dependencies.
@@ -361,7 +350,7 @@ class VtsVndkDependencyTest(base_test.BaseTestClass):
Returns:
List of tuples (path, disallowed_dependencies).
"""
- vndk_sp_ext_dir = self._GetVndkSpExtDir(bitness)
+ vndk_sp_ext_dir = vndk_utils.GetVndkSpExtDirectory(bitness)
vendor_libs = self._FindVendorLibs(bitness, objs)
logging.info("%d-bit vendor libraries: %s",
bitness, ", ".join([x.name for x in vendor_libs]))
@@ -375,12 +364,11 @@ class VtsVndkDependencyTest(base_test.BaseTestClass):
obj not in sp_hal_libs and
obj.target_dir != vndk_sp_ext_dir}
dep_errors = self._TestVendorDependency(vendor_objs, vendor_libs)
- # TODO(hsinyichen): b/68113025 enable when VNDK runtime restriction
- # is enforced
- if not target_file_utils.IsDirectory("/system/lib/vndk",
- self._dut.shell):
+
+ 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))
return dep_errors
diff --git a/files/VtsVndkFilesTest.py b/files/VtsVndkFilesTest.py
index 4115a7c..61af46a 100644
--- a/files/VtsVndkFilesTest.py
+++ b/files/VtsVndkFilesTest.py
@@ -23,6 +23,7 @@ from vts.runners.host import keys
from vts.runners.host import test_runner
from vts.testcases.vndk.golden import vndk_data
from vts.utils.python.file import target_file_utils
+from vts.utils.python.vndk import vndk_utils
class VtsVndkFilesTest(base_test.BaseTestClass):
@@ -30,18 +31,18 @@ class VtsVndkFilesTest(base_test.BaseTestClass):
Attributes:
data_file_path: The path to VTS data directory.
+ _dut: The AndroidDevice under test.
_shell: The ShellMirrorObject that executes commands.
+ _vndk_version: The VNDK version of the device.
"""
- _SYSTEM_VNDK_DIR_32 = "/system/lib/vndk"
- _SYSTEM_VNDK_DIR_64 = "/system/lib64/vndk"
- _SYSTEM_VNDK_SP_DIR_32 = "/system/lib/vndk-sp"
- _SYSTEM_VNDK_SP_DIR_64 = "/system/lib64/vndk-sp"
def setUpClass(self):
"""Initializes the data file path and shell."""
required_params = [keys.ConfigKeys.IKEY_DATA_FILE_PATH]
self.getUserParams(required_params)
- self._shell = self.android_devices[0].shell
+ self._dut = self.android_devices[0]
+ self._shell = self._dut.shell
+ self._vndk_version = self._dut.vndk_version
def _ListFiles(self, dir_path):
"""Lists all files in a directory except subdirectories.
@@ -64,7 +65,7 @@ class VtsVndkFilesTest(base_test.BaseTestClass):
that can be in the directory.
"""
vndk_lists = vndk_data.LoadVndkLibraryLists(
- self.data_file_path, "current", *vndk_list_names)
+ self.data_file_path, self._vndk_version, *vndk_list_names)
asserts.assertTrue(vndk_lists, "Cannot load VNDK library lists.")
vndk_set = set().union(*vndk_lists)
logging.debug("vndk set: %s", vndk_set)
@@ -74,15 +75,19 @@ class VtsVndkFilesTest(base_test.BaseTestClass):
asserts.fail("Total number of errors: %d" % len(unexpected))
def testVndkCoreDirectory(self):
- """Verifies that VNDK core directory doesn't contain extra files."""
+ """Verifies that VNDK-core directory doesn't contain extra files."""
+ asserts.skipIf(not vndk_utils.IsVndkRuntimeEnforced(self._dut),
+ "VNDK runtime is not enforced on the device.")
self._TestVndkDirectory(
- getattr(self, "_SYSTEM_VNDK_DIR_" + self.abi_bitness),
+ vndk_utils.GetVndkCoreDirectory(
+ self.abi_bitness, self._vndk_version),
vndk_data.VNDK)
def testVndkSpDirecotry(self):
"""Verifies that VNDK-SP directory doesn't contain extra files."""
self._TestVndkDirectory(
- getattr(self, "_SYSTEM_VNDK_SP_DIR_" + self.abi_bitness),
+ vndk_utils.GetVndkSpDirectory(
+ self.abi_bitness, self._vndk_version),
vndk_data.VNDK_SP,
vndk_data.VNDK_SP_INDIRECT,
vndk_data.VNDK_SP_INDIRECT_PRIVATE)
diff --git a/golden/vndk_data.py b/golden/vndk_data.py
index 61d749e..594dfe5 100644
--- a/golden/vndk_data.py
+++ b/golden/vndk_data.py
@@ -45,11 +45,42 @@ VNDK_SP_INDIRECT = "VNDK-SP-Indirect"
# VNDK-SP dependencies that vendor modules cannot directly access.
VNDK_SP_INDIRECT_PRIVATE = "VNDK-SP-Indirect-Private"
+# 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")
# The data directory.
_GOLDEN_DIR = os.path.join("vts", "testcases", "vndk", "golden")
+def GetAbiDumpDirectory(data_file_path, version, abi_name):
+ """Returns the VNDK dump directory on host.
+
+ Args:
+ data_file_path: The path to VTS data directory.
+ version: A string, the VNDK version.
+ abi_name: A string, the ABI of the library dump.
+
+ Returns:
+ A string, the path to the dump directory.
+ None if there is no directory for the version and ABI.
+ """
+ try:
+ abi_dir = next(x for x in _ABI_NAMES if abi_name.startswith(x))
+ except StopIteration:
+ logging.warning("Unknown ABI %s.", abi_name)
+ return None
+
+ dump_dir = os.path.join(data_file_path, _GOLDEN_DIR,
+ version if version else "current", abi_dir)
+
+ if not os.path.isdir(dump_dir):
+ logging.warning("%s is not a directory.", dump_dir)
+ return None
+
+ return dump_dir
+
+
def LoadVndkLibraryLists(data_file_path, version, *tags):
"""Find the VNDK libraries with specific tags.
@@ -63,12 +94,14 @@ def LoadVndkLibraryLists(data_file_path, version, *tags):
one tag in the argument.
None if the spreadsheet for the version is not found.
"""
- path = os.path.join(data_file_path, _GOLDEN_DIR, version,
- "eligible-list.csv")
+
+ path = os.path.join(data_file_path, _GOLDEN_DIR,
+ version if version else "current", "eligible-list.csv")
if not os.path.isfile(path):
logging.warning("Cannot load %s.", path)
return None
+ dir_suffix = "-" + version if version and version != "current" else ""
vndk_lists = tuple([] for x in tags)
with open(path) as csv_file:
# Skip header
@@ -77,6 +110,8 @@ def LoadVndkLibraryLists(data_file_path, version, *tags):
for cells in reader:
for tag_index, tag in enumerate(tags):
if tag == cells[1]:
- vndk_lists[tag_index].extend(cells[0].replace("${LIB}", lib)
- for lib in ("lib", "lib64"))
+ versioned_dir = cells[0].replace("${VER}", dir_suffix)
+ vndk_lists[tag_index].extend(
+ versioned_dir.replace("${LIB}", lib)
+ for lib in ("lib", "lib64"))
return vndk_lists
diff --git a/open_libraries/VtsVndkOpenLibrariesTest.py b/open_libraries/VtsVndkOpenLibrariesTest.py
index f7e5883..39404f7 100644
--- a/open_libraries/VtsVndkOpenLibrariesTest.py
+++ b/open_libraries/VtsVndkOpenLibrariesTest.py
@@ -23,6 +23,7 @@ from vts.runners.host import const
from vts.runners.host import keys
from vts.runners.host import test_runner
from vts.testcases.vndk.golden import vndk_data
+from vts.utils.python.vndk import vndk_utils
class VtsVndkOpenLibrariesTest(base_test.BaseTestClass):
@@ -97,17 +98,19 @@ class VtsVndkOpenLibrariesTest(base_test.BaseTestClass):
def testVendorProcessOpenLibraries(self):
"""Checks if vendor processes load shared libraries on system."""
+ asserts.skipIf(not vndk_utils.IsVndkRuntimeEnforced(self._dut),
+ "VNDK runtime is not enforced on the device.")
vndk_lists = vndk_data.LoadVndkLibraryLists(
- self.data_file_path,
- "current",
- vndk_data.LL_NDK,
- vndk_data.LL_NDK_INDIRECT,
- vndk_data.SP_NDK,
- vndk_data.SP_NDK_INDIRECT,
- vndk_data.VNDK,
- vndk_data.VNDK_SP,
- vndk_data.VNDK_SP_INDIRECT,
- vndk_data.VNDK_SP_INDIRECT_PRIVATE)
+ self.data_file_path,
+ self._dut.vndk_version,
+ vndk_data.LL_NDK,
+ vndk_data.LL_NDK_INDIRECT,
+ vndk_data.SP_NDK,
+ vndk_data.SP_NDK_INDIRECT,
+ vndk_data.VNDK,
+ vndk_data.VNDK_SP,
+ vndk_data.VNDK_SP_INDIRECT,
+ vndk_data.VNDK_SP_INDIRECT_PRIVATE)
asserts.assertTrue(vndk_lists, "Cannot load VNDK library lists.")
allowed_libs = set()
for vndk_list in vndk_lists: