1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 20:11:20 +00:00

wa/apk_workloads: Update to not specify a default apk version.

No longer specify a default version to allow any available apks to be
detected and then choose the appropriate automation based on the
detected version.
Refactor to support new supported_versions attribute and since APK
resolution needs to have happened before setting uiauto parameter
move assignments to ``initialize``.
This commit is contained in:
Marc Bonnici 2019-01-07 11:19:03 +00:00 committed by setrofim
parent a1cecc0002
commit 6ab1ae74a6
4 changed files with 22 additions and 37 deletions

View File

@ -77,13 +77,13 @@ class ExoPlayer(ApkWorkload):
video_directory = os.path.join(settings.dependencies_directory, name) video_directory = os.path.join(settings.dependencies_directory, name)
package_names = ['com.google.android.exoplayer2.demo'] package_names = ['com.google.android.exoplayer2.demo']
versions = ['2.4', '2.5', '2.6'] supported_versions = ['2.4', '2.5', '2.6']
action = 'com.google.android.exoplayer.demo.action.VIEW' action = 'com.google.android.exoplayer.demo.action.VIEW'
default_format = 'mov_720p' default_format = 'mov_720p'
view = 'SurfaceView - com.google.android.exoplayer2.demo/com.google.android.exoplayer2.demo.PlayerActivity' view = 'SurfaceView - com.google.android.exoplayer2.demo/com.google.android.exoplayer2.demo.PlayerActivity'
parameters = [ parameters = [
Parameter('version', allowed_values=versions, default=versions[-1], override=True), Parameter('version', allowed_values=supported_versions, override=True),
Parameter('duration', kind=int, default=20, Parameter('duration', kind=int, default=20,
description=""" description="""
Playback duration of the video file. This becomes the duration of the workload. Playback duration of the video file. This becomes the duration of the workload.

View File

@ -78,12 +78,13 @@ class Geekbench(ApkUiautoWorkload):
'activity': '.HomeActivity', 'activity': '.HomeActivity',
}, },
} }
supported_versions = sorted(versions.keys())
begin_regex = re.compile(r'^\s*D/WebViewClassic.loadDataWithBaseURL\(\s*\d+\s*\)' begin_regex = re.compile(r'^\s*D/WebViewClassic.loadDataWithBaseURL\(\s*\d+\s*\)'
r'\s*:\s*(?P<content>\<.*)\s*$') r'\s*:\s*(?P<content>\<.*)\s*$')
replace_regex = re.compile(r'<[^>]*>') replace_regex = re.compile(r'<[^>]*>')
parameters = [ parameters = [
Parameter('version', default=sorted(versions.keys())[-1], allowed_values=sorted(versions.keys()), Parameter('version', allowed_values=supported_versions,
description='Specifies which version of the workload should be run.', description='Specifies which version of the workload should be run.',
override=True), override=True),
Parameter('loops', kind=int, default=1, aliases=['times'], Parameter('loops', kind=int, default=1, aliases=['times'],
@ -109,23 +110,16 @@ class Geekbench(ApkUiautoWorkload):
def activity(self): def activity(self):
return self.versions[self.version]['activity'] return self.versions[self.version]['activity']
@property
def package(self):
return self.versions[self.version]['package']
@property @property
def package_names(self): def package_names(self):
return [self.package] return set(self.versions[v]['package'] for v in self.versions)
def __init__(self, *args, **kwargs): def initialize(self, context):
super(Geekbench, self).__init__(*args, **kwargs) super(Geekbench, self).initialize(context)
self.gui.uiauto_params['version'] = self.version self.gui.uiauto_params['version'] = self.version
self.gui.uiauto_params['loops'] = self.loops self.gui.uiauto_params['loops'] = self.loops
self.gui.uiauto_params['is_corporate'] = self.is_corporate self.gui.uiauto_params['is_corporate'] = self.is_corporate
self.gui.timeout = self.timeout self.gui.timeout = self.timeout
def initialize(self, context):
super(Geekbench, self).initialize(context)
if not self.disable_update_result and not self.target.is_rooted: if not self.disable_update_result and not self.target.is_rooted:
raise WorkloadError( raise WorkloadError(
'Geekbench workload requires root to collect results. ' 'Geekbench workload requires root to collect results. '
@ -135,7 +129,6 @@ class Geekbench(ApkUiautoWorkload):
def setup(self, context): def setup(self, context):
super(Geekbench, self).setup(context) super(Geekbench, self).setup(context)
self.run_timeout = self.timeout * self.loops self.run_timeout = self.timeout * self.loops
self.exact_apk_version = self.version
def update_output(self, context): def update_output(self, context):
super(Geekbench, self).update_output(context) super(Geekbench, self).update_output(context)
@ -154,7 +147,7 @@ class Geekbench(ApkUiautoWorkload):
score_calculator.update_results(context) score_calculator.update_results(context)
def update_result_3(self, context): def update_result_3(self, context):
outfile_glob = self.target.path.join(self.target.package_data_directory, self.package, 'files', '*gb3') outfile_glob = self.target.path.join(self.target.package_data_directory, self.apk.package, 'files', '*gb3')
on_target_output_files = [f.strip() for f in self.target.execute('ls {}'.format(outfile_glob), on_target_output_files = [f.strip() for f in self.target.execute('ls {}'.format(outfile_glob),
as_root=True).split('\n') if f] as_root=True).split('\n') if f]
for i, on_target_output_file in enumerate(on_target_output_files): for i, on_target_output_file in enumerate(on_target_output_files):
@ -176,7 +169,7 @@ class Geekbench(ApkUiautoWorkload):
section['multicore_score']) section['multicore_score'])
def update_result_4(self, context): def update_result_4(self, context):
outfile_glob = self.target.path.join(self.target.package_data_directory, self.package, 'files', '*gb*') outfile_glob = self.target.path.join(self.target.package_data_directory, self.apk.package, 'files', '*gb*')
on_target_output_files = [f.strip() for f in self.target.execute('ls {}'.format(outfile_glob), on_target_output_files = [f.strip() for f in self.target.execute('ls {}'.format(outfile_glob),
as_root=True).split('\n') if f] as_root=True).split('\n') if f]
for i, on_target_output_file in enumerate(on_target_output_files): for i, on_target_output_file in enumerate(on_target_output_files):
@ -395,16 +388,12 @@ class GeekbenchCorproate(Geekbench): # pylint: disable=too-many-ancestors
name = "geekbench-corporate" name = "geekbench-corporate"
is_corporate = True is_corporate = True
requires_network = False requires_network = False
supported_versions = ['4.1.0', '5.0.0']
versions = ['4.1.0', '5.0.0'] package_names = ['com.primatelabs.geekbench4.corporate']
activity = 'com.primatelabs.geekbench.HomeActivity' activity = 'com.primatelabs.geekbench.HomeActivity'
package = 'com.primatelabs.geekbench4.corporate'
parameters = [ parameters = [
Parameter('version', Parameter('version', allowed_values=supported_versions, override=True)
default=sorted(versions)[-1], allowed_values=versions,
override=True)
] ]

View File

@ -56,10 +56,8 @@ class Glb(ApkUiautoWorkload):
view = 'com.glbenchmark.glbenchmark27/com.glbenchmark.activities.GLBRender' view = 'com.glbenchmark.glbenchmark27/com.glbenchmark.activities.GLBRender'
package_names = ['com.glbenchmark.glbenchmark27', 'com.glbenchmark.glbenchmark25'] package_names = ['com.glbenchmark.glbenchmark27', 'com.glbenchmark.glbenchmark25']
packages = { supported_versions = ['2.7', '2.5']
'2.7': 'com.glbenchmark.glbenchmark27',
'2.5': 'com.glbenchmark.glbenchmark25',
}
# If usecase is not specified the default usecase is the first supported usecase alias # If usecase is not specified the default usecase is the first supported usecase alias
# for the specified version. # for the specified version.
supported_usecase_aliases = { supported_usecase_aliases = {
@ -74,7 +72,7 @@ class Glb(ApkUiautoWorkload):
regex = re.compile(r'GLBenchmark (metric|FPS): (.*)') regex = re.compile(r'GLBenchmark (metric|FPS): (.*)')
parameters = [ parameters = [
Parameter('version', default='2.7', allowed_values=['2.7', '2.5'], override=True, Parameter('version', allowed_values=supported_versions, override=True,
description=('Specifies which version of the benchmark to run (different versions ' description=('Specifies which version of the benchmark to run (different versions '
'support different use cases).')), 'support different use cases).')),
Parameter('use_case', default=None, Parameter('use_case', default=None,
@ -107,10 +105,9 @@ class Glb(ApkUiautoWorkload):
Alias('t-rex_offscreen', use_case='t-rex', type='offscreen'), Alias('t-rex_offscreen', use_case='t-rex', type='offscreen'),
] ]
def __init__(self, target, **kwargs): def initialize(self, context):
super(Glb, self).__init__(target, **kwargs) super(Glb, self).initialize(context)
self.gui.uiauto_params['version'] = self.version self.gui.uiauto_params['version'] = self.version
if self.use_case is None: if self.use_case is None:
self.use_case = self.supported_usecase_aliases[self.version][0] self.use_case = self.supported_usecase_aliases[self.version][0]
if self.use_case.lower() in USE_CASE_MAP: if self.use_case.lower() in USE_CASE_MAP:
@ -124,7 +121,6 @@ class Glb(ApkUiautoWorkload):
self.gui.uiauto_params['usecase_type'] = self.type.replace(' ', '_') self.gui.uiauto_params['usecase_type'] = self.type.replace(' ', '_')
self.gui.uiauto_params['timeout'] = self.run_timeout self.gui.uiauto_params['timeout'] = self.run_timeout
self.package_names = [self.packages[self.version]]
def update_output(self, context): def update_output(self, context):
super(Glb, self).update_output(context) super(Glb, self).update_output(context)

View File

@ -48,11 +48,11 @@ class Vellamo(ApkUiautoWorkload):
'3.0': ['Browser', 'Metal', 'Multi'], '3.0': ['Browser', 'Metal', 'Multi'],
'3.2.4': ['Browser', 'Metal', 'Multi'], '3.2.4': ['Browser', 'Metal', 'Multi'],
} }
valid_versions = list(benchmark_types.keys()) supported_versions = list(benchmark_types.keys())
summary_metrics = None summary_metrics = None
parameters = [ parameters = [
Parameter('version', kind=str, allowed_values=valid_versions, default=sorted(benchmark_types, reverse=True)[0], override=True, Parameter('version', kind=str, allowed_values=supported_versions, override=True,
description=('Specify the version of Vellamo to be run. ' description=('Specify the version of Vellamo to be run. '
'If not specified, the latest available version will be used.')), 'If not specified, the latest available version will be used.')),
Parameter('benchmarks', kind=list_of_strs, allowed_values=benchmark_types['3.0'], default=benchmark_types['3.0'], Parameter('benchmarks', kind=list_of_strs, allowed_values=benchmark_types['3.0'], default=benchmark_types['3.0'],
@ -66,15 +66,15 @@ class Vellamo(ApkUiautoWorkload):
] ]
def setup(self, context): def setup(self, context):
super(Vellamo, self).setup(context)
self.gui.uiauto_params['version'] = self.version self.gui.uiauto_params['version'] = self.version
self.gui.uiauto_params['browserToUse'] = self.browser self.gui.uiauto_params['browserToUse'] = self.browser
self.gui.uiauto_params['metal'] = 'Metal' in self.benchmarks self.gui.uiauto_params['metal'] = 'Metal' in self.benchmarks
self.gui.uiauto_params['browser'] = 'Browser' in self.benchmarks self.gui.uiauto_params['browser'] = 'Browser' in self.benchmarks
self.gui.uiauto_params['multicore'] = 'Multi' in self.benchmarks self.gui.uiauto_params['multicore'] = 'Multi' in self.benchmarks
super(Vellamo, self).setup(context)
def validate(self): def initialize(self, context):
super(Vellamo, self).validate() super(Vellamo, self).initialize(context)
if self.version == '2.0.3' or not self.benchmarks: # pylint: disable=access-member-before-definition if self.version == '2.0.3' or not self.benchmarks: # pylint: disable=access-member-before-definition
self.benchmarks = self.benchmark_types[self.version] # pylint: disable=attribute-defined-outside-init self.benchmarks = self.benchmark_types[self.version] # pylint: disable=attribute-defined-outside-init
else: else: