Bug 1320643 - Remove Device.setup_port_forward from mozrunner; r?jmaher draft
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 02 Dec 2016 19:49:37 +0000
changeset 447635 0a9ccdb4af1ddd05b9fd5c03cc794a792359a89e
parent 447634 e96c6bfc1f21e5ec859ecd52ba679b63b03447cc
child 447636 0c30e5fa4ca63f9a80d910369938938bae097c12
push id38095
push userbmo:ato@mozilla.com
push dateTue, 06 Dec 2016 23:17:59 +0000
reviewersjmaher
bugs1320643
milestone53.0a1
Bug 1320643 - Remove Device.setup_port_forward from mozrunner; r?jmaher The only consumer of `mozrunner.devices.base.Device.setup_port_forward` was Marionette, which now uses `mozdevice.DeviceManagerADB.forward` directly. MozReview-Commit-ID: 72ROrOixKvM
testing/mozbase/mozrunner/mozrunner/devices/base.py
--- a/testing/mozbase/mozrunner/mozrunner/devices/base.py
+++ b/testing/mozbase/mozrunner/mozrunner/devices/base.py
@@ -181,35 +181,16 @@ class Device(object):
         #      while calling adb shell directly does.
         args = [self.app_ctx.adb, '-s', self.dm._deviceSerial,
                 'shell', 'cd /system/bin; chmod 555 busybox;'
                 'for x in `./busybox --list`; do ln -s ./busybox $x; done']
         adb = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
         adb.wait()
         self.dm._verifyZip()
 
-    def setup_port_forwarding(self, local_port=None, remote_port=2828):
-        """
-        Set up TCP port forwarding to the specified port on the device,
-        using any availble local port (if none specified), and return the local port.
-
-        :param local_port: The local port to forward from, if unspecified a
-                           random port is chosen.
-        :param remote_port: The remote port to forward to, defaults to 2828.
-        :returns: The local_port being forwarded.
-        """
-        if not local_port:
-            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-            s.bind(("", 0))
-            local_port = s.getsockname()[1]
-            s.close()
-
-        self.dm.forward('tcp:%d' % int(local_port), 'tcp:%d' % int(remote_port))
-        return local_port
-
     def wait_for_net(self):
         active = False
         time_out = 0
         while not active and time_out < 40:
             proc = subprocess.Popen([self.app_ctx.adb, 'shell', '/system/bin/netcfg'],
                                     stdout=subprocess.PIPE)
             proc.stdout.readline()  # ignore first line
             line = proc.stdout.readline()