This changes Python API tests to use a single build shared across all test functions, instead of the previous default behavior of a separate build dir for each test function. This build behavior opt-out, tests can use the previous behavior of one individual (unshared) build directory per test function, by setting `SHARED_BUILD_TESTCASE` to False (in the test class). The motivation is to make the test suite more efficient, by not repeatedly building the same test source. When running tests on my macOS machine, this reduces the time of `ninja check-lldb-api` by almost 60% (sample numbers: from ~492s down to ~207s = 58%). Almost 5min time saved. Each test function still calls `self.build()`, but only the first call will do a build, in the subsequent tests `make` will be a no-op because the sources won't have changed.
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
import gdbremote_testcase
|
|
import random
|
|
import socket
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbgdbserverutils import Server
|
|
import lldbsuite.test.lldbplatformutil
|
|
from lldbgdbserverutils import Pipe
|
|
|
|
|
|
class TestGdbRemoteConnection(gdbremote_testcase.GdbRemoteTestCaseBase):
|
|
SHARED_BUILD_TESTCASE = False
|
|
|
|
@skipIfRemote # reverse connect is not a supported use case for now
|
|
def test_reverse_connect(self):
|
|
# Reverse connect is the default connection method.
|
|
self.connect_to_debug_monitor()
|
|
# Verify we can do the handshake. If that works, we'll call it good.
|
|
self.do_handshake()
|
|
|
|
@skipIfRemote
|
|
def test_named_pipe(self):
|
|
family, type, proto, _, addr = socket.getaddrinfo(
|
|
self.stub_hostname, 0, proto=socket.IPPROTO_TCP
|
|
)[0]
|
|
self.sock = socket.socket(family, type, proto)
|
|
self.sock.settimeout(self.DEFAULT_TIMEOUT)
|
|
|
|
self.addTearDownHook(lambda: self.sock.close())
|
|
|
|
pipe = Pipe(self.getBuildDir())
|
|
|
|
self.addTearDownHook(lambda: pipe.close())
|
|
|
|
args = self.debug_monitor_extra_args
|
|
if lldb.remote_platform:
|
|
args += ["*:0"]
|
|
else:
|
|
args += ["localhost:0"]
|
|
|
|
args += ["--named-pipe", pipe.name]
|
|
|
|
server = self.spawnSubprocess(
|
|
self.debug_monitor_exe, args, install_remote=False
|
|
)
|
|
|
|
pipe.finish_connection(self.DEFAULT_TIMEOUT)
|
|
port = pipe.read(10, self.DEFAULT_TIMEOUT)
|
|
# Trim null byte, convert to int
|
|
addr = (addr[0], int(port[:-1]))
|
|
self.sock.connect(addr)
|
|
self._server = Server(self.sock, server)
|
|
|
|
# Verify we can do the handshake. If that works, we'll call it good.
|
|
self.do_handshake()
|