mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-07 13:41:24 +00:00
Merge pull request #271 from marcbonnici/revent
ReventWorkload fixes and enhancements
This commit is contained in:
commit
4213e8e7d1
@ -246,7 +246,7 @@ definition.yaml file
|
|||||||
This defines each state of the workload and lists which templates are expected
|
This defines each state of the workload and lists which templates are expected
|
||||||
to be found and how many are required to be detected for a conclusive match. It
|
to be found and how many are required to be detected for a conclusive match. It
|
||||||
also defines the expected state in each workload phase where a state detection
|
also defines the expected state in each workload phase where a state detection
|
||||||
is run (currently those are setupComplete and runComplete).
|
is run (currently those are setup_complete and run_complete).
|
||||||
|
|
||||||
Templates are picture elements to be matched in a screenshot. Each template
|
Templates are picture elements to be matched in a screenshot. Each template
|
||||||
mentioned in the definition file should be placed as a file with the same name
|
mentioned in the definition file should be placed as a file with the same name
|
||||||
@ -260,7 +260,7 @@ understand the format. Note that more than just two states (for the afterSetup
|
|||||||
and afterRun phase) can be defined and this helps track the cause of errors in
|
and afterRun phase) can be defined and this helps track the cause of errors in
|
||||||
case an unexpected state is encountered.
|
case an unexpected state is encountered.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: yaml
|
||||||
|
|
||||||
workload_name: angrybirds
|
workload_name: angrybirds
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ class RecordCommand(ReventCommand):
|
|||||||
self.parser.add_argument('-p', '--package', help='Package to launch before recording')
|
self.parser.add_argument('-p', '--package', help='Package to launch before recording')
|
||||||
self.parser.add_argument('-C', '--clear', help='Clear app cache before launching it',
|
self.parser.add_argument('-C', '--clear', help='Clear app cache before launching it',
|
||||||
action="store_true")
|
action="store_true")
|
||||||
|
self.parser.add_argument('-S', '--capture-screen', help='Record a screen capture after recording',
|
||||||
|
action="store_true")
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
if args.device:
|
if args.device:
|
||||||
@ -128,6 +130,9 @@ class RecordCommand(ReventCommand):
|
|||||||
|
|
||||||
self.logger.info("Press Enter when you have finished recording...")
|
self.logger.info("Press Enter when you have finished recording...")
|
||||||
raw_input("")
|
raw_input("")
|
||||||
|
if args.screencapture:
|
||||||
|
self.logger.info("Recording screen capture")
|
||||||
|
self.device.capture_screen(args.output or os.getcwdu())
|
||||||
self.device.killall("revent", signal.SIGTERM)
|
self.device.killall("revent", signal.SIGTERM)
|
||||||
self.logger.info("Waiting for revent to finish")
|
self.logger.info("Waiting for revent to finish")
|
||||||
while self.device.get_pids_of("revent"):
|
while self.device.get_pids_of("revent"):
|
||||||
|
@ -240,7 +240,7 @@ class ApkWorkload(Workload):
|
|||||||
context.add_classifiers(apk_version=self.apk_version)
|
context.add_classifiers(apk_version=self.apk_version)
|
||||||
|
|
||||||
if self.launch_main:
|
if self.launch_main:
|
||||||
self.launch_package() # launch default activity without intent data
|
self.launch_package() # launch default activity without intent data
|
||||||
self.device.execute('am kill-all') # kill all *background* activities
|
self.device.execute('am kill-all') # kill all *background* activities
|
||||||
self.device.clear_logcat()
|
self.device.clear_logcat()
|
||||||
|
|
||||||
@ -439,6 +439,7 @@ AndroidBenchmark = ApkWorkload # backward compatibility
|
|||||||
|
|
||||||
|
|
||||||
class ReventWorkload(Workload):
|
class ReventWorkload(Workload):
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
|
||||||
def __init__(self, device, _call_super=True, **kwargs):
|
def __init__(self, device, _call_super=True, **kwargs):
|
||||||
if _call_super:
|
if _call_super:
|
||||||
@ -452,7 +453,9 @@ class ReventWorkload(Workload):
|
|||||||
self.on_device_setup_revent = None
|
self.on_device_setup_revent = None
|
||||||
self.on_device_run_revent = None
|
self.on_device_run_revent = None
|
||||||
self.statedefs_dir = None
|
self.statedefs_dir = None
|
||||||
self.check_states = None
|
|
||||||
|
if self.check_states:
|
||||||
|
state_detector.check_match_state_dependencies()
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
self.revent_setup_file = context.resolver.get(ReventFile(self, 'setup'))
|
self.revent_setup_file = context.resolver.get(ReventFile(self, 'setup'))
|
||||||
|
@ -40,6 +40,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
imutils = None
|
imutils = None
|
||||||
|
|
||||||
|
from wlauto.exceptions import HostError
|
||||||
|
|
||||||
|
|
||||||
class StateDefinitionError(RuntimeError):
|
class StateDefinitionError(RuntimeError):
|
||||||
pass
|
pass
|
||||||
@ -58,10 +60,14 @@ def auto_canny(image, sigma=0.33):
|
|||||||
return edged
|
return edged
|
||||||
|
|
||||||
|
|
||||||
|
def check_match_state_dependencies():
|
||||||
|
if np is None or cv2 is None or imutils is None:
|
||||||
|
raise HostError("State detection requires numpy, opencv (cv2) and imutils.")
|
||||||
|
|
||||||
|
|
||||||
def match_state(screenshot_file, defpath, state_definitions): # pylint: disable=too-many-locals
|
def match_state(screenshot_file, defpath, state_definitions): # pylint: disable=too-many-locals
|
||||||
# check dependencies
|
# check dependencies
|
||||||
if np is None or cv2 is None or imutils is None:
|
check_match_state_dependencies()
|
||||||
raise RuntimeError("State detection requires numpy, opencv (cv2) and imutils.")
|
|
||||||
|
|
||||||
# check if file exists, then load screenshot into opencv and create edge map
|
# check if file exists, then load screenshot into opencv and create edge map
|
||||||
if not os.path.isfile(screenshot_file):
|
if not os.path.isfile(screenshot_file):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user