mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-13 22:28:36 +00:00
Add workload validate step to check dependencies
Check that dependent files for the workload are present in the dependencies folder before starting the workload. Move cleanup of dependent files to finalize method.
This commit is contained in:
parent
32dec69742
commit
13df3cff90
@ -20,6 +20,7 @@ import time
|
||||
|
||||
from wlauto import AndroidUiAutoBenchmark, Parameter
|
||||
from wlauto.exceptions import DeviceError
|
||||
from wlauto.exceptions import NotFoundError
|
||||
|
||||
__version__ = '0.1.0'
|
||||
|
||||
@ -83,12 +84,17 @@ class Gmail(AndroidUiAutoBenchmark):
|
||||
if not self.device.is_wifi_connected():
|
||||
raise DeviceError('Wifi is not connected for device {}'.format(self.device.name))
|
||||
|
||||
self.storage_dir = self.device.path.join(self.device.working_directory)
|
||||
# Check for workload dependencies before proceeding
|
||||
jpeg_files = [entry for entry in os.listdir(self.dependencies_directory) if entry.endswith(".jpg")]
|
||||
|
||||
for file in os.listdir(self.dependencies_directory):
|
||||
if file.endswith(".jpg"):
|
||||
self.device.push_file(os.path.join(self.dependencies_directory, file),
|
||||
os.path.join(self.storage_dir, file), timeout=300)
|
||||
if len(jpeg_files) < 5:
|
||||
raise NotFoundError("This workload requires a minimum of five {} files in {}".format('jpg',
|
||||
self.dependencies_directory))
|
||||
else:
|
||||
for entry in jpeg_files:
|
||||
self.device.push_file(os.path.join(self.dependencies_directory, entry),
|
||||
os.path.join(self.device.working_directory, entry),
|
||||
timeout=300)
|
||||
|
||||
# Force a re-index of the mediaserver cache to pick up new files
|
||||
self.device.execute('am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard')
|
||||
@ -114,17 +120,17 @@ class Gmail(AndroidUiAutoBenchmark):
|
||||
def teardown(self, context):
|
||||
super(Gmail, self).teardown(context)
|
||||
|
||||
for file in self.device.listdir(self.device.working_directory):
|
||||
if file.endswith(".log"):
|
||||
self.device.pull_file(os.path.join(self.device.working_directory, file), context.output_directory)
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, file))
|
||||
for entry in self.device.listdir(self.device.working_directory):
|
||||
if entry.endswith(".log"):
|
||||
self.device.pull_file(os.path.join(self.device.working_directory, entry), context.output_directory)
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, entry))
|
||||
|
||||
def finalize(self, context):
|
||||
super(Gmail, self).finalize(context)
|
||||
|
||||
for file in self.device.listdir(self.device.working_directory):
|
||||
if file.endswith(".jpg"):
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, file))
|
||||
for entry in self.device.listdir(self.device.working_directory):
|
||||
if entry.endswith(".jpg"):
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, entry))
|
||||
|
||||
# Force a re-index of the mediaserver cache to pick up new files
|
||||
self.device.execute('am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard')
|
||||
|
@ -18,6 +18,7 @@ import re
|
||||
|
||||
from wlauto import AndroidUiAutoBenchmark, Parameter
|
||||
from wlauto.exceptions import DeviceError
|
||||
from wlauto.exceptions import NotFoundError
|
||||
|
||||
__version__ = '0.1.0'
|
||||
|
||||
@ -65,7 +66,6 @@ class Googlephotos(AndroidUiAutoBenchmark):
|
||||
]
|
||||
|
||||
instrumentation_log = ''.join([name, '_instrumentation.log'])
|
||||
file_prefix = 'wa_test_'
|
||||
|
||||
def __init__(self, device, **kwargs):
|
||||
super(Googlephotos, self).__init__(device, **kwargs)
|
||||
@ -84,11 +84,16 @@ class Googlephotos(AndroidUiAutoBenchmark):
|
||||
if not self.device.is_wifi_connected():
|
||||
raise DeviceError('Wifi is not connected for device {}'.format(self.device.name))
|
||||
|
||||
for entry in os.listdir(self.dependencies_directory):
|
||||
wa_file = ''.join([self.file_prefix, entry])
|
||||
if entry.endswith(".jpg"):
|
||||
# Check for workload dependencies before proceeding
|
||||
jpeg_files = [entry for entry in os.listdir(self.dependencies_directory) if entry.endswith(".jpg")]
|
||||
|
||||
if len(jpeg_files) < 4:
|
||||
raise NotFoundError("This workload requires a minimum of four {} files in {}".format('jpg',
|
||||
self.dependencies_directory))
|
||||
else:
|
||||
for entry in jpeg_files:
|
||||
self.device.push_file(os.path.join(self.dependencies_directory, entry),
|
||||
os.path.join(self.device.working_directory, wa_file),
|
||||
os.path.join(self.device.working_directory, entry),
|
||||
timeout=300)
|
||||
|
||||
# Force a re-index of the mediaserver cache to pick up new files
|
||||
@ -126,7 +131,7 @@ class Googlephotos(AndroidUiAutoBenchmark):
|
||||
super(Googlephotos, self).finalize(context)
|
||||
|
||||
for entry in self.device.listdir(self.device.working_directory):
|
||||
if entry.startswith(self.file_prefix) and entry.endswith(".jpg"):
|
||||
if entry.endswith(".jpg"):
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, entry))
|
||||
|
||||
# Force a re-index of the mediaserver cache to removed cached files
|
||||
|
@ -20,6 +20,7 @@ import time
|
||||
|
||||
from wlauto import AndroidUiAutoBenchmark, Parameter
|
||||
from wlauto.exceptions import DeviceError
|
||||
from wlauto.exceptions import NotFoundError
|
||||
|
||||
__version__ = '0.1.0'
|
||||
|
||||
@ -86,16 +87,19 @@ class Reader(AndroidUiAutoBenchmark):
|
||||
if not self.device.is_wifi_connected():
|
||||
raise DeviceError('Wifi is not connected for device {}'.format(self.device.name))
|
||||
|
||||
def setup(self, context):
|
||||
super(Reader, self).setup(context)
|
||||
|
||||
self.reader_local_dir = self.device.path.join(self.device.external_storage_directory,
|
||||
'Android/data/com.adobe.reader/files/')
|
||||
|
||||
for file in os.listdir(self.dependencies_directory):
|
||||
if file.endswith(".pdf"):
|
||||
self.device.push_file(os.path.join(self.dependencies_directory, file),
|
||||
os.path.join(self.reader_local_dir, file), timeout=300)
|
||||
# Check for workload dependencies before proceeding
|
||||
pdf_files = [entry for entry in os.listdir(self.dependencies_directory) if entry.endswith(".pdf")]
|
||||
|
||||
if not len(pdf_files):
|
||||
raise NotFoundError("Cannot find {} file(s) in {}".format('pdf', self.dependencies_directory))
|
||||
else:
|
||||
for entry in pdf_files:
|
||||
self.device.push_file(os.path.join(self.dependencies_directory, entry),
|
||||
os.path.join(self.reader_local_dir, entry),
|
||||
timeout=300)
|
||||
|
||||
def update_result(self, context):
|
||||
super(Reader, self).update_result(context)
|
||||
@ -117,11 +121,15 @@ class Reader(AndroidUiAutoBenchmark):
|
||||
|
||||
def teardown(self, context):
|
||||
super(Reader, self).teardown(context)
|
||||
for file in self.device.listdir(self.reader_local_dir):
|
||||
if file.endswith(".pdf"):
|
||||
self.device.delete_file(os.path.join(self.reader_local_dir, file))
|
||||
|
||||
for file in self.device.listdir(self.device.working_directory):
|
||||
if file.endswith(".log"):
|
||||
self.device.pull_file(os.path.join(self.device.working_directory, file), context.output_directory)
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, file))
|
||||
for entry in self.device.listdir(self.device.working_directory):
|
||||
if entry.endswith(".log"):
|
||||
self.device.pull_file(os.path.join(self.device.working_directory, entry), context.output_directory)
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, entry))
|
||||
|
||||
def finalize(self, context):
|
||||
super(Reader, self).finalize(context)
|
||||
|
||||
for entry in self.device.listdir(self.reader_local_dir):
|
||||
if entry.endswith(".pdf"):
|
||||
self.device.delete_file(os.path.join(self.reader_local_dir, entry))
|
||||
|
Loading…
x
Reference in New Issue
Block a user