Johnny Chen | 05178f6 | 2011-03-04 23:40:06 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb 'process connect' command. |
| 3 | """ |
| 4 | |
Johnny Chen | ea76c4f | 2011-04-22 21:47:07 +0000 | [diff] [blame] | 5 | import os |
Johnny Chen | 05178f6 | 2011-03-04 23:40:06 +0000 | [diff] [blame] | 6 | import unittest2 |
| 7 | import lldb |
Johnny Chen | ea76c4f | 2011-04-22 21:47:07 +0000 | [diff] [blame] | 8 | import pexpect |
Johnny Chen | 05178f6 | 2011-03-04 23:40:06 +0000 | [diff] [blame] | 9 | from lldbtest import * |
| 10 | |
| 11 | class ConnectRemoteTestCase(TestBase): |
| 12 | |
| 13 | mydir = "connect_remote" |
| 14 | |
Johnny Chen | af4ab42 | 2011-03-08 23:35:45 +0000 | [diff] [blame] | 15 | @unittest2.expectedFailure |
Johnny Chen | 05178f6 | 2011-03-04 23:40:06 +0000 | [diff] [blame] | 16 | def test_connect_remote(self): |
| 17 | """Test "process connect connect:://localhost:12345".""" |
| 18 | |
| 19 | # First, we'll start a fake debugserver (a simple echo server). |
Johnny Chen | ea76c4f | 2011-04-22 21:47:07 +0000 | [diff] [blame] | 20 | fakeserver = pexpect.spawn('./EchoServer.py') |
Johnny Chen | 05178f6 | 2011-03-04 23:40:06 +0000 | [diff] [blame] | 21 | |
Johnny Chen | ea76c4f | 2011-04-22 21:47:07 +0000 | [diff] [blame] | 22 | # Turn on logging for what the child sends back. |
| 23 | if self.TraceOn(): |
Johnny Chen | ea0d135 | 2011-04-22 21:56:22 +0000 | [diff] [blame] | 24 | fakeserver.logfile_read = sys.stdout |
Johnny Chen | ea76c4f | 2011-04-22 21:47:07 +0000 | [diff] [blame] | 25 | |
Johnny Chen | 35c3ae9 | 2011-04-22 21:50:08 +0000 | [diff] [blame] | 26 | # Schedule the fake debugserver to be shutting down during teardown. |
Johnny Chen | ea76c4f | 2011-04-22 21:47:07 +0000 | [diff] [blame] | 27 | def shutdown_fakeserver(): |
| 28 | fakeserver.close() |
| 29 | self.addTearDownHook(shutdown_fakeserver) |
| 30 | |
| 31 | # Wait until we receive the server ready message before continuing. |
Johnny Chen | 0934268 | 2011-05-03 22:14:19 +0000 | [diff] [blame] | 32 | fakeserver.expect_exact('Listening on localhost:12345') |
Johnny Chen | ea76c4f | 2011-04-22 21:47:07 +0000 | [diff] [blame] | 33 | |
| 34 | # Connect to the fake server.... |
Johnny Chen | 05178f6 | 2011-03-04 23:40:06 +0000 | [diff] [blame] | 35 | self.runCmd("process connect connect://localhost:12345") |
| 36 | |
| 37 | |
| 38 | if __name__ == '__main__': |
| 39 | import atexit |
| 40 | lldb.SBDebugger.Initialize() |
| 41 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 42 | unittest2.main() |