54 lines · python
1import gdbremote_testcase2import random3import socket4from lldbsuite.test.decorators import *5from lldbsuite.test.lldbtest import *6from lldbgdbserverutils import Server7import lldbsuite.test.lldbplatformutil8from lldbgdbserverutils import Pipe9 10 11class TestGdbRemoteConnection(gdbremote_testcase.GdbRemoteTestCaseBase):12 @skipIfRemote # reverse connect is not a supported use case for now13 def test_reverse_connect(self):14 # Reverse connect is the default connection method.15 self.connect_to_debug_monitor()16 # Verify we can do the handshake. If that works, we'll call it good.17 self.do_handshake()18 19 @skipIfRemote20 def test_named_pipe(self):21 family, type, proto, _, addr = socket.getaddrinfo(22 self.stub_hostname, 0, proto=socket.IPPROTO_TCP23 )[0]24 self.sock = socket.socket(family, type, proto)25 self.sock.settimeout(self.DEFAULT_TIMEOUT)26 27 self.addTearDownHook(lambda: self.sock.close())28 29 pipe = Pipe(self.getBuildDir())30 31 self.addTearDownHook(lambda: pipe.close())32 33 args = self.debug_monitor_extra_args34 if lldb.remote_platform:35 args += ["*:0"]36 else:37 args += ["localhost:0"]38 39 args += ["--named-pipe", pipe.name]40 41 server = self.spawnSubprocess(42 self.debug_monitor_exe, args, install_remote=False43 )44 45 pipe.finish_connection(self.DEFAULT_TIMEOUT)46 port = pipe.read(10, self.DEFAULT_TIMEOUT)47 # Trim null byte, convert to int48 addr = (addr[0], int(port[:-1]))49 self.sock.connect(addr)50 self._server = Server(self.sock, server)51 52 # Verify we can do the handshake. If that works, we'll call it good.53 self.do_handshake()54