Skip to content

[lldb] add --platform-available-ports option to the dotest.py #112555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/packages/Python/lldbsuite/test/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
lldb_platform_name = None
lldb_platform_url = None
lldb_platform_working_dir = None
lldb_platform_available_ports = None

# Apple SDK
apple_sdk = None
Expand Down
2 changes: 2 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ def parseOptionsAndInitTestdirs():
configuration.lldb_platform_url = args.lldb_platform_url
if args.lldb_platform_working_dir:
configuration.lldb_platform_working_dir = args.lldb_platform_working_dir
if args.lldb_platform_available_ports:
configuration.lldb_platform_available_ports = args.lldb_platform_available_ports
if platform_system == "Darwin" and args.apple_sdk:
configuration.apple_sdk = args.apple_sdk
if args.test_build_dir:
Expand Down
8 changes: 8 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ def create_parser():
metavar="platform-working-dir",
help="The directory to use on the remote platform.",
)
group.add_argument(
"--platform-available-ports",
dest="lldb_platform_available_ports",
nargs="*",
type=int,
metavar="platform-available-ports",
help="Ports available for connection to a lldb server on the remote platform",
)

# Test-suite behaviour
group = parser.add_argument_group("Runtime behaviour options")
Expand Down
4 changes: 4 additions & 0 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ def getSourcePath(self, name):
"""Return absolute path to a file in the test's source directory."""
return os.path.join(self.getSourceDir(), name)

def getPlatformAvailablePorts(self):
"""Return ports available for connection to a lldb server on the remote platform."""
return configuration.lldb_platform_available_ports

@classmethod
def setUpCommands(cls):
commands = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def setUpServerLogging(self, is_llgs):
]

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

def reset_test_sequence(self):
Expand Down