mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-02 19:32:34 +01:00
recentfling: script deployment and PID file fixes
- Scripts are now deployed during via install() ensuring that they are executable. - Handle the case where the PID file is delted before getting to process_results. - Exposed the option to not start any apps before flinging via a parameter.
This commit is contained in:
@@ -21,7 +21,7 @@ from collections import defaultdict
|
|||||||
|
|
||||||
from wlauto import Workload, Parameter, File
|
from wlauto import Workload, Parameter, File
|
||||||
from wlauto.utils.types import caseless_string
|
from wlauto.utils.types import caseless_string
|
||||||
from wlauto.exceptions import WorkloadError
|
from wlauto.exceptions import WorkloadError, DeviceError
|
||||||
|
|
||||||
|
|
||||||
class Recentfling(Workload):
|
class Recentfling(Workload):
|
||||||
@@ -32,7 +32,7 @@ class Recentfling(Workload):
|
|||||||
|
|
||||||
For this workload to work, ``recentfling.sh`` and ``defs.sh`` must be placed
|
For this workload to work, ``recentfling.sh`` and ``defs.sh`` must be placed
|
||||||
in ``~/.workload_automation/dependencies/recentfling/``. These can be found
|
in ``~/.workload_automation/dependencies/recentfling/``. These can be found
|
||||||
in the `AOSP Git repository <https://android.googlesource.com/platform/system/extras/+/master/tests/>`_.
|
in the `AOSP Git repository <https://android.googlesource.com/platform/system/extras/+/master/tests/workloads>`_.
|
||||||
|
|
||||||
To change the apps that are opened at the start of the workload you will need
|
To change the apps that are opened at the start of the workload you will need
|
||||||
to modify the ``defs.sh`` file. You will need to add your app to ``dfltAppList``
|
to modify the ``defs.sh`` file. You will need to add your app to ``dfltAppList``
|
||||||
@@ -47,6 +47,12 @@ class Recentfling(Workload):
|
|||||||
parameters = [
|
parameters = [
|
||||||
Parameter('loops', kind=int, default=3,
|
Parameter('loops', kind=int, default=3,
|
||||||
description="The number of test iterations."),
|
description="The number of test iterations."),
|
||||||
|
Parameter('start_apps', kind=bool, default=True,
|
||||||
|
description="""
|
||||||
|
If set to ``False``,no apps will be started before flinging
|
||||||
|
through the recent apps list (in which the assumption is
|
||||||
|
there are already recently started apps in the list.
|
||||||
|
"""),
|
||||||
]
|
]
|
||||||
|
|
||||||
def initialise(self, context): # pylint: disable=no-self-use
|
def initialise(self, context): # pylint: disable=no-self-use
|
||||||
@@ -56,15 +62,18 @@ class Recentfling(Workload):
|
|||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
self.defs_host = context.resolver.get(File(self, "defs.sh"))
|
self.defs_host = context.resolver.get(File(self, "defs.sh"))
|
||||||
|
self.defs_target = self.device.install(self.defs_host)
|
||||||
self.recentfling_host = context.resolver.get(File(self, "recentfling.sh"))
|
self.recentfling_host = context.resolver.get(File(self, "recentfling.sh"))
|
||||||
self.device.push_file(self.recentfling_host, self.device.working_directory)
|
self.recentfling_target = self.device.install(self.recentfling_host)
|
||||||
self.device.push_file(self.defs_host, self.device.working_directory)
|
|
||||||
self._kill_recentfling()
|
self._kill_recentfling()
|
||||||
self.device.ensure_screen_is_on()
|
self.device.ensure_screen_is_on()
|
||||||
|
|
||||||
def run(self, context):
|
def run(self, context):
|
||||||
cmd = "echo $$>{dir}/pidfile; exec {dir}/recentfling.sh -i {}; rm {dir}/pidfile"
|
args = '-i {} '.format(self.loops)
|
||||||
cmd = cmd.format(self.loops, dir=self.device.working_directory)
|
if not self.start_apps:
|
||||||
|
args += '-N '
|
||||||
|
cmd = "echo $$>{dir}/pidfile; cd {bindir}; exec ./recentfling.sh {args}; rm {dir}/pidfile"
|
||||||
|
cmd = cmd.format(args=args, dir=self.device.working_directory, bindir=self.device.binaries_directory)
|
||||||
try:
|
try:
|
||||||
self.output = self.device.execute(cmd, timeout=120)
|
self.output = self.device.execute(cmd, timeout=120)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@@ -89,12 +98,14 @@ class Recentfling(Workload):
|
|||||||
classifiers={"loop": count or "Average"})
|
classifiers={"loop": count or "Average"})
|
||||||
|
|
||||||
def teardown(self, context):
|
def teardown(self, context):
|
||||||
self.device.delete_file(self.device.path.join(self.device.working_directory,
|
self.device.uninstall(self.recentfling_target)
|
||||||
"recentfling.sh"))
|
self.device.uninstall(self.defs_target)
|
||||||
self.device.delete_file(self.device.path.join(self.device.working_directory,
|
|
||||||
"defs.sh"))
|
|
||||||
|
|
||||||
def _kill_recentfling(self):
|
def _kill_recentfling(self):
|
||||||
pid = self.device.execute('cat {}/pidfile'.format(self.device.working_directory))
|
command = 'cat {}/pidfile'.format(self.device.working_directory)
|
||||||
if pid:
|
try:
|
||||||
self.device.kill(pid.strip(), signal='SIGKILL')
|
pid = self.device.execute(command)
|
||||||
|
if pid.strip():
|
||||||
|
self.device.kill(pid.strip(), signal='SIGKILL')
|
||||||
|
except DeviceError:
|
||||||
|
pass # may have already been deleted
|
||||||
|
Reference in New Issue
Block a user