Bug 1320643 - Remove Device.setup_port_forward from mozrunner; r=jmaher,whimboo
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 02 Dec 2016 19:49:37 +0000
changeset 325360 d4657cdb08125a7daab950a72066df1332f25f21
parent 325359 29e885d1bf97f479c2719d31ac60f4e2816ceb29
child 325361 d237751e0dea92a3b033a7b44855238c12c9ce86
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjmaher, whimboo
bugs1320643
milestone53.0a1
Bug 1320643 - Remove Device.setup_port_forward from mozrunner; r=jmaher,whimboo 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()