bug 598507 - wrap test harness process execution with 'arch -arch i386' on OS X 10.5. r=catlee, a=blocking
authorTed Mielczarek <ted.mielczarek@gmail.com>
Thu, 23 Sep 2010 12:19:31 -0400
changeset 54617 0c0e27537b72e2c98f6a65da0599997479d0a786
parent 54616 9549708d2e9008bf57413df8e3811b495f37d4f6
child 54618 8b84f9ba869c9c425ebe64deb8c4707b734b28c2
push idunknown
push userunknown
push dateunknown
reviewerscatlee, blocking
bugs598507
milestone2.0b7pre
bug 598507 - wrap test harness process execution with 'arch -arch i386' on OS X 10.5. r=catlee, a=blocking
build/automation.py.in
build/automationutils.py
testing/xpcshell/runxpcshelltests.py
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -207,16 +207,18 @@ class Automation(object):
                  preexec_fn=None,
                  close_fds=False,
                  shell=False,
                  cwd=None,
                  env=None,
                  universal_newlines=False,
                  startupinfo=None,
                  creationflags=0):
+      args = automationutils.wrapCommand(args)
+      print "args: %s" % args
       subprocess.Popen.__init__(self, args, bufsize, executable,
                                 stdin, stdout, stderr,
                                 preexec_fn, close_fds,
                                 shell, cwd, env,
                                 universal_newlines, startupinfo, creationflags)
       self.log = _log
 
     def kill(self):
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -31,29 +31,30 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK ***** */
 
-import glob, logging, os, shutil, subprocess, sys
+import glob, logging, os, platform, shutil, subprocess, sys
 import re
 from urlparse import urlparse
 
 __all__ = [
   "addCommonOptions",
   "checkForCrashes",
   "dumpLeakLog",
   "isURL",
   "processLeakLog",
   "getDebuggerInfo",
   "DEBUGGER_INFO",
   "replaceBackSlashes",
+  "wrapCommand",
   ]
 
 # Map of debugging programs to information about them, like default arguments
 # and whether or not they are interactive.
 DEBUGGER_INFO = {
   # gdb requires that you supply the '--args' flag in order to pass arguments
   # after the executable name to the executable.
   "gdb": {
@@ -354,8 +355,21 @@ def processLeakLog(leakLogFile, leakThre
       m = pidRegExp.search(fileName)
       if m:
         processType = m.group(1)
         processPID = m.group(2)
       processSingleLeakFile(thisFile, processPID, processType, leakThreshold)
 
 def replaceBackSlashes(input):
   return input.replace('\\', '/')
+
+def wrapCommand(cmd):
+  """
+  If running on OS X 10.5 or older, wrap |cmd| so that it will
+  be executed as an i386 binary, in case it's a 32-bit/64-bit universal
+  binary.
+  """
+  if platform.system() == "Darwin" and \
+     hasattr(platform, 'mac_ver') and \
+     platform.mac_ver()[0][:4] < '10.6':
+    return ["arch", "-arch", "i386"] + cmd
+  # otherwise just execute the command normally
+  return cmd
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -315,16 +315,17 @@ class XPCShellTests(object):
     self.env["XPCOM_MEM_LEAK_LOG"] = leakLogFile
     return leakLogFile
 
   def launchProcess(self, cmd, stdout, stderr, env, cwd):
     """
       Simple wrapper to launch a process.
       On a remote system, this is more complex and we need to overload this function.
     """
+    cmd = wrapCommand(cmd)
     proc = Popen(cmd, stdout=stdout, stderr=stderr, 
                 env=env, cwd=cwd)
     return proc
 
   def communicate(self, proc):
     """
       Simple wrapper to communicate with a process.
       On a remote system, this is overloaded to handle remote process communication.