Bug 975085 - Don't create unnecessary devicemanager instance in b2g emulator tests, r=jgriffin
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 20 Feb 2014 16:56:57 -0500
changeset 170119 bb4e11e818fe400abf57ff103266f77cf5f28a31
parent 170118 1acdcb6714972eb6a2556f1f055182251c2795dd
child 170120 6db7636b8b19edf874927b6a0809f7b191bf5d79
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjgriffin
bugs975085
milestone30.0a1
Bug 975085 - Don't create unnecessary devicemanager instance in b2g emulator tests, r=jgriffin
layout/tools/reftest/runreftestb2g.py
testing/mochitest/runtestsb2g.py
testing/xpcshell/runtestsb2g.py
--- a/layout/tools/reftest/runreftestb2g.py
+++ b/layout/tools/reftest/runreftestb2g.py
@@ -500,24 +500,26 @@ def run_remote_reftests(parser, options,
         kwargs['homedir'] = options.b2gPath
     if options.marionette:
         host,port = options.marionette.split(':')
         kwargs['host'] = host
         kwargs['port'] = int(port)
     marionette = Marionette.getMarionetteOrExit(**kwargs)
     auto.marionette = marionette
 
-    # create the DeviceManager
-    kwargs = {'adbPath': options.adbPath,
-              'deviceRoot': options.remoteTestRoot}
-    if options.deviceIP:
-        kwargs.update({'host': options.deviceIP,
-                       'port': options.devicePort})
-
-    dm = DeviceManagerADB(**kwargs)
+    if options.emulator:
+        dm = marionette.emulator.dm
+    else:
+        # create the DeviceManager
+        kwargs = {'adbPath': options.adbPath,
+                  'deviceRoot': options.remoteTestRoot}
+        if options.deviceIP:
+            kwargs.update({'host': options.deviceIP,
+                           'port': options.devicePort})
+        dm = DeviagerADB(**kwargs)
     auto.setDeviceManager(dm)
 
     options = parser.verifyRemoteOptions(options)
 
     if (options == None):
         print "ERROR: Invalid options specified, use --help for a list of valid options"
         sys.exit(1)
 
--- a/testing/mochitest/runtestsb2g.py
+++ b/testing/mochitest/runtestsb2g.py
@@ -305,23 +305,27 @@ def run_remote_mochitests(parser, option
         kwargs['homedir'] = options.b2gPath
     if options.marionette:
         host, port = options.marionette.split(':')
         kwargs['host'] = host
         kwargs['port'] = int(port)
 
     marionette = Marionette.getMarionetteOrExit(**kwargs)
 
-    # create the DeviceManager
-    kwargs = {'adbPath': options.adbPath,
-              'deviceRoot': options.remoteTestRoot}
-    if options.deviceIP:
-        kwargs.update({'host': options.deviceIP,
-                       'port': options.devicePort})
-    dm = DeviceManagerADB(**kwargs)
+    if options.emulator:
+        dm = marionette.emulator.dm
+    else:
+        # create the DeviceManager
+        kwargs = {'adbPath': options.adbPath,
+                  'deviceRoot': options.remoteTestRoot}
+        if options.deviceIP:
+            kwargs.update({'host': options.deviceIP,
+                           'port': options.devicePort})
+        dm = DeviceManagerADB(**kwargs)
+
     options = parser.verifyRemoteOptions(options)
     if (options == None):
         print "ERROR: Invalid options specified, use --help for a list of valid options"
         sys.exit(1)
 
     mochitest = B2GDeviceMochitest(marionette, dm, options.profile_data_dir, options.xrePath,
                                    remote_test_root=options.remoteTestRoot,
                                    remote_log_file=options.remoteLogFile)
--- a/testing/xpcshell/runtestsb2g.py
+++ b/testing/xpcshell/runtestsb2g.py
@@ -178,23 +178,26 @@ def main():
         host, port = options.address.split(':')
         kwargs['host'] = host
         kwargs['port'] = int(port)
         kwargs['baseurl'] = 'http://%s:%d/' % (host, int(port))
         if options.emulator:
             kwargs['connectToRunningEmulator'] = True
     marionette = Marionette(**kwargs)
 
-    # Create the DeviceManager instance
-    kwargs = {'adbPath': options.adb_path}
-    if options.deviceIP:
-        kwargs['host'] = options.deviceIP
-        kwargs['port'] = options.devicePort
-    kwargs['deviceRoot'] = options.remoteTestRoot
-    dm = devicemanagerADB.DeviceManagerADB(**kwargs)
+    if options.emulator:
+        dm = marionette.emulator.dm
+    else:
+        # Create the DeviceManager instance
+        kwargs = {'adbPath': options.adb_path}
+        if options.deviceIP:
+            kwargs['host'] = options.deviceIP
+            kwargs['port'] = options.devicePort
+        kwargs['deviceRoot'] = options.remoteTestRoot
+        dm = devicemanagerADB.DeviceManagerADB(**kwargs)
 
     if not options.remoteTestRoot:
         options.remoteTestRoot = dm.getDeviceRoot()
     xpcsh = B2GXPCShellRemote(dm, options, args)
 
     # we don't run concurrent tests on mobile
     options.sequential = True