Skip to content

Commit dca7e03

Browse files
authored
[lldb] add --platform-available-ports option to the dotest.py (#112555)
This patch adds --platform-available-ports option to the dotest.py script to avoid hardcoded gdb ports in lldb testsuite. Currently, this option could be helpful in GdbRemoteTestCases (e.g. TestLldbGdbServer, TestNonStop, TestGdbRemoteThreadsInStopReply, TestGdbRemotePlatformFile, TestGdbRemote_vCont)
1 parent 7581cb6 commit dca7e03

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ 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+
nargs="*",
299+
type=int,
300+
metavar="platform-available-ports",
301+
help="Ports available for connection to a lldb server on the remote platform",
302+
)
295303

296304
# Test-suite behaviour
297305
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ def setUpServerLogging(self, is_llgs):
185185
]
186186

187187
def get_next_port(self):
188+
if available_ports := self.getPlatformAvailablePorts():
189+
return random.choice(available_ports)
188190
return 12000 + random.randint(0, 7999)
189191

190192
def reset_test_sequence(self):

0 commit comments

Comments
 (0)