[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed May 29 00:07:27 PDT 2024
================
@@ -0,0 +1,142 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbgdbserverutils
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+import socket
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+ def get_free_port(self):
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind(("", 0))
+ port = s.getsockname()[1]
+ s.close()
+ return port
----------------
labath wrote:
That's better (for some definition of the word), but it still doesn't guarantee you avoid races. The fact that the port is free at this point doesn't guarantee the port will still be free when the lldb-server attempts to use it. When running the test suite, you can have a hundred of tests attempting to allocate ports in parallel, so it's just a matter of time before something collides. What you really want is for lldb-server to allocate the port and let the test suite know which port it has chosen without closing it in between (that's what the code I pointed you to does).
https://github.com/llvm/llvm-project/pull/91570
More information about the lldb-commits
mailing list