Bug 1052371 - Fix m-bc shutdown leak detector. r=akachkach, a=test-only
authorTim Taubert <ttaubert@mozilla.com>
Tue, 12 Aug 2014 21:23:29 +0200
changeset 217469 540ac322aac8f3ba7de93e4b720e05770187723a
parent 217468 28ca334743079c22e294af16c31ccc7288829062
child 217470 d4982a4bbb4dc53c1d9c14afb3c07f067f992a8a
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersakachkach, test-only
bugs1052371
milestone33.0a2
Bug 1052371 - Fix m-bc shutdown leak detector. r=akachkach, a=test-only
build/automation.py.in
build/automationutils.py
testing/mochitest/runtests.py
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -814,17 +814,17 @@ class Automation(object):
   def checkForCrashes(self, minidumpDir, symbolsPath):
     return mozcrash.check_for_crashes(minidumpDir, symbolsPath, test_name=self.lastTestSeen)
 
   def runApp(self, testURL, env, app, profileDir, extraArgs,
              runSSLTunnel = False, utilityPath = None,
              xrePath = None, certPath = None,
              debuggerInfo = None, symbolsPath = None,
              timeout = -1, maxTime = None, onLaunch = None,
-             webapprtChrome = False, screenshotOnFail=False, testPath=None, bisectChunk=None):
+             detectShutdownLeaks = False, screenshotOnFail=False, testPath=None, bisectChunk=None):
     """
     Run the app, log the duration it took to execute, return the status code.
     Kills the app if it runs for longer than |maxTime| seconds, or outputs nothing for |timeout| seconds.
     """
 
     if utilityPath == None:
       utilityPath = self.DIST_BIN
     if xrePath == None:
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -604,28 +604,31 @@ class ShutdownLeaks(object):
 
   def log(self, message):
     if message['action'] == 'log':
         line = message['message']
         if line[2:11] == "DOMWINDOW":
           self._logWindow(line)
         elif line[2:10] == "DOCSHELL":
           self._logDocShell(line)
+        elif line.startswith("TEST-START | Shutdown"):
+          self.seenShutdown = True
     elif message['action'] == 'test_start':
       fileName = message['test'].replace("chrome://mochitests/content/browser/", "")
       self.currentTest = {"fileName": fileName, "windows": set(), "docShells": set()}
     elif message['action'] == 'test_end':
       # don't track a test if no windows or docShells leaked
       if self.currentTest and (self.currentTest["windows"] or self.currentTest["docShells"]):
         self.tests.append(self.currentTest)
       self.currentTest = None
-    elif message['action'] == 'suite_end':
-      self.seenShutdown = True
 
   def process(self):
+    if not self.seenShutdown:
+      self.logger("TEST-UNEXPECTED-FAIL | ShutdownLeaks | process() called before end of test suite")
+
     for test in self._parseLeakingTests():
       for url, count in self._zipLeakedWindows(test["leakedWindows"]):
         self.logger("TEST-UNEXPECTED-FAIL | %s | leaked %d window(s) until shutdown [url = %s]" % (test["fileName"], count, url))
 
       if test["leakedDocShells"]:
         self.logger("TEST-UNEXPECTED-FAIL | %s | leaked %d docShell(s) until shutdown" % (test["fileName"], len(test["leakedDocShells"])))
 
   def _logWindow(self, line):
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1313,17 +1313,17 @@ class Mochitest(MochitestUtilsMixin):
              app,
              profile,
              extraArgs,
              utilityPath,
              debuggerInfo=None,
              symbolsPath=None,
              timeout=-1,
              onLaunch=None,
-             webapprtChrome=False,
+             detectShutdownLeaks=False,
              screenshotOnFail=False,
              testPath=None,
              bisectChunk=None,
              quiet=False):
     """
     Run the app, log the duration it took to execute, return the status code.
     Kills the app if it runs for longer than |maxTime| seconds, or outputs nothing for |timeout| seconds.
     """
@@ -1368,17 +1368,17 @@ class Mochitest(MochitestUtilsMixin):
       # TODO: mozrunner should use -foreground at least for mac
       # https://bugzilla.mozilla.org/show_bug.cgi?id=916512
       args.append('-foreground')
       if testUrl:
         if debuggerInfo and debuggerInfo['requiresEscapedArgs']:
           testUrl = testUrl.replace("&", "\\&")
         args.append(testUrl)
 
-      if mozinfo.info["debug"] and not webapprtChrome:
+      if detectShutdownLeaks:
         shutdownLeaks = ShutdownLeaks(log.info)
       else:
         shutdownLeaks = None
 
       if mozinfo.info["asan"] and (mozinfo.isLinux or mozinfo.isMac):
         lsanLeaks = LSANLeaks(log.info)
       else:
         lsanLeaks = None
@@ -1720,29 +1720,32 @@ class Mochitest(MochitestUtilsMixin):
       elif options.debugger or not options.autorun:
         timeout = None
       else:
         timeout = 330.0 # default JS harness timeout is 300 seconds
 
       if options.vmwareRecording:
         self.startVMwareRecording(options);
 
+      # detect shutdown leaks for m-bc runs
+      detectShutdownLeaks = mozinfo.info["debug"] and options.browserChrome and not options.webapprtChrome
+
       log.info("runtests.py | Running tests: start.\n")
       try:
         status = self.runApp(testURL,
                              self.browserEnv,
                              options.app,
                              profile=self.profile,
                              extraArgs=options.browserArgs,
                              utilityPath=options.utilityPath,
                              debuggerInfo=debuggerInfo,
                              symbolsPath=options.symbolsPath,
                              timeout=timeout,
                              onLaunch=onLaunch,
-                             webapprtChrome=options.webapprtChrome,
+                             detectShutdownLeaks=detectShutdownLeaks,
                              screenshotOnFail=options.screenshotOnFail,
                              testPath=options.testPath,
                              bisectChunk=options.bisectChunk,
                              quiet=options.quiet
         )
       except KeyboardInterrupt:
         log.info("runtests.py | Received keyboard interrupt.\n");
         status = -1