From 04253b28c24e80750fcad66721ffda69669a0e64 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Fri, 12 May 2017 11:11:40 +0100 Subject: [PATCH 1/2] Fix typo. --- wa/framework/execution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wa/framework/execution.py b/wa/framework/execution.py index 9d4eb8f9..69343b00 100644 --- a/wa/framework/execution.py +++ b/wa/framework/execution.py @@ -253,7 +253,7 @@ class Executor(object): config.run_config.device_config) output.write_target_info(self.target_manager.get_target_info()) - self.logger.info('Initializing execution conetext') + self.logger.info('Initializing execution context') context = ExecutionContext(config_manager, self.target_manager, output) self.logger.info('Generating jobs') From e7290c3f148068c6491b2ba32f5d8fa16188bef1 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Fri, 12 May 2017 11:58:28 +0100 Subject: [PATCH 2/2] idle: Add idle workload. Added a workload that idles on target. For Android targets, there are options for turning off the screen and/or Android services while idling. --- wa/workloads/idle.py | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 wa/workloads/idle.py diff --git a/wa/workloads/idle.py b/wa/workloads/idle.py new file mode 100644 index 00000000..88c3bdab --- /dev/null +++ b/wa/workloads/idle.py @@ -0,0 +1,91 @@ +# Copyright 2014-2015 ARM Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# pylint: disable=E1101 + +from wa import Workload, Parameter, WorkloadError, ConfigError + + +class IdleWorkload(Workload): + + name = 'idle' + description = """ + Do nothing for the specified duration. + + On android devices, this may optionally stop the Android run time, if + ``stop_android`` is set to ``True``. + + .. note:: This workload requires the device to be rooted. + + """ + + parameters = [ + Parameter('duration', kind=int, default=20, + description=''' + Specifies the duration, in seconds, of this workload. + '''), + Parameter('screen_off', kind=bool, default=False, + description=''' + Ensure that the screen is off before idling. + + .. note:: Make sure screen lock is disabled on the target! + + '''), + Parameter('stop_android', kind=bool, default=False, + description=''' + Specifies whether the Android run time should be stopped. + (Can be set only for Android devices). + '''), + ] + + def initialize(self, context): + self.old_screen_state = None + if self.target.os == 'android': + if self.stop_android and not self.target.is_rooted: + msg = 'Idle workload requires the device to be rooted in order to stop Android.' + raise WorkloadError(msg) + else: + if self.stop_android or self.screen_off: + msg = 'stop_android/screen_off can only be set for Android devices' + raise ConfigError(msg) + + def setup(self, context): + if self.target.os == 'android': + if self.screen_off: + self.old_screen_state = self.target.is_screen_on() + self.target.ensure_screen_is_on() + self.target.homescreen() + if self.screen_off: + self.target.ensure_screen_is_off() + + def run(self, context): + self.logger.debug('idling...') + if self.stop_android: + timeout = self.duration + 10 + self.target.execute('stop && sleep {} && start'.format(self.duration), + timeout=timeout, as_root=True) + else: + self.target.sleep(self.duration) + + def teardown(self, context): + if self.stop_android: + self.logger.debug('Waiting for Android restart to complete...') + # Wait for the boot animation to start and then to finish. + while self.target.getprop('init.svc.bootanim') == 'stopped': + self.target.sleep(0.2) + while self.target.getprop('init.svc.bootanim') == 'running': + self.target.sleep(1) + if self.screen_off and self.old_screen_state: + self.target.ensure_screen_is_on()