Skip to content

Commit 2557310

Browse files
committed
[lldb] add --platform-available-ports option to the dotest.py
This patch adds --platform-available-ports option to the dotest.py script to remove hardcoded gdb ports from lldb testsuite. Currently, this option could be helpful for GdbRemoteTestCases (e.g. TestLldbGdbServer, TestNonStop, TestGdbRemoteThreadsInStopReply, TestGdbRemotePlatformFile, TestGdbRemote_vCont)
1 parent 95c24cb commit 2557310

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

lldb/packages/Python/lldbsuite/test/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
lldb_platform_name = None
100100
lldb_platform_url = None
101101
lldb_platform_working_dir = None
102+
lldb_platform_available_ports = None
102103

103104
# Apple SDK
104105
apple_sdk = None

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ def parseOptionsAndInitTestdirs():
419419
configuration.lldb_platform_url = args.lldb_platform_url
420420
if args.lldb_platform_working_dir:
421421
configuration.lldb_platform_working_dir = args.lldb_platform_working_dir
422+
if args.lldb_platform_available_ports:
423+
configuration.lldb_platform_available_ports = args.lldb_platform_available_ports
422424
if platform_system == "Darwin" and args.apple_sdk:
423425
configuration.apple_sdk = args.apple_sdk
424426
if args.test_build_dir:

lldb/packages/Python/lldbsuite/test/dotest_args.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ def create_parser():
292292
metavar="platform-working-dir",
293293
help="The directory to use on the remote platform.",
294294
)
295+
group.add_argument(
296+
"--platform-available-ports",
297+
dest="lldb_platform_available_ports",
298+
type=lambda ports: [int(port.strip()) for port in ports.split(":")],
299+
metavar="platform-available-ports",
300+
help="Ports available for connection to a lldb server on the remote platform",
301+
)
295302

296303
# Test-suite behaviour
297304
group = parser.add_argument_group("Runtime behaviour options")

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ def getSourcePath(self, name):
747747
"""Return absolute path to a file in the test's source directory."""
748748
return os.path.join(self.getSourceDir(), name)
749749

750+
def getPlatformAvailablePorts(self):
751+
"""Return ports available for connection to a lldb server on the remote platform."""
752+
return configuration.lldb_platform_available_ports
753+
750754
@classmethod
751755
def setUpCommands(cls):
752756
commands = [

lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ def setUpServerLogging(self, is_llgs):
185185
]
186186

187187
def get_next_port(self):
188+
available_ports = self.getPlatformAvailablePorts()
189+
if available_ports:
190+
return random.choice(available_ports)
188191
return 12000 + random.randint(0, 3999)
189192

190193
def reset_test_sequence(self):

0 commit comments

Comments
 (0)