Bug 1079931 - Update reftest remotereftest.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 210548 943a42fff8f47c86219d2e3f1776e121497b6573
parent 210547 c14a85b2d8248b9b9388a285194d01fa8e644662
child 210549 3af437d9bb50577866ac61d12cde411ef68d06c4
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersahal
bugs1079931
milestone36.0a1
Bug 1079931 - Update reftest remotereftest.py to support connecting to device by serial number, r=ahal.
layout/tools/reftest/remotereftest.py
--- a/layout/tools/reftest/remotereftest.py
+++ b/layout/tools/reftest/remotereftest.py
@@ -37,16 +37,21 @@ class RemoteOptions(ReftestOptions):
                     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 = "adb serial number of remote device to test")
+        defaults["deviceSerial"] = None
+
         self.add_option("--devicePort", action="store",
                     type = "string", dest = "devicePort",
                     help = "port of remote device to test")
         defaults["devicePort"] = 20701
 
         self.add_option("--remote-product-name", action="store",
                     type = "string", dest = "remoteProductName",
                     help = "Name of product to test - either fennec or firefox, defaults to fennec")
@@ -444,24 +449,26 @@ class RemoteReftest(RefTest):
             except:
                 print "Warning: cleaning up pidfile '%s' was unsuccessful from the test harness" % self.pidFile
 
 def main(args):
     automation = RemoteAutomation(None)
     parser = RemoteOptions(automation)
     options, args = parser.parse_args()
 
-    if (options.deviceIP == None):
-        print "Error: you must provide a device IP to connect to via the --device option"
+    if (options.dm_trans == 'sut' and options.deviceIP == None):
+        print "Error: If --dm_trans = sut, you must provide a device IP to connect to via the --deviceIP option"
         return 1
 
     try:
         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(None, None, deviceRoot=options.remoteTestRoot)
         else:
             dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
     except devicemanager.DMError:
         print "Automation Error: exception while initializing devicemanager.  Most likely the device is not in a testable state."
         return 1