Loading testing/mozbase/mozscreenshot/mozscreenshot/__init__.py +5 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ def printstatus(name, returncode): print("TEST-INFO | %s: %s" % (name, strstatus(returncode))) def dump_screen(utilityPath, log): def dump_screen(utilityPath, log, prefix='mozilla-test-fail-screenshot_'): """dumps a screenshot of the entire screen to a directory specified by the MOZ_UPLOAD_DIR environment variable. Loading Loading @@ -52,7 +52,7 @@ def dump_screen(utilityPath, log): # Run the capture try: tmpfd, imgfilename = tempfile.mkstemp( prefix='mozilla-test-fail-screenshot_', prefix=prefix, suffix='.png', dir=parent_dir ) os.close(tmpfd) Loading @@ -68,7 +68,7 @@ def dump_screen(utilityPath, log): % (utility[0], err.strerror)) def dump_device_screen(device, log): def dump_device_screen(device, log, prefix='mozilla-test-fail-screenshot_'): """dumps a screenshot of a real device's entire screen to a directory specified by the MOZ_UPLOAD_DIR environment variable. Cloned from mozscreenshot.dump_screen. Loading @@ -95,8 +95,8 @@ def dump_device_screen(device, log): # We can use mktemp on real devices since we do not test on # real devices older than Android 6.0. Note we must create the # file without an extension due to limitations in mktemp. filename = device.shell_output('mktemp -p %s mozilla-test-fail-screenshot_XXXXXX' % device.test_root) filename = device.shell_output('mktemp -p %s %sXXXXXX' % (device.test_root, prefix)) pngfilename = filename + '.png' device.mv(filename, pngfilename) if is_structured_log: Loading testing/mozharness/configs/android/android_common.py +4 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,10 @@ config = { "minidump_stackwalk_path": "/usr/local/bin/linux64-minidump_stackwalk", "marionette_address": "localhost:2828", "marionette_test_manifest": "unit-tests.ini", # To take device screenshots at timed intervals (each time in seconds, relative # to the start of the run-tests step) specify screenshot_times. For example, to # take 4 screenshots at one minute intervals you could specify: # "screenshot_times": [60, 120, 180, 240], "suite_definitions": { "mochitest": { Loading testing/mozharness/mozharness/mozilla/testing/android.py +29 −5 Original line number Diff line number Diff line Loading @@ -13,8 +13,9 @@ import signal import subprocess import time import tempfile from threading import Timer from mozharness.mozilla.automation import TBPL_RETRY, EXIT_STATUS_DICT from mozharness.base.script import PostScriptAction from mozharness.base.script import PreScriptAction, PostScriptAction class AndroidMixin(object): Loading Loading @@ -194,7 +195,7 @@ class AndroidMixin(object): def _verify_emulator_and_restart_on_fail(self): emulator_ok = self._verify_emulator() if not emulator_ok: self.device_screenshot() self.device_screenshot("screenshot-emulator-start") self.kill_processes(self.config["emulator_process_name"]) subprocess.check_call(['ps', '-ef']) # remove emulator tmp files Loading Loading @@ -335,10 +336,12 @@ class AndroidMixin(object): def shell_output(self, cmd): return self.device.shell_output(cmd, timeout=30) def device_screenshot(self): def device_screenshot(self, prefix): """ On emulator, save a screenshot of the entire screen to the upload directory; otherwise, save a screenshot of the device to the upload directory. :param prefix specifies a filename prefix for the screenshot """ from mozscreenshot import dump_screen, dump_device_screen reset_dir = False Loading @@ -347,9 +350,9 @@ class AndroidMixin(object): os.environ["MOZ_UPLOAD_DIR"] = dirs['abs_blob_upload_dir'] reset_dir = True if self.is_emulator: dump_screen(self.xre_path, self) dump_screen(self.xre_path, self, prefix=prefix) else: dump_device_screen(self.device, self) dump_device_screen(self.device, self, prefix=prefix) if reset_dir: del os.environ["MOZ_UPLOAD_DIR"] Loading Loading @@ -494,6 +497,25 @@ class AndroidMixin(object): # Get a post-boot device process list for diagnostics self.info(self.shell_output('ps')) @PreScriptAction('run-tests') def timed_screenshots(self, action, success=None): """ If configured, start screenshot timers. """ if not self.is_android: return def take_screenshot(seconds): self.device_screenshot("screenshot-%ss-" % str(seconds)) self.info("timed (%ss) screenshot complete" % str(seconds)) self.timers = [] for seconds in self.config.get("screenshot_times", []): self.info("screenshot requested %s seconds from now" % str(seconds)) t = Timer(int(seconds), take_screenshot, [seconds]) t.start() self.timers.append(t) @PostScriptAction('run-tests') def stop_device(self, action, success=None): """ Loading @@ -502,6 +524,8 @@ class AndroidMixin(object): if not self.is_android: return for t in self.timers: t.cancel() self.logcat_stop() if self.is_emulator: self.kill_processes(self.config["emulator_process_name"]) Loading
testing/mozbase/mozscreenshot/mozscreenshot/__init__.py +5 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ def printstatus(name, returncode): print("TEST-INFO | %s: %s" % (name, strstatus(returncode))) def dump_screen(utilityPath, log): def dump_screen(utilityPath, log, prefix='mozilla-test-fail-screenshot_'): """dumps a screenshot of the entire screen to a directory specified by the MOZ_UPLOAD_DIR environment variable. Loading Loading @@ -52,7 +52,7 @@ def dump_screen(utilityPath, log): # Run the capture try: tmpfd, imgfilename = tempfile.mkstemp( prefix='mozilla-test-fail-screenshot_', prefix=prefix, suffix='.png', dir=parent_dir ) os.close(tmpfd) Loading @@ -68,7 +68,7 @@ def dump_screen(utilityPath, log): % (utility[0], err.strerror)) def dump_device_screen(device, log): def dump_device_screen(device, log, prefix='mozilla-test-fail-screenshot_'): """dumps a screenshot of a real device's entire screen to a directory specified by the MOZ_UPLOAD_DIR environment variable. Cloned from mozscreenshot.dump_screen. Loading @@ -95,8 +95,8 @@ def dump_device_screen(device, log): # We can use mktemp on real devices since we do not test on # real devices older than Android 6.0. Note we must create the # file without an extension due to limitations in mktemp. filename = device.shell_output('mktemp -p %s mozilla-test-fail-screenshot_XXXXXX' % device.test_root) filename = device.shell_output('mktemp -p %s %sXXXXXX' % (device.test_root, prefix)) pngfilename = filename + '.png' device.mv(filename, pngfilename) if is_structured_log: Loading
testing/mozharness/configs/android/android_common.py +4 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,10 @@ config = { "minidump_stackwalk_path": "/usr/local/bin/linux64-minidump_stackwalk", "marionette_address": "localhost:2828", "marionette_test_manifest": "unit-tests.ini", # To take device screenshots at timed intervals (each time in seconds, relative # to the start of the run-tests step) specify screenshot_times. For example, to # take 4 screenshots at one minute intervals you could specify: # "screenshot_times": [60, 120, 180, 240], "suite_definitions": { "mochitest": { Loading
testing/mozharness/mozharness/mozilla/testing/android.py +29 −5 Original line number Diff line number Diff line Loading @@ -13,8 +13,9 @@ import signal import subprocess import time import tempfile from threading import Timer from mozharness.mozilla.automation import TBPL_RETRY, EXIT_STATUS_DICT from mozharness.base.script import PostScriptAction from mozharness.base.script import PreScriptAction, PostScriptAction class AndroidMixin(object): Loading Loading @@ -194,7 +195,7 @@ class AndroidMixin(object): def _verify_emulator_and_restart_on_fail(self): emulator_ok = self._verify_emulator() if not emulator_ok: self.device_screenshot() self.device_screenshot("screenshot-emulator-start") self.kill_processes(self.config["emulator_process_name"]) subprocess.check_call(['ps', '-ef']) # remove emulator tmp files Loading Loading @@ -335,10 +336,12 @@ class AndroidMixin(object): def shell_output(self, cmd): return self.device.shell_output(cmd, timeout=30) def device_screenshot(self): def device_screenshot(self, prefix): """ On emulator, save a screenshot of the entire screen to the upload directory; otherwise, save a screenshot of the device to the upload directory. :param prefix specifies a filename prefix for the screenshot """ from mozscreenshot import dump_screen, dump_device_screen reset_dir = False Loading @@ -347,9 +350,9 @@ class AndroidMixin(object): os.environ["MOZ_UPLOAD_DIR"] = dirs['abs_blob_upload_dir'] reset_dir = True if self.is_emulator: dump_screen(self.xre_path, self) dump_screen(self.xre_path, self, prefix=prefix) else: dump_device_screen(self.device, self) dump_device_screen(self.device, self, prefix=prefix) if reset_dir: del os.environ["MOZ_UPLOAD_DIR"] Loading Loading @@ -494,6 +497,25 @@ class AndroidMixin(object): # Get a post-boot device process list for diagnostics self.info(self.shell_output('ps')) @PreScriptAction('run-tests') def timed_screenshots(self, action, success=None): """ If configured, start screenshot timers. """ if not self.is_android: return def take_screenshot(seconds): self.device_screenshot("screenshot-%ss-" % str(seconds)) self.info("timed (%ss) screenshot complete" % str(seconds)) self.timers = [] for seconds in self.config.get("screenshot_times", []): self.info("screenshot requested %s seconds from now" % str(seconds)) t = Timer(int(seconds), take_screenshot, [seconds]) t.start() self.timers.append(t) @PostScriptAction('run-tests') def stop_device(self, action, success=None): """ Loading @@ -502,6 +524,8 @@ class AndroidMixin(object): if not self.is_android: return for t in self.timers: t.cancel() self.logcat_stop() if self.is_emulator: self.kill_processes(self.config["emulator_process_name"])