Bug 1068429 - Log crashes with structured logging for those using structured logging.;r=ahal
authorChris Manchester <cmanchester@mozilla.com>
Tue, 23 Sep 2014 20:33:31 -0400
changeset 207066 1244ab6f3d0e52038aa63a6113488062e454bae7
parent 207065 8b6aebc85b17fe9175c45e49e8f8c5f6fb679935
child 207067 3a1ba1c83e32e186e237b1e62c5c3a4d7ba11538
push id27544
push userryanvm@gmail.com
push dateWed, 24 Sep 2014 21:10:36 +0000
treeherdermozilla-central@1735ff2bb23e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1068429
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1068429 - Log crashes with structured logging for those using structured logging.;r=ahal
build/mobile/b2gautomation.py
build/mobile/remoteautomation.py
testing/mochitest/runtests.py
testing/mozbase/mozrunner/mozrunner/base/runner.py
--- a/build/mobile/b2gautomation.py
+++ b/build/mobile/b2gautomation.py
@@ -11,16 +11,17 @@ import Queue
 import re
 import shutil
 import signal
 import tempfile
 import time
 import traceback
 
 from automation import Automation
+from mozlog.structured import get_default_logger
 from mozprocess import ProcessHandlerMixin
 
 
 class StdOutProc(ProcessHandlerMixin):
     """Process handler for b2g which puts all output in a Queue.
     """
 
     def __init__(self, cmd, queue, **kwargs):
@@ -109,17 +110,21 @@ class B2GRemoteAutomation(Automation):
     def checkForCrashes(self, directory, symbolsPath):
         crashed = False
         remote_dump_dir = self._remoteProfile + '/minidumps'
         print "checking for crashes in '%s'" % remote_dump_dir
         if self._devicemanager.dirExists(remote_dump_dir):
             local_dump_dir = tempfile.mkdtemp()
             self._devicemanager.getDirectory(remote_dump_dir, local_dump_dir)
             try:
-                crashed = mozcrash.check_for_crashes(local_dump_dir, symbolsPath, test_name=self.lastTestSeen)
+                logger = get_default_logger()
+                if logger is not None:
+                    crashed = mozcrash.log_crashes(logger, local_dump_dir, symbolsPath, test=self.lastTestSeen)
+                else:
+                    crashed = mozcrash.check_for_crashes(local_dump_dir, symbolsPath, test_name=self.lastTestSeen)
             except:
                 traceback.print_exc()
             finally:
                 shutil.rmtree(local_dump_dir)
                 self._devicemanager.removeDir(remote_dump_dir)
         return crashed
 
     def buildCommandLine(self, app, debuggerInfo, profileDir, testURL, extraArgs):
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -8,16 +8,17 @@ import re
 import os
 import tempfile
 import shutil
 import subprocess
 import sys
 
 from automation import Automation
 from devicemanager import DMError
+from mozlog.structured import get_default_logger
 import mozcrash
 
 # signatures for logcat messages that we don't care about much
 fennecLogcatFilters = [ "The character encoding of the HTML document was not declared",
                         "Use of Mutation Events is deprecated. Use MutationObserver instead.",
                         "Unexpected value from nativeGetEnabledTags: 0" ]
 
 class RemoteAutomation(Automation):
@@ -197,17 +198,22 @@ class RemoteAutomation(Automation):
                 # 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)
+
+            logger = get_default_logger()
+            if logger is not None:
+                crashed = mozcrash.log_crashes(logger, dumpDir, symbolsPath, test=self.lastTestSeen)
+            else:
+                crashed = Automation.checkForCrashes(self, dumpDir, symbolsPath)
 
         finally:
             try:
                 shutil.rmtree(dumpDir)
             except:
                 print "WARNING: unable to remove directory: %s" % dumpDir
         return crashed
 
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1527,21 +1527,20 @@ class Mochitest(MochitestUtilsMixin):
 
       self.log.info("runtests.py | Application ran for: %s" % str(datetime.now() - startTime))
 
       # Do a final check for zombie child processes.
       zombieProcesses = self.checkForZombies(processLog, utilityPath, debuggerInfo)
 
       # check for crashes
       minidump_path = os.path.join(self.profile.profile, "minidumps")
-      crashed = mozcrash.check_for_crashes(minidump_path,
-                                           symbolsPath,
-                                           test_name=self.lastTestSeen)
+      crash_count = mozcrash.log_crashes(self.log, minidump_path, symbolsPath,
+                                         test=self.lastTestSeen)
 
-      if crashed or zombieProcesses:
+      if crash_count or zombieProcesses:
         status = 1
 
     finally:
       # cleanup
       if os.path.exists(processLog):
         os.remove(processLog)
 
     return status
--- a/testing/mozbase/mozrunner/mozrunner/base/runner.py
+++ b/testing/mozbase/mozrunner/mozrunner/base/runner.py
@@ -3,16 +3,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from abc import ABCMeta, abstractproperty
 import os
 import subprocess
 import traceback
 
+from mozlog.structured import get_default_logger
 from mozprocess import ProcessHandler
 import mozcrash
 
 from ..application import DefaultContext
 from ..errors import RunnerNotStartedError
 
 
 class BaseRunner(object):
@@ -176,22 +177,32 @@ class BaseRunner(object):
         :param quiet: If `True` don't print the PROCESS-CRASH message to stdout
         :returns: True if a crash was detected, otherwise False
         """
         if not dump_directory:
             dump_directory = os.path.join(self.profile.profile, 'minidumps')
 
         self.crashed = False
         try:
-            self.crashed = mozcrash.check_for_crashes(
-                dump_directory,
-                self.symbols_path,
-                dump_save_path=dump_save_path,
-                test_name=test_name,
-                quiet=quiet)
+            logger = get_default_logger()
+            if logger is not None:
+                if test_name is None:
+                    test_name = "runner.py"
+                self.crashed = mozcrash.log_crashes(logger,
+                                                    dump_directory,
+                                                    self.symbols_path,
+                                                    dump_save_path=dump_save_path,
+                                                    test=test_name)
+            else:
+                self.crashed = mozcrash.check_for_crashes(
+                    dump_directory,
+                    self.symbols_path,
+                    dump_save_path=dump_save_path,
+                    test_name=test_name,
+                    quiet=quiet)
         except:
             traceback.print_exc()
 
         return self.crashed
 
     def cleanup(self):
         """
         Cleanup all runner state