Пример #1
0
 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
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
 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
Пример #5
0
    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
Пример #6
0
    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")
Пример #7
0
 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
Пример #8
0
 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))
Пример #9
0
    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)
Пример #10
0
 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)
Пример #11
0
 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))
Пример #12
0
 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))
Пример #13
0
 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))
Пример #14
0
 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))
Пример #15
0
 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))
Пример #16
0
 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))
Пример #17
0
 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))
Пример #18
0
    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
Пример #19
0
    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
Пример #20
0
    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
Пример #21
0
    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
Пример #22
0
 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
Пример #24
0
 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))
Пример #25
0
    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")
Пример #26
0
 def wrapper(logcat=None, test_name=None, quiet=True):
     return mozcrash.check_for_java_exception(logcat, test_name, quiet)
Пример #27
0
 def test_uncaught_exception(self):
         """
         Test for an exception which should be caught
         """
         self.assert_(mozcrash.check_for_java_exception(self.test_log))