1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-26 04:29:25 +00:00

[framework/workload] Add support for jank testing

Jank testing involves using a different library (JankTestBase) that our
testing class needs to extend. Since we already make the base testing
class UiAutomation extend BaseUiAutomation, we cannot use the UiAutomation
class for our tests.

The uiauto_class property is hardcoded to "UiAutomation" though, so this
patch adds a uiauto_jank_class property for the Jank test class.

While at it, we also make the uiauto_runner configurable (currently hardcoded
to the old deprecated android.support version of it) so that our workloads
can pass whatever runner they need to use.

In terms of stages for testing, their current names are the following:

stages = ['setup', 'runWorkload', 'extractResults', 'teardown']

Those won't work for jank tests. For some reason the jank test library wants
to see the testing function name contain or start with a "test" string
pattern on it.

This behavior doesn't seem to be documented, but at least with the current
version of the JankTestBase library we have this restriction.

To make things work despite this restriction, I've added separate jank
test stages that can be provided by the workload. The generic workload
code will use these stages to generate the instrumentation invocation
command, and the provided jank test stages (essentially jank test
functions) will be invoked one by one.

Finally, we make the UiAutomatorGUI's _execute method return the output
of the execution so the workload can freely process and pattern-match
the results, like the UiBenchJankTests workload.
This commit is contained in:
Luis Machado 2024-07-08 10:48:35 +01:00
parent 510b344aa5
commit 18d9f942da

@ -504,13 +504,14 @@ class UiAutomatorGUI(object):
stages = ['setup', 'runWorkload', 'extractResults', 'teardown']
uiauto_runner = 'android.support.test.runner.AndroidJUnitRunner'
def __init__(self, owner, package=None, klass='UiAutomation', timeout=600):
self.owner = owner
self.target = self.owner.target
self.uiauto_package = package
self.uiauto_class = klass
self.uiauto_jank_class = klass
self.uiauto_runner = 'android.support.test.runner.AndroidJUnitRunner'
self.jank_stages = []
self.timeout = timeout
self.logger = logging.getLogger('gui')
self.uiauto_file = None
@ -539,6 +540,16 @@ class UiAutomatorGUI(object):
self.commands[stage] = cmd_template.format(params, class_string,
instrumentation_string)
for stage in self.jank_stages:
class_string = '{}.{}#{}'.format(self.uiauto_package,
self.uiauto_jank_class,
stage)
instrumentation_string = '{}/{}'.format(self.uiauto_package,
self.uiauto_runner)
cmd_template = 'am instrument -w -r{} -e class {} {}'
self.commands[stage] = cmd_template.format(params, class_string,
instrumentation_string)
def deploy(self):
if self.target.package_is_installed(self.uiauto_package):
self.target.uninstall_package(self.uiauto_package)
@ -578,6 +589,7 @@ class UiAutomatorGUI(object):
else:
self.logger.debug(result)
time.sleep(2)
return result
class ReventGUI(object):