Bug 816630 - B2G xpcshell tests use wrong binary directory, r=jgriffin, DONTBUILD a=NPOTB,test-only
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 30 Nov 2012 11:25:40 -0500
changeset 114609 d743a639162da4313098959f0bc3d43aab3509fe
parent 114608 f3ee32cc5b88502d2c8f7e902c0ea946260aa8a1
child 114610 ce1e1e13511b3e34387e4ab34a59737c41d0cca0
push id23926
push userryanvm@gmail.com
push dateSat, 01 Dec 2012 15:27:30 +0000
treeherdermozilla-central@ecdf0e332f17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin, DONTBUILD, NPOTB, test-only
bugs816630
milestone20.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 816630 - B2G xpcshell tests use wrong binary directory, r=jgriffin, DONTBUILD a=NPOTB,test-only
testing/xpcshell/remotexpcshelltests.py
testing/xpcshell/runtestsb2g.py
--- a/testing/xpcshell/remotexpcshelltests.py
+++ b/testing/xpcshell/remotexpcshelltests.py
@@ -14,18 +14,18 @@ from mozdevice import devicemanagerADB, 
 here = os.path.dirname(os.path.abspath(__file__))
 
 # A specialization of XPCShellTests that runs tests on an Android device
 # via devicemanager.
 class XPCShellRemote(xpcshell.XPCShellTests, object):
 
     def __init__(self, devmgr, options, args):
         xpcshell.XPCShellTests.__init__(self)
-        self.localLib = None
-        self.localBin = None
+        self.localLib = options.localLib
+        self.localBin = options.localBin
         self.options = options
         self.device = devmgr
         self.pathMapping = []
         self.remoteTestRoot = self.device.getTestRoot("xpcshell")
         # Terse directory names are used here ("b" for a binaries directory)
         # to minimize the length of the command line used to execute
         # xpcshell on the remote device. adb has a limit to the number
         # of characters used in a shell command, and the xpcshell command
@@ -93,24 +93,16 @@ class XPCShellRemote(xpcshell.XPCShellTe
           self.device.mkDir(self.remoteScriptsDir)
         if (not self.device.dirExists(self.remoteComponentsDir)):
           self.device.mkDir(self.remoteComponentsDir)
 
         local = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'head.js')
         remoteFile = self.remoteJoin(self.remoteScriptsDir, "head.js")
         self.device.pushFile(local, remoteFile)
 
-        if not self.localBin:
-          self.localBin = os.path.join(self.options.objdir, "dist/bin")
-          if not os.path.exists(self.localBin):
-            self.localBin = os.path.join(self.options.objdir, "bin")
-            if not os.path.exists(self.localBin):
-              print >>sys.stderr, "Error: could not find bin in objdir"
-              sys.exit(1)
-
         local = os.path.join(self.localBin, "xpcshell")
         remoteFile = self.remoteJoin(self.remoteBinDir, "xpcshell")
         self.device.pushFile(local, remoteFile)
 
         local = os.path.join(self.localBin, "components/httpd.js")
         remoteFile = self.remoteJoin(self.remoteComponentsDir, "httpd.js")
         self.device.pushFile(local, remoteFile)
 
@@ -124,27 +116,16 @@ class XPCShellRemote(xpcshell.XPCShellTe
 
         if self.options.localAPK:
           remoteFile = self.remoteJoin(self.remoteBinDir, os.path.basename(self.options.localAPK))
           self.device.pushFile(self.options.localAPK, remoteFile)
 
         self.pushLibs()
 
     def pushLibs(self):
-        if not self.localLib:
-          if self.options.localAPK:
-            self.localLib = os.path.join(self.options.objdir, "dist/fennec")
-            if not os.path.exists(self.localLib):
-              self.localLib = os.path.join(self.options.objdir, "fennec/lib")
-              if not os.path.exists(self.localLib):
-                print >>sys.stderr, "Error: could not find libs in objdir"
-                sys.exit(1)
-          else:
-            self.localLib = os.path.join(self.options.objdir, 'dist/bin')
-
         for file in os.listdir(self.localLib):
           if (file.endswith(".so")):
             print >> sys.stderr, "Pushing %s.." % file
             if 'libxul' in file:
               print >> sys.stderr, "This is a big file, it could take a while."
             remoteFile = self.remoteJoin(self.remoteBinDir, file)
             self.device.pushFile(os.path.join(self.localLib, file), remoteFile)
 
@@ -375,28 +356,71 @@ class RemoteXPCShellOptions(xpcshell.XPC
                         help = "local path to Fennec APK")
         defaults["localAPK"] = None
 
         self.add_option("--noSetup", action="store_false",
                         dest = "setup",
                         help = "do not copy any files to device (to be used only if device is already setup)")
         defaults["setup"] = True
 
+        self.add_option("--local-lib-dir", action="store",
+                        type = "string", dest = "localLib",
+                        help = "local path to library directory")
+        defaults["localLib"] = None
+
+        self.add_option("--local-bin-dir", action="store",
+                        type = "string", dest = "localBin",
+                        help = "local path to bin directory")
+        defaults["localBin"] = None
+
         self.set_defaults(**defaults)
 
+    def verifyRemoteOptions(self, options):
+        if options.localLib is None:
+            if options.localAPK and options.objdir:
+                for path in ['dist/fennec', 'fennec/lib']:
+                    options.localLib = os.path.join(options.objdir, path)
+                    if os.path.isdir(options.localLib):
+                        break
+                else:
+                    self.error("Couldn't find local library dir, specify --local-lib-dir")
+            elif options.objdir:
+                options.localLib = os.path.join(options.objdir, 'dist/bin')
+            elif os.path.isfile(os.path.join(here, '..', 'bin', 'xpcshell')):
+                # assume tests are being run from a tests.zip
+                options.localLib = os.path.abspath(os.path.join(here, '..', 'bin'))
+            else:
+                self.error("Couldn't find local library dir, specify --local-lib-dir")
+
+        if options.localBin is None:
+            if options.objdir:
+                for path in ['dist/bin', 'bin']:
+                    options.localBin = os.path.join(options.objdir, path)
+                    if os.path.isdir(options.localBin):
+                        break
+                else:
+                    self.error("Couldn't find local binary dir, specify --local-bin-dir")
+            elif os.path.isfile(os.path.join(here, '..', 'bin', 'xpcshell')):
+                # assume tests are being run from a tests.zip
+                options.localBin = os.path.abspath(os.path.join(here, '..', 'bin'))
+            else:
+                self.error("Couldn't find local binary dir, specify --local-bin-dir")
+        return options
+
 class PathMapping:
 
     def __init__(self, localDir, remoteDir):
         self.local = localDir
         self.remote = remoteDir
 
 def main():
 
     parser = RemoteXPCShellOptions()
     options, args = parser.parse_args()
+    options = parser.verifyRemoteOptions(options)
 
     if len(args) < 1 and options.manifest is None:
       print >>sys.stderr, """Usage: %s <test dirs>
            or: %s --manifest=test.manifest """ % (sys.argv[0], sys.argv[0])
       sys.exit(1)
 
     if (options.dm_trans == "adb"):
       if (options.deviceIP):
--- a/testing/xpcshell/runtestsb2g.py
+++ b/testing/xpcshell/runtestsb2g.py
@@ -13,25 +13,20 @@ from remotexpcshelltests import XPCShell
 from automationutils import *
 from mozdevice import devicemanagerADB
 
 DEVICE_TEST_ROOT = '/data/local/tests'
 
 
 from marionette import Marionette
 
-
 class B2GXPCShellRemote(XPCShellRemote):
 
     # Overridden
     def setupUtilities(self):
-        if self.options.xrePath:
-            self.localLib = self.options.xrePath
-            self.localBin = self.options.xrePath
-
         if self.options.clean:
             # Ensure a fresh directory structure for our tests
             self.clean()
             self.device.mkDir(DEVICE_TEST_ROOT)
 
         XPCShellRemote.setupUtilities(self)
 
     def clean(self):
@@ -142,32 +137,31 @@ class B2GOptions(RemoteXPCShellOptions):
         defaults['busybox'] = None
 
         defaults['dm_trans'] = 'adb'
         defaults['debugger'] = None
         defaults['debuggerArgs'] = None
 
         self.set_defaults(**defaults)
 
+    def verifyRemoteOptions(self, options):
+        if options.b2g_path is None:
+            self.error("Need to specify a --b2gpath")
+
+        if options.geckoPath and not options.emulator:
+            self.error("You must specify --emulator if you specify --gecko-path")
+
+        if options.logcat_dir and not options.emulator:
+            self.error("You must specify --emulator if you specify --logcat-dir")
+        return RemoteXPCShellOptions.verifyRemoteOptions(self, options)
 
 def main():
     parser = B2GOptions()
     options, args = parser.parse_args()
-
-    if options.b2g_path is None:
-        parser.error("Need to specify a --b2gpath")
-
-    if options.xrePath is None:
-        parser.error("Need to specify a --xre-path")
-
-    if options.geckoPath and not options.emulator:
-        self.error("You must specify --emulator if you specify --gecko-path")
-
-    if options.logcat_dir and not options.emulator:
-        self.error("You must specify --emulator if you specify --logcat-dir")
+    options = parser.verifyRemoteOptions(options)
 
     # Create the Marionette instance
     kwargs = {}
     if options.emulator:
         kwargs['emulator'] = options.emulator
         if options.no_window:
             kwargs['noWindow'] = True
         if options.geckoPath: