Skip to content

Commit a9d02c8

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 2d09028 commit a9d02c8

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
@@ -103,6 +103,7 @@
103103
lldb_platform_name = None
104104
lldb_platform_url = None
105105
lldb_platform_working_dir = None
106+
lldb_platform_available_ports = None
106107

107108
# Apple SDK
108109
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
@@ -749,6 +749,10 @@ def getSourcePath(self, name):
749749
"""Return absolute path to a file in the test's source directory."""
750750
return os.path.join(self.getSourceDir(), name)
751751

752+
def getPlatformAvailablePorts(self):
753+
"""Return ports available for connection to a lldb server on the remote platform."""
754+
return configuration.lldb_platform_available_ports
755+
752756
@classmethod
753757
def setUpCommands(cls):
754758
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, 7999)
189192

190193
def reset_test_sequence(self):

0 commit comments

Comments
 (0)