<p dir="ltr">You coul</p>
<div class="gmail_quote">On Mar 13, 2015 6:38 AM, "Tamas Berghammer" <<a href="mailto:tberghammer@google.com">tberghammer@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi labath,<br>
<br>
Forward adb port for reverse connect test cases<br>
<br>
The test cases in TestStubReverseConnect are using a socket connection from python to lldb-server running on a remote target. To enable the socket connection an adb port forwarding have to be set up when the remote target is android.<br>
<br>
<a href="http://reviews.llvm.org/D8319" target="_blank">http://reviews.llvm.org/D8319</a><br>
<br>
Files:<br>
  test/tools/lldb-server/commandline/TestStubReverseConnect.py<br>
  test/tools/lldb-server/gdbremote_testcase.py<br>
<br>
Index: test/tools/lldb-server/commandline/TestStubReverseConnect.py<br>
===================================================================<br>
--- test/tools/lldb-server/commandline/TestStubReverseConnect.py<br>
+++ test/tools/lldb-server/commandline/TestStubReverseConnect.py<br>
@@ -47,6 +47,10 @@<br>
         self.stub_hostname = "127.0.0.1"<br>
         self.port = self.listener_port<br>
<br>
+        triple = self.dbg.GetSelectedPlatform().GetTriple()<br>
+        if re.match(".*-.*-.*-android", triple):<br>
+            self.forward_adb_port(self.port, self.port, "reverse")<br>
+<br>
         # Start the stub.<br>
         server = self.launch_debug_monitor(logfile=sys.stdout)<br>
         self.assertIsNotNone(server)<br>
Index: test/tools/lldb-server/gdbremote_testcase.py<br>
===================================================================<br>
--- test/tools/lldb-server/gdbremote_testcase.py<br>
+++ test/tools/lldb-server/gdbremote_testcase.py<br>
@@ -173,6 +173,13 @@<br>
         # when the process truly dies.<br>
         self.stub_sends_two_stop_notifications_on_kill = True<br>
<br>
+    def forward_adb_port(self, source, target, direction):<br>
+        def remove_port_forward():<br>
+            subprocess.call(["adb", direction, "--remove", "tcp:%d" % source])<br>
+<br>
+        subprocess.call(["adb", direction, "tcp:%d" % source, "tcp:%d" % target])<br>
+        self.addTearDownHook(remove_port_forward)<br>
+<br>
     def create_socket(self):<br>
         sock = socket.socket()<br>
         logger = self.logger<br>
@@ -194,11 +201,7 @@<br>
<br>
         triple = self.dbg.GetSelectedPlatform().GetTriple()<br>
         if re.match(".*-.*-.*-android", triple):<br>
-            subprocess.call(["adb", "forward", "tcp:%d" % self.port, "tcp:%d" % self.port])<br>
-            def remove_port_forward():<br>
-                subprocess.call(["adb", "forward", "--remove", "tcp:%d" % self.port])<br>
-<br>
-            self.addTearDownHook(remove_port_forward)<br>
+            self.forward_adb_port(self.port, self.port, "forward")<br>
<br>
         connect_info = (self.stub_hostname, self.port)<br>
         # print "connecting to stub on {}:{}".format(connect_info[0], connect_info[1])<br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
<br></blockquote></div>