From 1108c5701e023af4b632e5a96aa73c2a5427e241 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Thu, 20 Jun 2019 11:43:33 +0100 Subject: [PATCH] workloads: Update to better utilize `cleanup_assets` and `uninstall` Update the workload classes to attempt and standardize the use of the `cleanup_assets` parameter and the newly added `uninstall` parameter --- wa/framework/workload.py | 10 ++++++---- wa/workloads/dhrystone/__init__.py | 3 ++- wa/workloads/hackbench/__init__.py | 6 ++++-- wa/workloads/hwuitest/__init__.py | 2 +- wa/workloads/lmbench/__init__.py | 3 ++- wa/workloads/meabo/__init__.py | 3 ++- wa/workloads/memcpy/__init__.py | 3 ++- wa/workloads/openssl/__init__.py | 2 +- wa/workloads/rt_app/__init__.py | 9 +++++---- wa/workloads/shellscript/__init__.py | 3 ++- wa/workloads/stress_ng/__init__.py | 3 ++- wa/workloads/sysbench/__init__.py | 6 ++++-- 12 files changed, 33 insertions(+), 20 deletions(-) diff --git a/wa/framework/workload.py b/wa/framework/workload.py index e9cabeb2..13898c2f 100644 --- a/wa/framework/workload.py +++ b/wa/framework/workload.py @@ -358,7 +358,8 @@ class ApkUIWorkload(ApkWorkload): @once_per_instance def finalize(self, context): super(ApkUIWorkload, self).finalize(context) - self.gui.remove() + if self.cleanup_assets: + self.gui.remove() class ApkUiautoWorkload(ApkUIWorkload): @@ -438,7 +439,8 @@ class UIWorkload(Workload): @once_per_instance def finalize(self, context): super(UIWorkload, self).finalize(context) - self.gui.remove() + if self.cleanup_assets: + self.gui.remove() class UiautoWorkload(UIWorkload): @@ -634,12 +636,12 @@ class ReventGUI(object): if self.revent_teardown_file: self.revent_recorder.replay(self.on_target_teardown_revent, timeout=self.teardown_timeout) + + def remove(self): self.target.remove(self.on_target_setup_revent) self.target.remove(self.on_target_run_revent) self.target.remove(self.on_target_extract_results_revent) self.target.remove(self.on_target_teardown_revent) - - def remove(self): self.revent_recorder.remove() def _check_revent_files(self): diff --git a/wa/workloads/dhrystone/__init__.py b/wa/workloads/dhrystone/__init__.py index 3c8865ff..89aa9090 100644 --- a/wa/workloads/dhrystone/__init__.py +++ b/wa/workloads/dhrystone/__init__.py @@ -153,7 +153,8 @@ class Dhrystone(Workload): @once def finalize(self, context): - self.target.uninstall('dhrystone') + if self.uninstall: + self.target.uninstall('dhrystone') def validate(self): if self.mloops and self.duration: # pylint: disable=E0203 diff --git a/wa/workloads/hackbench/__init__.py b/wa/workloads/hackbench/__init__.py index 19020f48..b0f8bb92 100644 --- a/wa/workloads/hackbench/__init__.py +++ b/wa/workloads/hackbench/__init__.py @@ -90,8 +90,10 @@ class Hackbench(Workload): context.add_metric(label, float(match.group(1)), units) def teardown(self, context): - self.target.execute('rm -f {}'.format(self.target_output_file)) + if self.cleanup_assets: + self.target.execute('rm -f {}'.format(self.target_output_file)) @once def finalize(self, context): - self.target.uninstall(self.binary_name) + if self.uninstall: + self.target.uninstall(self.binary_name) diff --git a/wa/workloads/hwuitest/__init__.py b/wa/workloads/hwuitest/__init__.py index bb27289a..3bd304d5 100644 --- a/wa/workloads/hwuitest/__init__.py +++ b/wa/workloads/hwuitest/__init__.py @@ -120,5 +120,5 @@ class HWUITest(Workload): @once def finalize(self, context): - if self.target_exe: + if self.target_exe and self.uninstall: self.target.uninstall(self.target_exe) diff --git a/wa/workloads/lmbench/__init__.py b/wa/workloads/lmbench/__init__.py index 81d92c91..43003d23 100755 --- a/wa/workloads/lmbench/__init__.py +++ b/wa/workloads/lmbench/__init__.py @@ -117,7 +117,8 @@ class Lmbench(Workload): context.add_artifact('lmbench-result', "lmbench.output", kind='raw') def teardown(self, context): - self.target.uninstall(self.test) + if self.uninstall: + self.target.uninstall(self.test) # # Test setup routines diff --git a/wa/workloads/meabo/__init__.py b/wa/workloads/meabo/__init__.py index 5fdb751d..899fcfe3 100644 --- a/wa/workloads/meabo/__init__.py +++ b/wa/workloads/meabo/__init__.py @@ -286,7 +286,8 @@ class Meabo(Workload): int(match.group('duration')), units="ns") def finalize(self, context): - self._uninstall_executable() + if self.uninstall: + self._uninstall_executable() def _build_command(self): self.command = self.target_exe diff --git a/wa/workloads/memcpy/__init__.py b/wa/workloads/memcpy/__init__.py index 47cc1133..18c526e9 100644 --- a/wa/workloads/memcpy/__init__.py +++ b/wa/workloads/memcpy/__init__.py @@ -86,4 +86,5 @@ class Memcpy(Workload): @once def finalize(self, context): - self.target.uninstall('memcpy') + if self.uninstall: + self.target.uninstall('memcpy') diff --git a/wa/workloads/openssl/__init__.py b/wa/workloads/openssl/__init__.py index 8de02ee9..b573e639 100644 --- a/wa/workloads/openssl/__init__.py +++ b/wa/workloads/openssl/__init__.py @@ -156,5 +156,5 @@ class Openssl(Workload): @once def finalize(self, context): - if not self.use_system_binary: + if not self.use_system_binary and self.uninstall: self.target.uninstall('openssl') diff --git a/wa/workloads/rt_app/__init__.py b/wa/workloads/rt_app/__init__.py index 1b426e50..00aadef9 100644 --- a/wa/workloads/rt_app/__init__.py +++ b/wa/workloads/rt_app/__init__.py @@ -130,8 +130,8 @@ class RtApp(Workload): '''), Parameter('cpus', kind=cpu_mask, default=0, aliases=['taskset_mask'], description='Constrain execution to specific CPUs.'), - Parameter('uninstall_on_exit', kind=bool, default=False, - description=""" + Parameter('uninstall', aliases=['uninstall_on_exit'], kind=bool, default=False, + override=True, description=""" If set to ``True``, rt-app binary will be uninstalled from the device at the end of the run. """), @@ -213,9 +213,10 @@ class RtApp(Workload): @once def finalize(self, context): - if self.uninstall_on_exit: + if self.uninstall: self.target.uninstall(self.target_binary) - self.target.execute('rm -rf {}'.format(self.target_working_directory)) + if self.cleanup_assets: + self.target.execute('rm -rf {}'.format(self.target_working_directory)) def _deploy_rt_app_binary_if_necessary(self): # called from initialize() so gets invoked once per run diff --git a/wa/workloads/shellscript/__init__.py b/wa/workloads/shellscript/__init__.py index becd26a3..561369d4 100644 --- a/wa/workloads/shellscript/__init__.py +++ b/wa/workloads/shellscript/__init__.py @@ -67,4 +67,5 @@ class ShellScript(Workload): wfh.write(self.output) def teardown(self, context): - self.target.remove(self.on_target_script_file) + if self.cleanup_assets: + self.target.remove(self.on_target_script_file) diff --git a/wa/workloads/stress_ng/__init__.py b/wa/workloads/stress_ng/__init__.py index c4e0df61..9cf1a7d7 100644 --- a/wa/workloads/stress_ng/__init__.py +++ b/wa/workloads/stress_ng/__init__.py @@ -131,4 +131,5 @@ class StressNg(Workload): @once def finalize(self, context): - self.target.uninstall('stress-ng') + if self.uninstall: + self.target.uninstall('stress-ng') diff --git a/wa/workloads/sysbench/__init__.py b/wa/workloads/sysbench/__init__.py index d430a9da..ac1718a3 100644 --- a/wa/workloads/sysbench/__init__.py +++ b/wa/workloads/sysbench/__init__.py @@ -147,11 +147,13 @@ class Sysbench(Workload): extract_threads_fairness_metric('execution time', next(fh), context.output) def teardown(self, context): - self.target.remove(self.target_results_file) + if self.cleanup_assets: + self.target.remove(self.target_results_file) @once def finalize(self, context): - self.target.uninstall('sysbench') + if self.uninstall: + self.target.uninstall('sysbench') def _build_command(self, **parameters): param_strings = ['--{}={}'.format(k.replace('_', '-'), v)