From e7fae25821aa099733985e35da2cbd5392df6253 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Tue, 16 Jun 2015 12:49:07 +0100 Subject: [PATCH] list command: can now filter results by supported platform Added -p option to the list command. This alows filtering results by supported platforms, e.g. wa list workloads -p linux Also adding missing supported_platforms attribute to various extensions. If an extension does not have this attribute, the assumption is that it is supported by all available platforms. --- wlauto/commands/list.py | 13 ++++++++++++- wlauto/common/android/workload.py | 4 ++++ wlauto/instrumentation/fps/__init__.py | 1 + wlauto/workloads/applaunch/__init__.py | 1 + wlauto/workloads/audio/__init__.py | 1 + wlauto/workloads/dex2oat/__init__.py | 1 + wlauto/workloads/homescreen/__init__.py | 1 + wlauto/workloads/power_loadtest/__init__.py | 1 + wlauto/workloads/video/__init__.py | 1 + 9 files changed, 23 insertions(+), 1 deletion(-) diff --git a/wlauto/commands/list.py b/wlauto/commands/list.py index 0ffba3fa..ee1f9cbb 100644 --- a/wlauto/commands/list.py +++ b/wlauto/commands/list.py @@ -31,6 +31,8 @@ class ListCommand(Command): 'one of: {}'.format(', '.join(extension_types))), choices=extension_types) self.parser.add_argument('-n', '--name', help='Filter results by the name specified') + self.parser.add_argument('-p', '--platform', help='Only list results that are supported by ' + 'the specified platform') def execute(self, args): filters = {} @@ -39,7 +41,7 @@ class ListCommand(Command): ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) results = ext_loader.list_extensions(args.kind[:-1]) - if filters: + if filters or args.platform: filtered_results = [] for result in results: passed = True @@ -47,6 +49,8 @@ class ListCommand(Command): if getattr(result, k) != v: passed = False break + if passed and args.platform: + passed = check_platform(result, args.platform) if passed: filtered_results.append(result) else: # no filters specified @@ -57,3 +61,10 @@ class ListCommand(Command): for result in sorted(filtered_results, key=lambda x: x.name): output.add_item(get_summary(result), result.name) print output.format_data() + + +def check_platform(extension, platform): + supported_platforms = getattr(extension, 'supported_platforms', []) + if supported_platforms: + return platform in supported_platforms + return True diff --git a/wlauto/common/android/workload.py b/wlauto/common/android/workload.py index ee49c061..3781d999 100644 --- a/wlauto/common/android/workload.py +++ b/wlauto/common/android/workload.py @@ -144,6 +144,7 @@ class ApkWorkload(Workload): view = None install_timeout = None default_install_timeout = 300 + supported_platforms = ['android'] parameters = [ Parameter('uninstall_apk', kind=boolean, default=False, @@ -304,6 +305,8 @@ class ReventWorkload(Workload): class AndroidUiAutoBenchmark(UiAutomatorWorkload, AndroidBenchmark): + supported_platforms = ['android'] + def __init__(self, device, **kwargs): UiAutomatorWorkload.__init__(self, device, **kwargs) AndroidBenchmark.__init__(self, device, _call_super=False, **kwargs) @@ -357,6 +360,7 @@ class GameWorkload(ApkWorkload, ReventWorkload): view = 'SurfaceView' install_timeout = 500 loading_time = 10 + supported_platforms = ['android'] def __init__(self, device, **kwargs): # pylint: disable=W0613 ApkWorkload.__init__(self, device, **kwargs) diff --git a/wlauto/instrumentation/fps/__init__.py b/wlauto/instrumentation/fps/__init__.py index 0e3f12a7..26c06a7c 100644 --- a/wlauto/instrumentation/fps/__init__.py +++ b/wlauto/instrumentation/fps/__init__.py @@ -70,6 +70,7 @@ class FpsInstrument(Instrument): vsync cycle. """ + supported_platforms = ['android'] parameters = [ Parameter('drop_threshold', kind=numeric, default=5, diff --git a/wlauto/workloads/applaunch/__init__.py b/wlauto/workloads/applaunch/__init__.py index 4e2cac14..5599d10f 100644 --- a/wlauto/workloads/applaunch/__init__.py +++ b/wlauto/workloads/applaunch/__init__.py @@ -60,6 +60,7 @@ class ApplaunchWorkload(Workload): Measures the time and energy used in launching an application. """ + supported_platforms = ['android'] parameters = [ Parameter('app', default='browser', allowed_values=['calculator', 'browser', 'calendar'], diff --git a/wlauto/workloads/audio/__init__.py b/wlauto/workloads/audio/__init__.py index 75244e45..a2872046 100644 --- a/wlauto/workloads/audio/__init__.py +++ b/wlauto/workloads/audio/__init__.py @@ -33,6 +33,7 @@ class Audio(Workload): it plays Canon_in_D_Pieano.mp3 for 30 seconds. """ + supported_platforms = ['android'] parameters = [ Parameter('duration', kind=int, default=30, diff --git a/wlauto/workloads/dex2oat/__init__.py b/wlauto/workloads/dex2oat/__init__.py index 440ed5b3..4d1955bb 100644 --- a/wlauto/workloads/dex2oat/__init__.py +++ b/wlauto/workloads/dex2oat/__init__.py @@ -39,6 +39,7 @@ class Dex2oatBenchmark(Workload): """ + supported_platforms = ['android'] command_template = 'dex2oat --dex-file={} --oat-file={} --instruction-set={} --dump-timing' run_timeout = 5 * 60 diff --git a/wlauto/workloads/homescreen/__init__.py b/wlauto/workloads/homescreen/__init__.py index 729054be..737d435b 100644 --- a/wlauto/workloads/homescreen/__init__.py +++ b/wlauto/workloads/homescreen/__init__.py @@ -28,6 +28,7 @@ class HomeScreen(Workload): specified duration. """ + supported_platforms = ['android'] parameters = [ Parameter('duration', kind=int, default=20, diff --git a/wlauto/workloads/power_loadtest/__init__.py b/wlauto/workloads/power_loadtest/__init__.py index f964761e..f95bf5bf 100644 --- a/wlauto/workloads/power_loadtest/__init__.py +++ b/wlauto/workloads/power_loadtest/__init__.py @@ -42,6 +42,7 @@ class PowerLoadtest(Workload): See: https://www.chromium.org/chromium-os/testing/power-testing ''' + supported_platforms = ['chromeos'] parameters = [ Parameter('board', default=os.getenv('BOARD'), diff --git a/wlauto/workloads/video/__init__.py b/wlauto/workloads/video/__init__.py index 711a7b82..75696852 100644 --- a/wlauto/workloads/video/__init__.py +++ b/wlauto/workloads/video/__init__.py @@ -45,6 +45,7 @@ class VideoWorkload(Workload): .. _Big Buck Bunny: http://www.bigbuckbunny.org/ """ + supported_platforms = ['android'] parameters = [ Parameter('play_duration', kind=int, default=20,