1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

framework/workload: Implement Workload.requires_network attribute

This commit is contained in:
Brendan Jackman 2017-10-18 11:49:52 +01:00
parent 73f863f281
commit 71815e4e1c

View File

@ -50,6 +50,12 @@ class Workload(TargetedPlugin):
prevent this workload from being run accidentally.
"""
requires_network = False
"""
Set this to ``True`` to mark the the workload will fail without a network
connection, this enables it to fail early with a clear message.
"""
def init_resources(self, context):
"""
This method may be used to perform early resource discovery and
@ -77,7 +83,11 @@ class Workload(TargetedPlugin):
This is also the place to perform any on-device checks prior to
attempting to execute the workload.
"""
pass
if self.requires_network and not self.target.is_network_connected():
raise WorkloadError(
'Workload "{}" requires internet. Target does not appear '
'to be connected to the internet.'.format(self.name))
def run(self, context):
"""
@ -193,6 +203,7 @@ class ApkWorkload(Workload):
self.apk.activity)
def setup(self, context):
super(ApkWorkload, self).setup(context)
self.apk.setup(context)
time.sleep(self.loading_time)