1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

ApkResolution: Now takes into account apk abi when resolving.

Previously any apk found would be selected even if the abi did not match
the device, now an apk is only selected if it is compatible with the
device. Additionally the 'exact_abi' parameter has been added to allow only
selecting an apk if a devices primary abi's native code is present in
the apk, or there is no native code.
This commit is contained in:
Marc Bonnici 2017-07-14 18:11:05 +01:00
parent 5ef3d7673f
commit c722a6a73c
2 changed files with 41 additions and 6 deletions

View File

@ -29,7 +29,7 @@ from wa.framework.exception import ResourceError
from wa.framework.configuration import settings from wa.framework.configuration import settings
from wa.utils import log from wa.utils import log
from wa.utils.misc import ensure_directory_exists as _d, get_object_name from wa.utils.misc import ensure_directory_exists as _d, get_object_name
from wa.utils.types import boolean, prioritylist, enum from wa.utils.types import boolean, prioritylist, enum, list_or_string
@ -144,17 +144,21 @@ class ApkFile(Resource):
kind = 'apk' kind = 'apk'
def __init__(self, owner, variant=None, version=None, def __init__(self, owner, variant=None, version=None,
package=None, uiauto=False): package=None, uiauto=False, exact_abi=False,
supported_abi=None):
super(ApkFile, self).__init__(owner) super(ApkFile, self).__init__(owner)
self.variant = variant self.variant = variant
self.version = version self.version = version
self.package = package self.package = package
self.uiauto = uiauto self.uiauto = uiauto
self.exact_abi = exact_abi
self.supported_abi = supported_abi
def match(self, path): def match(self, path):
name_matches = True name_matches = True
version_matches = True version_matches = True
package_matches = True package_matches = True
abi_matches = True
uiauto_matches = uiauto_test_matches(path, self.uiauto) uiauto_matches = uiauto_test_matches(path, self.uiauto)
if self.version is not None: if self.version is not None:
version_matches = apk_version_matches(path, self.version) version_matches = apk_version_matches(path, self.version)
@ -162,8 +166,12 @@ class ApkFile(Resource):
name_matches = file_name_matches(path, self.variant) name_matches = file_name_matches(path, self.variant)
if self.package is not None: if self.package is not None:
package_matches = package_name_matches(path, self.package) package_matches = package_name_matches(path, self.package)
if self.supported_abi is not None:
abi_matches = apk_abi_matches(path, self.supported_abi,
self.exact_abi)
return name_matches and version_matches and \ return name_matches and version_matches and \
uiauto_matches and package_matches uiauto_matches and package_matches and \
abi_matches
def __str__(self): def __str__(self):
@ -289,3 +297,18 @@ def uiauto_test_matches(path, uiauto):
def package_name_matches(path, package): def package_name_matches(path, package):
info = ApkInfo(path) info = ApkInfo(path)
return info.package == package return info.package == package
def apk_abi_matches(path, supported_abi, exact_abi=False):
supported_abi = list_or_string(supported_abi)
info = ApkInfo(path)
# If no native code present, suitable for all devices.
if not info.native_code:
return True
if exact_abi: # Only check primary
return supported_abi[0] in info.native_code
else:
for abi in supported_abi:
if abi in info.native_code:
return True
return False

View File

@ -145,6 +145,12 @@ class ApkWorkload(Workload):
description=""" description="""
If ``True``, will uninstall workload\'s APK as part of teardown.' If ``True``, will uninstall workload\'s APK as part of teardown.'
"""), """),
Parameter('exact_abi', kind=bool,
default=False,
description="""
If ``True``, workload will check that the APK matches the target
device ABI, otherwise any suitable APK found will be used.
""")
] ]
def __init__(self, target, **kwargs): def __init__(self, target, **kwargs):
@ -156,7 +162,8 @@ class ApkWorkload(Workload):
version=self.version, version=self.version,
force_install=self.force_install, force_install=self.force_install,
install_timeout=self.install_timeout, install_timeout=self.install_timeout,
uninstall=self.uninstall) uninstall=self.uninstall,
exact_abi=self.exact_abi)
def init_resources(self, context): def init_resources(self, context):
pass pass
@ -423,7 +430,8 @@ class ReventGUI(object):
class PackageHandler(object): class PackageHandler(object):
def __init__(self, owner, install_timeout=300, version=None, variant=None, def __init__(self, owner, install_timeout=300, version=None, variant=None,
package=None, strict=False, force_install=False, uninstall=False): package=None, strict=False, force_install=False, uninstall=False,
exact_abi=False):
self.logger = logging.getLogger('apk') self.logger = logging.getLogger('apk')
self.owner = owner self.owner = owner
self.target = self.owner.target self.target = self.owner.target
@ -434,10 +442,12 @@ class PackageHandler(object):
self.strict = strict self.strict = strict
self.force_install = force_install self.force_install = force_install
self.uninstall = uninstall self.uninstall = uninstall
self.exact_abi = exact_abi
self.apk_file = None self.apk_file = None
self.apk_info = None self.apk_info = None
self.apk_version = None self.apk_version = None
self.logcat_log = None self.logcat_log = None
self.supported_abi = self.target.supported_abi
def initialize(self, context): def initialize(self, context):
self.resolve_package(context) self.resolve_package(context)
@ -452,7 +462,9 @@ class PackageHandler(object):
self.apk_file = context.resolver.get(ApkFile(self.owner, self.apk_file = context.resolver.get(ApkFile(self.owner,
variant=self.variant, variant=self.variant,
version=self.version, version=self.version,
package=self.package), package=self.package,
exact_abi=self.exact_abi,
supported_abi=self.supported_abi),
strict=self.strict) strict=self.strict)
if self.apk_file: if self.apk_file:
self.apk_info = ApkInfo(self.apk_file) self.apk_info = ApkInfo(self.apk_file)