Bug 1354232 - Always try to process the leak log whenever we stop firefox, r=ato
authorJames Graham <james@hoppipolla.co.uk>
Tue, 29 May 2018 23:39:50 +0100
changeset 1555228 5d9db023723c554add548698eb7828f1ea4a299d
parent 1555227 be8f3a0bd5c974a6ced44239986890da2ef0d114
child 1555229 d2d3ad95784696cdd9cb7be7aa5b7d7e023f68d5
push id282197
push userjames@hoppipolla.co.uk
push dateTue, 03 Jul 2018 20:12:38 +0000
treeherdertry@03ac4554ef3e [default view] [failures only]
Bug 1354232 - Always try to process the leak log whenever we stop firefox, r=ato The `stop` method is always called to shutdown firefox, but the cleanup method is only called at the end of a test run. Therefore we need all the leak processing stuff ot happen in stop(). MozReview-Commit-ID: 5OE54cEygNy
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/firefox.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/firefox.py
@@ -1,15 +1,14 @@
 import json
 import os
 import platform
 import signal
 import subprocess
 import sys
-import tempfile
 import mozinfo
 import mozleak
 from mozprocess import ProcessHandler
 from mozprofile import FirefoxProfile, Preferences
 from mozrunner import FirefoxRunner
 from mozrunner.utils import test_environment, get_stack_fixer_function
 from mozcrash import mozcrash
@@ -227,18 +226,18 @@ class FirefoxBrowser(Browser):
                                       "dom.send_after_paint_to_content": True,
                                       "network.preload": True})
         if self.e10s:
             self.profile.set_preferences({"browser.tabs.remote.autostart": True})
         if self.test_type == "reftest":
             self.profile.set_preferences({"layout.interruptible-reflow.enabled": False})
-        if self.leak_check and kwargs.get("check_leaks", True):
-            self.leak_report_file = os.path.join(self.profile.profile, "runtests_leaks.log")
+        if self.leak_check:
+            self.leak_report_file = os.path.join(self.profile.profile, "runtests_leaks_%s.log" % os.getpid())
             if os.path.exists(self.leak_report_file):
             env["XPCOM_MEM_BLOAT_LOG"] = self.leak_report_file
             self.leak_report_file = None
         # Bug 1262954: winxp + e10s, disable hwaccel
         if (self.e10s and platform.system() in ("Windows", "Microsoft") and
@@ -302,16 +301,17 @@ class FirefoxBrowser(Browser):
                     if not force or not clean:
                         retcode = stop_f()
                         if retcode is not None:
                             self.logger.info("Browser exited with return code %s" % retcode)
             except OSError:
                 # This can happen on Windows if the process is already dead
+        self.process_leaks()
     def process_leaks(self):
         self.logger.debug("PROCESS LEAKS %s" % self.leak_report_file)
         if self.lsan_handler:
         if self.leak_report_file is not None:
@@ -351,19 +351,18 @@ class FirefoxBrowser(Browser):
                                            command=" ".join(self.runner.command))
     def is_alive(self):
         if self.runner:
             return self.runner.is_running()
         return False
-    def cleanup(self):
-        self.stop()
-        self.process_leaks()
+    def cleanup(self, force=False):
+        self.stop(force)
     def executor_browser(self):
         assert self.marionette_port is not None
         return ExecutorBrowser, {"marionette_port": self.marionette_port}
     def check_for_crashes(self):
         dump_dir = os.path.join(self.profile.profile, "minidumps")