1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-21 01:59:13 +00:00

AndroidUxPerfWorkload: Added AndroidUxPerfWorkload base class

This commit is contained in:
Sebastian Goscik 2016-08-25 15:24:56 +01:00
parent 64860a2d1a
commit fc52b6d347

View File

@ -18,7 +18,7 @@ import sys
import time import time
from math import ceil from math import ceil
from wlauto.core.extension import Parameter from wlauto.core.extension import Parameter, ExtensionMeta, ListCollection
from wlauto.core.workload import Workload from wlauto.core.workload import Workload
from wlauto.core.resource import NO_ONE from wlauto.core.resource import NO_ONE
from wlauto.common.android.resources import ApkFile from wlauto.common.android.resources import ApkFile
@ -593,3 +593,63 @@ class GameWorkload(ApkWorkload, ReventWorkload):
self.device.busybox, self.device.busybox,
ondevice_cache) ondevice_cache)
self.device.execute(deploy_command, timeout=timeout, as_root=True) self.device.execute(deploy_command, timeout=timeout, as_root=True)
class AndroidUxPerfWorkloadMeta(ExtensionMeta):
to_propagate = ExtensionMeta.to_propagate + [('deployable_assets', str, ListCollection)]
class AndroidUxPerfWorkload(AndroidUiAutoBenchmark):
__metaclass__ = AndroidUxPerfWorkloadMeta
deployable_assets = []
parameters = [
Parameter('markers_enabled', kind=bool, default=False,
description="""
If ``True``, UX_PERF action markers will be emitted to logcat during
the test run.
"""),
Parameter('cleanup_assets', kind=bool, default=False,
description="""
If ``True`` pushed assets will be deleted at the end of each iteration.
"""),
Parameter('force_push', kind=bool, default=False,
description="""
If ``False``, assets will only be pushed to the device when they are
not already present on the device.
"""),
]
# Methods to handle assests
def _path_on_device(self, fpath, dirname=None):
if dirname is None:
dirname = self.device.working_directory
fname = os.path.basename(fpath)
return self.device.path.join(dirname, fname)
def push_dependencies(self, context):
for f in self.deployable_assets:
fpath = context.resolver.get(File(self, f))
device_path = self._path_on_device(fpath)
if self.force_push or not self.device.file_exists(device_path):
self.device.push_file(fpath, device_path, timeout=300)
def delete_dependencies(self):
for f in self.deployable_assets:
self.device.delete_file(self._path_on_device(f))
# Framework
def __init__(self):
super(AndroidUxPerfWorkload, self).__init__()
# Turn class attribute into instance attribute
self.deployable_assets = list(self.deployable_assets)
def setup(self, context):
self.push_dependencies(context)
self.uiauto_params['markers_enabled'] = self.markers_enabled
def teardown(self, context):
if self.cleanup_assets:
self.delete_dependencies()