mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-07 13:41:24 +00:00
idle: updated to work on Linux devices.
This commit is contained in:
parent
950f0851bf
commit
a4bff161aa
@ -18,14 +18,17 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from wlauto import Workload, Parameter
|
from wlauto import Workload, Parameter
|
||||||
from wlauto.exceptions import WorkloadError
|
from wlauto.exceptions import WorkloadError, ConfigError
|
||||||
|
|
||||||
|
|
||||||
class IdleWorkload(Workload):
|
class IdleWorkload(Workload):
|
||||||
|
|
||||||
name = 'idle'
|
name = 'idle'
|
||||||
description = """
|
description = """
|
||||||
Stop Android and sleep for the specified duration before restarting it.
|
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.
|
.. note:: This workload requires the device to be rooted.
|
||||||
|
|
||||||
@ -34,19 +37,29 @@ class IdleWorkload(Workload):
|
|||||||
parameters = [
|
parameters = [
|
||||||
Parameter('duration', kind=int, default=20,
|
Parameter('duration', kind=int, default=20,
|
||||||
description='Specifies the duration, in seconds, of this workload.'),
|
description='Specifies the duration, in seconds, of this workload.'),
|
||||||
|
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 setup(self, context):
|
def setup(self, context):
|
||||||
|
if self.stop_android:
|
||||||
|
if not self.device.platform == 'android':
|
||||||
|
raise ConfigError('stop_android can only be set for Android devices')
|
||||||
if not self.device.is_rooted:
|
if not self.device.is_rooted:
|
||||||
raise WorkloadError('Idle workload requires the device to be rooted.')
|
raise WorkloadError('Idle workload requires the device to be rooted in order to stop Android.')
|
||||||
|
|
||||||
def run(self, context):
|
def run(self, context):
|
||||||
self.device.execute('stop && sleep {} && start'.format(self.duration), as_root=True)
|
self.logger.debug('idling...')
|
||||||
|
if self.stop_android:
|
||||||
def update_result(self, context):
|
timeout = self.duration + 10
|
||||||
pass
|
self.device.execute('stop && sleep {} && start'.format(self.duration),
|
||||||
|
timeout=timeout, as_root=True)
|
||||||
|
else:
|
||||||
|
time.sleep(self.duration)
|
||||||
|
|
||||||
def teardown(self, context):
|
def teardown(self, context):
|
||||||
|
if self.stop_android:
|
||||||
self.logger.debug('Waiting for Android restart to complete...')
|
self.logger.debug('Waiting for Android restart to complete...')
|
||||||
# Wait for the boot animation to start and then to finish.
|
# Wait for the boot animation to start and then to finish.
|
||||||
while self.device.execute('getprop init.svc.bootanim').strip() == 'stopped':
|
while self.device.execute('getprop init.svc.bootanim').strip() == 'stopped':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user