Bug 1300163 - Add a --adbpath argument to mochitest Android to allow explicitly setting the adb binary, r?gbrown draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 02 Sep 2016 14:26:16 -0400
changeset 410290 c8f793a43bfbe096b10f62abb1ad89a96546d6e5
parent 410289 8df938a2e7caceae5e987169421d3f0ec25a217a
child 410291 9d4cdd8aa6c9bdc1ffe4f03a2df46a186229e77b
push id28715
push userahalberstadt@mozilla.com
push dateTue, 06 Sep 2016 16:35:28 +0000
reviewersgbrown
bugs1300163
milestone51.0a1
Bug 1300163 - Add a --adbpath argument to mochitest Android to allow explicitly setting the adb binary, r?gbrown In mozdevice, it's possible to pass in the path to the adb binary (rather than requiring it to be on the path). The mochitest android options don't provide any means to set this however (even though the b2g options do). This patch adds that option in. This will be used by the mach environment on interactive loaners. MozReview-Commit-ID: 4lsKGpizfH7
testing/mochitest/mochitest_options.py
testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -989,16 +989,22 @@ class AndroidArguments(ArgumentContainer
           "default": None,
           }],
         [["--dm_trans"],
          {"choices": ["adb", "sut"],
           "default": "adb",
           "help": "The transport to use for communication with the device [default: adb].",
           "suppress": True,
           }],
+        [["--adbpath"],
+         {"dest": "adbPath",
+          "default": None,
+          "help": "Path to adb binary.",
+          "suppress": True,
+          }],
         [["--devicePort"],
          {"dest": "devicePort",
           "type": int,
           "default": 20701,
           "help": "port of remote device to test",
           }],
         [["--remote-product-name"],
          {"dest": "remoteProductName",
@@ -1060,39 +1066,32 @@ class AndroidArguments(ArgumentContainer
     }
 
     def validate(self, parser, options, context):
         """Validate android options."""
 
         if build_obj:
             options.log_mach = '-'
 
+        device_args = {'deviceRoot': options.remoteTestRoot}
         if options.dm_trans == "adb":
+            device_args['adbPath'] = options.adbPath
             if options.deviceIP:
-                options.dm = DroidADB(
-                    options.deviceIP,
-                    options.devicePort,
-                    deviceRoot=options.remoteTestRoot)
+                device_args['host'] = options.deviceIP
+                device_args['port'] = options.devicePort
             elif options.deviceSerial:
-                options.dm = DroidADB(
-                    None,
-                    None,
-                    deviceSerial=options.deviceSerial,
-                    deviceRoot=options.remoteTestRoot)
-            else:
-                options.dm = DroidADB(deviceRoot=options.remoteTestRoot)
+                device_args['deviceSerial'] = options.deviceSerial
+            options.dm = DroidADB(**device_args)
         elif options.dm_trans == 'sut':
             if options.deviceIP is None:
                 parser.error(
                     "If --dm_trans = sut, you must provide a device IP")
-
-            options.dm = DroidSUT(
-                options.deviceIP,
-                options.devicePort,
-                deviceRoot=options.remoteTestRoot)
+            device_args['host'] = options.deviceIP
+            device_args['port'] = options.devicePort
+            options.dm = DroidSUT(**device_args)
 
         if not options.remoteTestRoot:
             options.remoteTestRoot = options.dm.deviceRoot
 
         if options.remoteWebServer is None:
             if os.name != "nt":
                 options.remoteWebServer = moznetwork.get_ip()
             else:
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -30,30 +30,30 @@ class DeviceManagerADB(DeviceManager):
     _useZip = False
     _logcatNeedsRoot = False
     _pollingInterval = 0.01
     _packageName = None
     _tempDir = None
     connected = False
 
     def __init__(self, host=None, port=5555, retryLimit=5, packageName='fennec',
-                 adbPath='adb', deviceSerial=None, deviceRoot=None,
+                 adbPath=None, deviceSerial=None, deviceRoot=None,
                  logLevel=logging.ERROR, autoconnect=True, runAdbAsRoot=False,
                  serverHost=None, serverPort=None, **kwargs):
         DeviceManager.__init__(self, logLevel=logLevel,
                                deviceRoot=deviceRoot)
         self.host = host
         self.port = port
         self.retryLimit = retryLimit
 
         self._serverHost = serverHost
         self._serverPort = serverPort
 
         # the path to adb, or 'adb' to assume that it's on the PATH
-        self._adbPath = adbPath
+        self._adbPath = adbPath or 'adb'
 
         # The serial number of the device to use with adb, used in cases
         # where multiple devices are being managed by the same adb instance.
         self._deviceSerial = deviceSerial
 
         # Some devices do no start adb as root, if allowed you can use
         # this to reboot adbd on the device as root automatically
         self._runAdbAsRoot = runAdbAsRoot