-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
[lldb] add --platform-available-ports option to the dotest.py #112555
Conversation
@llvm/pr-subscribers-lldb Author: None (dlav-sc) ChangesThis 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) Full diff: https://github.com/llvm/llvm-project/pull/112555.diff 5 Files Affected:
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py
index 1bacd74a968c31..c54f8d6a3962f8 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -99,6 +99,7 @@
lldb_platform_name = None
lldb_platform_url = None
lldb_platform_working_dir = None
+lldb_platform_available_ports = None
# Apple SDK
apple_sdk = None
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 681ea1638f2d6f..7cc8f2985043e6 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -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:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index a80428ebec5891..18047fdca2a921 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -292,6 +292,13 @@ 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",
+ type=lambda ports: [int(port.strip()) for port in ports.split(":")],
+ 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")
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8884ef5933ada8..112f139518f393 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -747,6 +747,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 = [
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 8c8e4abed0b454..f7516d26d01d79 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -185,6 +185,9 @@ def setUpServerLogging(self, is_llgs):
]
def get_next_port(self):
+ available_ports = self.getPlatformAvailablePorts()
+ if available_ports:
+ return random.choice(available_ports)
return 12000 + random.randint(0, 3999)
def reset_test_sequence(self):
|
@dlav-sc do you still have an interest in this? If not, I will close this PR. |
Hi @DavidSpickett, I believe I still need this patch for two reasons:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I didn't realise it generated them randomly, though I don't know what else it was going to do :)
Do you need a CMake variable for this too? I wonder how you are getting the argument to dotest.
For example https://lab.llvm.org/buildbot/#/builders/195/builds/5784/steps/6/logs/stdio uses CMake variables.
No harm adding one for this, as I see the other platform_ ones already there.
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
Outdated
Show resolved
Hide resolved
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)
2557310
to
1148438
Compare
✅ With the latest revision this PR passed the Python code formatter. |
Yeah, me too, so I've decided to retain the old behavior if
I don't think I really need a separate CMake flag here. Currently, the |
1148438
to
b38b96c
Compare
b38b96c
to
bee4395
Compare
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
Outdated
Show resolved
Hide resolved
This change is fine now I just want to understand whether you'll still get test cases competing for ports even with this option. |
…12555) 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)
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)