Bug 616383 - backport crash reporter fixes for mozmill to 1.5.1 mozmill in m-c r=harth a=NPOTB DONTBUILD
authorClint Talbert <ctalbert@mozilla.com>
Fri, 28 Jan 2011 14:41:21 -0800
changeset 61577 03c41bf59d8206bd4d3e3d355701ae6c28da7fd5
parent 61576 8e01633a1a7ddf1c164669778379955933530993
child 61578 bfd144a54f0adcb1f01995403f16bdf8d33ab0e1
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersharth, NPOTB
bugs616383
milestone2.0b11pre
Bug 616383 - backport crash reporter fixes for mozmill to 1.5.1 mozmill in m-c r=harth a=NPOTB DONTBUILD
testing/mozmill/mozmill/mozmill/__init__.py
testing/mozmill/mozrunner/mozrunner/__init__.py
testing/mozmill/mozrunner/mozrunner/wpk.py
--- a/testing/mozmill/mozmill/mozmill/__init__.py
+++ b/testing/mozmill/mozmill/mozmill/__init__.py
@@ -170,16 +170,19 @@ class MozMill(object):
         self.global_listeners = []
         self.listeners = []
         self.add_listener(self.persist_listener, eventType="mozmill.persist")
         self.add_listener(self.endTest_listener, eventType='mozmill.endTest')
         self.add_listener(self.endRunner_listener, eventType='mozmill.endRunner')
         self.add_listener(self.startTest_listener, eventType='mozmill.setTest')
         self.add_listener(self.userShutdown_listener, eventType='mozmill.userShutdown')
 
+        # disable the crashreporter
+        os.environ['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
+
     def add_listener(self, callback, **kwargs):
         self.listeners.append((callback, kwargs,))
 
     def add_global_listener(self, callback):
         self.global_listeners.append(callback)
 
     def persist_listener(self, obj):
         self.persisted = obj
--- a/testing/mozmill/mozrunner/mozrunner/__init__.py
+++ b/testing/mozmill/mozrunner/mozrunner/__init__.py
@@ -103,51 +103,22 @@ def getoutput(l):
 def get_pids(name, minimun_pid=0):
     """Get all the pids matching name, exclude any pids below minimum_pid."""
     if os.name == 'nt' or sys.platform == 'cygwin':
         import wpk
 
         pids = wpk.get_pids(name)
 
     else:
-        # get_pids_cmd = ['ps', 'ax']
-        # h = killableprocess.runCommand(get_pids_cmd, stdout=subprocess.PIPE, universal_newlines=True)
-        # h.wait(group=False)
-        # data = h.stdout.readlines()
         data = getoutput(['ps', 'ax']).splitlines()
         pids = [int(line.split()[0]) for line in data if line.find(name) is not -1]
 
     matching_pids = [m for m in pids if m > minimun_pid]
     return matching_pids
 
-def kill_process_by_name(name):
-    """Find and kill all processes containing a certain name"""
-
-    pids = get_pids(name)
-
-    if os.name == 'nt' or sys.platform == 'cygwin':
-        for p in pids:
-            import wpk
-
-            wpk.kill_pid(p)
-
-    else:
-        for pid in pids:
-            try:
-                os.kill(pid, signal.SIGTERM)
-            except OSError: pass
-            sleep(.5)
-            if len(get_pids(name)) is not 0:
-                try:
-                    os.kill(pid, signal.SIGKILL)
-                except OSError: pass
-                sleep(.5)
-                if len(get_pids(name)) is not 0:
-                    logger.error('Could not kill process')
-
 def makedirs(name):
 
     head, tail = os.path.split(name)
     if not tail:
         head, tail = os.path.split(head)
     if head and tail and not os.path.exists(head):
         try:
             makedirs(head)
@@ -321,16 +292,18 @@ class FirefoxProfile(Profile):
                    # Don't check for the default web browser
                    'browser.shell.checkDefaultBrowser' : False,
                    # Don't warn on exit when multiple tabs are open
                    'browser.tabs.warnOnClose' : False,
                    # Don't warn when exiting the browser
                    'browser.warnOnQuit': False,
                    # Only install add-ons from the profile and the app folder
                    'extensions.enabledScopes' : 5,
+                   # Dont' run the add-on compatibility check during start-up
+                   'extensions.showMismatchUI' : False,
                    # Don't automatically update add-ons
                    'extensions.update.enabled'    : False,
                    # Don't open a dialog to show available add-on updates
                    'extensions.update.notifyUser' : False,
                    }
 
     @property
     def names(self):
@@ -351,17 +324,17 @@ class ThunderbirdProfile(Profile):
                    }
     names = ["thunderbird", "shredder"]
 
 
 class Runner(object):
     """Handles all running operations. Finds bins, runs and kills the process."""
 
     def __init__(self, binary=None, profile=None, cmdargs=[], env=None,
-                 aggressively_kill=['crashreporter'], kp_kwargs={}):
+                 kp_kwargs={}):
         if binary is None:
             self.binary = self.find_binary()
         elif sys.platform == 'darwin' and binary.find('Contents/MacOS/') == -1:
             self.binary = os.path.join(binary, 'Contents/MacOS/%s-bin' % self.names[0])
         else:
             self.binary = binary
 
         if not os.path.exists(self.binary):
@@ -369,26 +342,28 @@ class Runner(object):
 
         if sys.platform == 'linux2' and self.binary.endswith('-bin'):
             dirname = os.path.dirname(self.binary)
             if os.environ.get('LD_LIBRARY_PATH', None):
                 os.environ['LD_LIBRARY_PATH'] = '%s:%s' % (os.environ['LD_LIBRARY_PATH'], dirname)
             else:
                 os.environ['LD_LIBRARY_PATH'] = dirname
 
+        # Set the environment to not use crash reporter by default
+        os.environ['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
+
         self.profile = profile
 
         self.cmdargs = cmdargs
         if env is None:
             self.env = copy.copy(os.environ)
             self.env.update({'MOZ_NO_REMOTE':"1",})
         else:
             self.env = env
-        self.aggressively_kill = aggressively_kill
-        self.kp_kwargs = kp_kwargs
+        self.kp_kwargs = kp_kwargs or {}
 
     def find_binary(self):
         """Finds the binary for self.names if one was not provided."""
         binary = None
         if sys.platform in ('linux2', 'sunos5', 'solaris'):
             for name in reversed(self.names):
                 binary = findInPath(name)
         elif os.name == 'nt' or sys.platform == 'cygwin':
@@ -501,19 +476,16 @@ class Runner(object):
                     self.process_handler.pid = pid
                     self.process_handler.kill()
         else:
             try:
                 self.process_handler.kill(group=True)
             except Exception, e:
                 logger.error('Cannot kill process, '+type(e).__name__+' '+e.message)
 
-        for name in self.aggressively_kill:
-            kill_process_by_name(name)
-
     def stop(self):
         self.kill()
 
 class FirefoxRunner(Runner):
     """Specialized Runner subclass for running Firefox."""
 
     app_name = 'Firefox'
     profile_class = FirefoxProfile
--- a/testing/mozmill/mozrunner/mozrunner/wpk.py
+++ b/testing/mozmill/mozrunner/mozrunner/wpk.py
@@ -44,21 +44,16 @@ def get_pids(process_name):
     return pids
 
 def kill_pid(pid):
     process = windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid)
     if process:
         windll.kernel32.TerminateProcess(process, 0)
         windll.kernel32.CloseHandle(process)
 
-def kill_process_by_name(name):
-    pids = get_pids(name)
-    for pid in pids:
-        kill_pid(pid)
-
 if __name__ == '__main__':
     import subprocess
     import time
 
     # This test just opens a new notepad instance and kills it.
 
     name = 'notepad'