def check_for_crashes(self): logcat = self.device.get_logcat() if logcat: if mozcrash.check_for_java_exception(logcat, self.current_full_name): return True symbols_path = self.options.symbolsPath try: dump_dir = tempfile.mkdtemp() remote_dir = posixpath.join(self.remote_profile, 'minidumps') if not self.device.is_dir(remote_dir): # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the # minidumps directory is automatically created when the app # (first) starts, so its lack of presence is a hint that # something went wrong. print "Automation Error: No crash directory (%s) found on remote device" % \ remote_dir return True self.device.pull(remote_dir, dump_dir) crashed = mozcrash.log_crashes(self.log, dump_dir, symbols_path, test=self.current_full_name) finally: try: shutil.rmtree(dump_dir) except Exception: self.log.warning("unable to remove directory: %s" % dump_dir) return crashed
def checkForCrashes(self, directory, symbolsPath): self.checkForANRs() logcat = self._devicemanager.getLogcat(filterOutRegexps=fennecLogcatFilters) javaException = mozcrash.check_for_java_exception(logcat) if javaException: return True # If crash reporting is disabled (MOZ_CRASHREPORTER!=1), we can't say # anything. if not self.CRASHREPORTER: return False try: dumpDir = tempfile.mkdtemp() remoteCrashDir = self._remoteProfile + '/minidumps/' if not self._devicemanager.dirExists(remoteCrashDir): # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the # minidumps directory is automatically created when Fennec # (first) starts, so its lack of presence is a hint that # something went wrong. print "Automation Error: No crash directory (%s) found on remote device" % remoteCrashDir # Whilst no crash was found, the run should still display as a failure return True self._devicemanager.getDirectory(remoteCrashDir, dumpDir) crashed = Automation.checkForCrashes(self, dumpDir, symbolsPath) finally: try: shutil.rmtree(dumpDir) except: print "WARNING: unable to remove directory: %s" % dumpDir return crashed
def checkForCrashes(self, symbolsPath): logcat = self.device.get_logcat(filter_out_regexps=fennecLogcatFilters) javaException = mozcrash.check_for_java_exception( logcat, test_name=self.lastTestSeen) if javaException: return True # If crash reporting is disabled (MOZ_CRASHREPORTER!=1), we can't say # anything. if not self.CRASHREPORTER: return False try: dumpDir = tempfile.mkdtemp() remoteCrashDir = posixpath.join(self.remoteProfile, 'minidumps') if not self.device.is_dir(remoteCrashDir): return False self.device.pull(remoteCrashDir, dumpDir) logger = get_default_logger() crashed = mozcrash.log_crashes(logger, dumpDir, symbolsPath, test=self.lastTestSeen) finally: try: shutil.rmtree(dumpDir) except Exception as e: print("WARNING: unable to remove directory %s: %s" % (dumpDir, str(e))) return crashed
def check_for_crashes(self): if self.logcat: if mozcrash.check_for_java_exception(self.logcat, self.test_name): return True symbols_path = self.options.symbols_path try: dump_dir = tempfile.mkdtemp() remote_dir = posixpath.join(self.remote_profile, 'minidumps') if not self.dm.dirExists(remote_dir): # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the # minidumps directory is automatically created when the app # (first) starts, so its lack of presence is a hint that # something went wrong. print "Automation Error: No crash directory (%s) found on remote device" % \ remote_dir # Whilst no crash was found, the run should still display as a failure return True self.dm.getDirectory(remote_dir, dump_dir) crashed = mozcrash.log_crashes(self.log, dump_dir, symbols_path, test=self.test_name) finally: try: shutil.rmtree(dump_dir) except: self.log.warn("unable to remove directory: %s" % dump_dir) return crashed
def checkForCrashes(self, directory, symbolsPath): self.checkForANRs() self.checkForTombstones() logcat = self._devicemanager.getLogcat( filterOutRegexps=fennecLogcatFilters) javaException = mozcrash.check_for_java_exception(logcat) if javaException: return True # If crash reporting is disabled (MOZ_CRASHREPORTER!=1), we can't say # anything. if not self.CRASHREPORTER: return False try: dumpDir = tempfile.mkdtemp() remoteCrashDir = self._remoteProfile + '/minidumps/' if not self._devicemanager.dirExists(remoteCrashDir): # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the # minidumps directory is automatically created when Fennec # (first) starts, so its lack of presence is a hint that # something went wrong. print "Automation Error: No crash directory (%s) found on remote device" % remoteCrashDir # Whilst no crash was found, the run should still display as a failure return True self._devicemanager.getDirectory(remoteCrashDir, dumpDir) crashed = Automation.checkForCrashes(self, dumpDir, symbolsPath) finally: try: shutil.rmtree(dumpDir) except: print "WARNING: unable to remove directory: %s" % dumpDir return crashed
def cleanupAndCheckForCrashes(self, browser_config, profile_dir, test_name): """cleanup browser processes and process crashes if found""" # cleanup processes self._ffprocess.cleanupProcesses(browser_config['process'], browser_config['child_process'], browser_config['browser_wait']) # find stackwalk binary if platform.system() in ('Windows', 'Microsoft'): stackwalkpaths = ['win32', 'minidump_stackwalk.exe'] elif platform.system() == 'Linux': # are we 64 bit? if '64' in platform.architecture()[0]: stackwalkpaths = ['linux64', 'minidump_stackwalk'] else: stackwalkpaths = ['linux', 'minidump_stackwalk'] elif platform.system() == 'Darwin': stackwalkpaths = ['osx', 'minidump_stackwalk'] else: # no minidump_stackwalk available for your platform return stackwalkbin = os.path.join(os.path.dirname(__file__), 'breakpad', *stackwalkpaths) assert os.path.exists(stackwalkbin), "minidump_stackwalk binary not found: %s" % stackwalkbin if browser_config['remote'] is True: # favour using Java exceptions in the logcat over minidumps if os.path.exists('logcat.log'): with open('logcat.log') as f: logcat = f.read().split('\r') found = mozcrash.check_for_java_exception(logcat) remoteminidumpdir = profile_dir + '/minidumps/' if not found: # check for minidumps minidumpdir = tempfile.mkdtemp() try: if self._ffprocess.testAgent.dirExists(remoteminidumpdir): self._ffprocess.testAgent.getDirectory(remoteminidumpdir, minidumpdir) except mozdevice.DMError: print "Remote Device Error: Error getting crash minidumps from device" raise found = mozcrash.check_for_crashes(minidumpdir, browser_config['symbols_path'], stackwalk_binary=stackwalkbin, test_name=test_name) self._hostproc.removeDirectory(minidumpdir) # cleanup dumps on remote self._ffprocess.testAgent.removeDir(remoteminidumpdir) else: # check for minidumps minidumpdir = os.path.join(profile_dir, 'minidumps') found = mozcrash.check_for_crashes(minidumpdir, browser_config['symbols_path'], stackwalk_binary=stackwalkbin, test_name=test_name) if found: raise talosCrash("Found crashes after test run, terminating test")
def test_unchecked_exception(self): """ Test for an exception which should not be caught """ passable_log = list(self.test_log) passable_log[0] = "01-30 20:15:41.937 E/GeckoAppShell( 1703): >>> NOT-SO-BAD EXCEPTION FROM THREAD 9 (\"GeckoBackgroundThread\")" self.assert_(not mozcrash.check_for_java_exception(passable_log))
def check_for_crashes(self): super(WebExtensionAndroid, self).check_for_crashes() if not self.app_launched: LOG.info( "skipping check_for_crashes: application has not been launched" ) return self.app_launched = False # Turn off verbose to prevent logcat from being inserted into the main log. verbose = self.device._verbose self.device._verbose = False logcat = self.device.get_logcat() self.device._verbose = verbose if logcat: if mozcrash.check_for_java_exception(logcat, "raptor"): return try: dump_dir = tempfile.mkdtemp() remote_dir = posixpath.join(self.remote_profile, "minidumps") if not self.device.is_dir(remote_dir): return self.device.pull(remote_dir, dump_dir) mozcrash.log_crashes(LOG, dump_dir, self.config["symbols_path"]) finally: try: shutil.rmtree(dump_dir) except Exception: LOG.warning("unable to remove directory: %s" % dump_dir)
def check_for_crashes(self): # Turn off verbose to prevent logcat from being inserted into the main log. verbose = self.device._verbose self.device._verbose = False logcat = self.device.get_logcat() self.device._verbose = verbose if logcat: if mozcrash.check_for_java_exception(logcat, "raptor"): return try: dump_dir = tempfile.mkdtemp() remote_dir = posixpath.join(self.device_profile, 'minidumps') if not self.device.is_dir(remote_dir): self.log.error( "No crash directory (%s) found on remote device" % remote_dir) return self.device.pull(remote_dir, dump_dir) mozcrash.log_crashes(self.log, dump_dir, self.config['symbols_path']) finally: try: shutil.rmtree(dump_dir) except Exception: self.log.warning("unable to remove directory: %s" % dump_dir)
def test_fatal_exception(self): """ Test for an exception which should be caught """ fatal_log = list(self.test_log) fatal_log[0] = "01-30 20:15:41.937 E/GeckoAppShell( 1703): >>> FATAL EXCEPTION FROM THREAD 9 (\"GeckoBackgroundThread\")" self.assert_(mozcrash.check_for_java_exception(fatal_log))
def test_truncated_exception(self): """ Test for an exception which should be caught which was truncated """ truncated_log = list(self.test_log) truncated_log[0], truncated_log[1] = truncated_log[1], truncated_log[0] self.assert_(mozcrash.check_for_java_exception(truncated_log))
def test_fatal_exception(self): """ Test for an exception which should be caught """ fatal_log = list(self.test_log) fatal_log[ 0] = "01-30 20:15:41.937 E/GeckoAppShell( 1703): >>> FATAL EXCEPTION FROM THREAD 9 (\"GeckoBackgroundThread\")" self.assert_(mozcrash.check_for_java_exception(fatal_log, quiet=True))
def test_unchecked_exception(self): """ Test for an exception which should not be caught """ passable_log = list(self.test_log) passable_log[0] = "01-30 20:15:41.937 E/GeckoAppShell( 1703):" \ " >>> NOT-SO-BAD EXCEPTION FROM THREAD 9 (\"GeckoBackgroundThread\")" self.assert_(not mozcrash.check_for_java_exception(passable_log, quiet=True))
def test_truncated_exception(self): """ Test for an exception which should be caught which was truncated """ truncated_log = list(self.test_log) truncated_log[0], truncated_log[1] = truncated_log[1], truncated_log[0] self.assert_(mozcrash.check_for_java_exception(truncated_log, quiet=True))
def test_unchecked_exception(self): """ Test for an exception which should not be caught """ passable_log = list(self.test_log) passable_log[ 0 ] = '01-30 20:15:41.937 E/GoannaAppShell( 1703): >>> NOT-SO-BAD EXCEPTION FROM THREAD 9 ("GoannaBackgroundThread")' self.assert_(not mozcrash.check_for_java_exception(passable_log, quiet=True))
def test_fatal_exception(self): """ Test for an exception which should be caught """ fatal_log = list(self.test_log) fatal_log[ 0 ] = '01-30 20:15:41.937 E/GoannaAppShell( 1703): >>> FATAL EXCEPTION FROM THREAD 9 ("GoannaBackgroundThread")' self.assert_(mozcrash.check_for_java_exception(fatal_log, quiet=True))
def checkForCrashes(self, directory, symbolsPath): self.checkForANRs() self.checkForTombstones() logcat = self._devicemanager.getLogcat(filterOutRegexps=fennecLogcatFilters) javaException = mozcrash.check_for_java_exception(logcat) if javaException: return True # No crash reporting return False
def checkForCrashes(self, directory, symbolsPath): self.checkForANRs() self.checkForTombstones() logcat = self._devicemanager.getLogcat(filterOutRegexps=fennecLogcatFilters) javaException = mozcrash.check_for_java_exception(logcat, test_name=self.lastTestSeen) if javaException: return True # No crash reporting means we can't say anything. return False
def checkForCrashes(self, directory, symbolsPath): self.checkForANRs() self.checkForTombstones() logcat = self._device.get_logcat( filter_out_regexps=fennecLogcatFilters) javaException = mozcrash.check_for_java_exception( logcat, test_name=self.lastTestSeen) if javaException: return True # If crash reporting is disabled (MOZ_CRASHREPORTER!=1), we can't say # anything. if not self.CRASHREPORTER: return False try: dumpDir = tempfile.mkdtemp() remoteCrashDir = posixpath.join(self._remoteProfile, 'minidumps') if not self._device.is_dir(remoteCrashDir): # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the # minidumps directory is automatically created when Fennec # (first) starts, so its lack of presence is a hint that # something went wrong. print( "Automation Error: No crash directory (%s) found on remote device" % remoteCrashDir) return True self._device.pull(remoteCrashDir, dumpDir) logger = get_default_logger() crashed = mozcrash.log_crashes(logger, dumpDir, symbolsPath, test=self.lastTestSeen) finally: try: shutil.rmtree(dumpDir) except Exception as e: print("WARNING: unable to remove directory %s: %s" % (dumpDir, str(e))) return crashed
def checkForCrashes(self, directory, symbolsPath): self.checkForANRs() self.checkForTombstones() logcat = self._device.get_logcat( filter_out_regexps=fennecLogcatFilters) javaException = mozcrash.check_for_java_exception( logcat, test_name=self.lastTestSeen) if javaException: return True # If crash reporting is disabled (MOZ_CRASHREPORTER!=1), we can't say # anything. if not self.CRASHREPORTER: return False try: dumpDir = tempfile.mkdtemp() remoteCrashDir = posixpath.join(self._remoteProfile, 'minidumps') if not self._device.is_dir(remoteCrashDir): # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the # minidumps directory is automatically created when Fennec # (first) starts, so its lack of presence is a hint that # something went wrong. print("Automation Error: No crash directory (%s) found on remote device" % remoteCrashDir) return True self._device.pull(remoteCrashDir, dumpDir) logger = get_default_logger() crashed = mozcrash.log_crashes( logger, dumpDir, symbolsPath, test=self.lastTestSeen) finally: try: shutil.rmtree(dumpDir) except Exception as e: print("WARNING: unable to remove directory %s: %s" % ( dumpDir, str(e))) return crashed
def check_for_crashes(self): logcat = self.device.get_logcat() if logcat: if mozcrash.check_for_java_exception(logcat, self.current_full_name): return True symbols_path = self.options.symbolsPath try: dump_dir = tempfile.mkdtemp() remote_dir = posixpath.join(self.remote_profile, 'minidumps') if not self.device.is_dir(remote_dir): return False self.device.pull(remote_dir, dump_dir) crashed = mozcrash.log_crashes(self.log, dump_dir, symbols_path, test=self.current_full_name) finally: try: shutil.rmtree(dump_dir) except Exception: self.log.warning("unable to remove directory: %s" % dump_dir) return crashed
def check_for_crashes(self): if self.logcat: if mozcrash.check_for_java_exception(self.logcat, self.test_name): return True symbols_path = self.options.symbols_path try: dump_dir = tempfile.mkdtemp() remote_dir = posixpath.join(self.remote_profile, 'minidumps') crash_dir_found = False # wait up to 60 seconds for gecko startup to progress through # crashreporter initialization, in case all tests finished quickly for wait_time in xrange(60): time.sleep(1) if self.device.is_dir(remote_dir): crash_dir_found = True break if not crash_dir_found: # If crash reporting is enabled (MOZ_CRASHREPORTER=1), the # minidumps directory is automatically created when the app # (first) starts, so its lack of presence is a hint that # something went wrong. print "Automation Error: No crash directory (%s) found on remote device" % \ remote_dir # Whilst no crash was found, the run should still display as a failure return True self.device.pull(remote_dir, dump_dir) crashed = mozcrash.log_crashes(self.log, dump_dir, symbols_path, test=self.test_name) finally: try: shutil.rmtree(dump_dir) except Exception: self.log.warning("unable to remove directory: %s" % dump_dir) return crashed
def test_uncaught_exception(self): """ Test for an exception which should be caught """ self.assert_(mozcrash.check_for_java_exception(self.test_log, quiet=True))
def cleanupAndCheckForCrashes(self, browser_config, profile_dir, test_name): """cleanup browser processes and process crashes if found""" # cleanup processes self._ffprocess.cleanupProcesses(browser_config['process'], browser_config['child_process'], browser_config['browser_wait']) # find stackwalk binary if platform.system() in ('Windows', 'Microsoft'): stackwalkpaths = ['win32', 'minidump_stackwalk.exe'] elif platform.system() == 'Linux': # are we 64 bit? if '64' in platform.architecture()[0]: stackwalkpaths = ['linux64', 'minidump_stackwalk'] else: stackwalkpaths = ['linux', 'minidump_stackwalk'] elif platform.system() == 'Darwin': stackwalkpaths = ['osx', 'minidump_stackwalk'] else: # no minidump_stackwalk available for your platform return stackwalkbin = os.path.join(os.path.dirname(__file__), 'breakpad', *stackwalkpaths) assert os.path.exists( stackwalkbin ), "minidump_stackwalk binary not found: %s" % stackwalkbin if browser_config['remote'] is True: # favour using Java exceptions in the logcat over minidumps if os.path.exists('logcat.log'): with open('logcat.log') as f: logcat = f.read().split('\r') found = mozcrash.check_for_java_exception(logcat) remoteminidumpdir = profile_dir + '/minidumps/' if not found: # check for minidumps minidumpdir = tempfile.mkdtemp() try: if self._ffprocess.testAgent.dirExists(remoteminidumpdir): self._ffprocess.testAgent.getDirectory( remoteminidumpdir, minidumpdir) except mozdevice.DMError: print "Remote Device Error: Error getting crash minidumps from device" raise found = mozcrash.check_for_crashes( minidumpdir, browser_config['symbols_path'], stackwalk_binary=stackwalkbin, test_name=test_name) self._hostproc.removeDirectory(minidumpdir) # cleanup dumps on remote self._ffprocess.testAgent.removeDir(remoteminidumpdir) else: # check for minidumps minidumpdir = os.path.join(profile_dir, 'minidumps') found = mozcrash.check_for_crashes(minidumpdir, browser_config['symbols_path'], stackwalk_binary=stackwalkbin, test_name=test_name) if found: raise talosCrash("Found crashes after test run, terminating test")
def wrapper(logcat=None, test_name=None, quiet=True): return mozcrash.check_for_java_exception(logcat, test_name, quiet)
def test_uncaught_exception(self): """ Test for an exception which should be caught """ self.assert_(mozcrash.check_for_java_exception(self.test_log))