1import lldb
2import binascii
3import os
4from lldbsuite.test.lldbtest import *
5from lldbsuite.test.decorators import *
6from gdbclientutils import *
7
8
9class TestProcessConnect(GDBRemoteTestBase):
10    def test_gdb_remote_sync(self):
11        """Test the gdb-remote command in synchronous mode"""
12        try:
13            self.dbg.SetAsync(False)
14            self.expect("gdb-remote %d" % self.server.port,
15                        substrs=['Process', 'stopped'])
16        finally:
17            self.dbg.GetSelectedPlatform().DisconnectRemote()
18
19    def test_gdb_remote_async(self):
20        """Test the gdb-remote command in asynchronous mode"""
21        try:
22            self.dbg.SetAsync(True)
23            self.expect("gdb-remote %d" % self.server.port,
24                        matching=False,
25                        substrs=['Process', 'stopped'])
26            lldbutil.expect_state_changes(self, self.dbg.GetListener(),
27                                          self.process(), [lldb.eStateStopped])
28        finally:
29            self.dbg.GetSelectedPlatform().DisconnectRemote()
30
31    def test_process_connect_sync(self):
32        """Test the gdb-remote command in synchronous mode"""
33        try:
34            self.dbg.SetAsync(False)
35            self.expect("process connect connect://localhost:%d" %
36                        self.server.port,
37                        substrs=['Process', 'stopped'])
38        finally:
39            self.dbg.GetSelectedPlatform().DisconnectRemote()
40
41    def test_process_connect_async(self):
42        """Test the gdb-remote command in asynchronous mode"""
43        try:
44            self.dbg.SetAsync(True)
45            self.expect("process connect connect://localhost:%d" %
46                        self.server.port,
47                        matching=False,
48                        substrs=['Process', 'stopped'])
49            lldbutil.expect_state_changes(self, self.dbg.GetListener(),
50                                          self.process(), [lldb.eStateStopped])
51        finally:
52            self.dbg.GetSelectedPlatform().DisconnectRemote()
53