Bug 1079930 - Update mochitest runtestsremote.py to support connecting to device by serial number, r=ahal.
authorBob Clary <bclary@bclary.com>
Wed, 15 Oct 2014 07:09:16 -0700
changeset 210547 c14a85b2d8248b9b9388a285194d01fa8e644662
parent 210546 db0912d0106deb90f48d82c46b73ef84e356351e
child 210548 943a42fff8f47c86219d2e3f1776e121497b6573
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersahal
bugs1079930
milestone36.0a1
Bug 1079930 - Update mochitest runtestsremote.py to support connecting to device by serial number, r=ahal.
testing/mochitest/runtestsremote.py
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -41,16 +41,21 @@ class RemoteOptions(MochitestOptions):
                     help = "Path to remote executable relative to device root using only forward slashes. Either this or app must be specified but not both")
         defaults["remoteAppPath"] = None
 
         self.add_option("--deviceIP", action="store",
                     type = "string", dest = "deviceIP",
                     help = "ip address of remote device to test")
         defaults["deviceIP"] = None
 
+        self.add_option("--deviceSerial", action="store",
+                    type = "string", dest = "deviceSerial",
+                    help = "ip address of remote device to test")
+        defaults["deviceSerial"] = None
+
         self.add_option("--dm_trans", action="store",
                     type = "string", dest = "dm_trans",
                     help = "the transport to use to communicate with device: [adb|sut]; default=sut")
         defaults["dm_trans"] = "sut"
 
         self.add_option("--devicePort", action="store",
                     type = "string", dest = "devicePort",
                     help = "port of remote device to test")
@@ -130,18 +135,18 @@ class RemoteOptions(MochitestOptions):
             if os.name != "nt":
                 options.remoteWebServer = moznetwork.get_ip()
             else:
                 options_logger.error("you must specify a --remote-webserver=<ip address>")
                 return None
 
         options.webServer = options.remoteWebServer
 
-        if (options.deviceIP == None):
-            options_logger.error("you must provide a device IP")
+        if (options.dm_trans == 'sut' and options.deviceIP == None):
+            options_logger.error("If --dm_trans = sut, you must provide a device IP")
             return None
 
         if (options.remoteLogFile == None):
             options.remoteLogFile = options.remoteTestRoot + '/logs/mochitest.log'
 
         if (options.remoteLogFile.count('/') < 1):
             options.remoteLogFile = options.remoteTestRoot + '/' + options.remoteLogFile
 
@@ -595,16 +600,18 @@ def main(args):
 
     parser = RemoteOptions(auto)
     structured.commandline.add_logging_group(parser)
     options, args = parser.parse_args(args)
 
     if (options.dm_trans == "adb"):
         if (options.deviceIP):
             dm = droid.DroidADB(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
+        elif (options.deviceSerial):
+            dm = droid.DroidADB(None, None, deviceSerial=options.deviceSerial, deviceRoot=options.remoteTestRoot)
         else:
             dm = droid.DroidADB(deviceRoot=options.remoteTestRoot)
     else:
          dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
     auto.setDeviceManager(dm)
     options = parser.verifyRemoteOptions(options, auto)
 
     mochitest = MochiRemote(auto, dm, options)