[Lldb-commits] [lldb] 68bb51a - [lldb] Fix TestAutoInstallMainExecutable.py

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 18 07:21:00 PDT 2021


Author: Pavel Labath
Date: 2021-03-18T15:20:44+01:00
New Revision: 68bb51acd572735d80d20adb2c2fc51a5cbbd88e

URL: https://github.com/llvm/llvm-project/commit/68bb51acd572735d80d20adb2c2fc51a5cbbd88e
DIFF: https://github.com/llvm/llvm-project/commit/68bb51acd572735d80d20adb2c2fc51a5cbbd88e.diff

LOG: [lldb] Fix TestAutoInstallMainExecutable.py

Fix the test to account for recent test infrastructure changes, and make
it run locally to increase the chances of it continuing to work in the
future.

Added: 
    

Modified: 
    lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py b/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
index 5afb57f3ac46..92151cea4e67 100644
--- a/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
+++ b/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -2,61 +2,56 @@
 Test target commands: target.auto-install-main-executable.
 """
 
+import socket
 import time
-import gdbremote_testcase
+import lldbgdbserverutils
 
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 
-class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
+class TestAutoInstallMainExecutable(TestBase):
     mydir = TestBase.compute_mydir(__file__)
+    NO_DEBUG_INFO_TESTCASE = True
 
-    @llgs_test
-    @no_debug_info_test
-    @skipIf(remote=False)
-    @expectedFailureAll(hostoslist=["windows"], triple='.*-android')
+    @skipIfRemote
+    @expectedFailureAll(oslist=["windows"]) # process modules not loaded
     def test_target_auto_install_main_executable(self):
         self.build()
 
-        # Manually install the modified binary.
-        working_dir = lldb.remote_platform.GetWorkingDirectory()
-        src_device = lldb.SBFileSpec(self.getBuildArtifact("a.device.out"))
-        dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out"))
-        err = lldb.remote_platform.Put(src_device, dest)
-        if err.Fail():
-            raise RuntimeError(
-                "Unable copy '%s' to '%s'.\n>>> %s" %
-                (src_device.GetFilename(), working_dir, err.GetCString()))
-
-        m = re.search("^(.*)://([^/]*):(.*)$", configuration.lldb_platform_url)
-        protocol = m.group(1)
-        hostname = m.group(2)
-        hostport = int(m.group(3))
-        listen_url = "*:"+str(hostport+1)
+        hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0]
+        listen_url = "[%s]:0"%hostname
 
+        port_file = self.getBuildArtifact("port")
         commandline_args = [
             "platform",
             "--listen",
             listen_url,
-            "--server"
-            ]
-
+            "--socket-file",
+            port_file]
         self.spawnSubprocess(
-            self.debug_monitor_exe,
-            commandline_args,
-            install_remote=False)
+            lldbgdbserverutils.get_lldb_server_exe(),
+            commandline_args)
 
-        # Wait for the new process gets ready.
-        time.sleep(0.1)
+        socket_id = lldbutil.wait_for_file_on_target(self, port_file)
 
-        self.dbg.SetAsync(False)
-
-        new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
+        new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
         self.dbg.SetSelectedPlatform(new_platform)
 
-        connect_url = "%s://%s:%s" % (protocol, hostname, str(hostport+1))
+        connect_url = "connect://[%s]:%s" % (hostname, socket_id)
+        connect_opts = lldb.SBPlatformConnectOptions(connect_url)
+        self.assertSuccess(new_platform.ConnectRemote(connect_opts))
+
+        wd = self.getBuildArtifact("wd")
+        os.mkdir(wd)
+        new_platform.SetWorkingDirectory(wd)
+
+
+        # Manually install the modified binary.
+        src_device = lldb.SBFileSpec(self.getBuildArtifact("a.device.out"))
+        dest = lldb.SBFileSpec(os.path.join(wd, "a.out"))
+        self.assertSuccess(new_platform.Put(src_device, dest))
 
         # Test the default setting.
         self.expect("settings show target.auto-install-main-executable",
@@ -68,12 +63,9 @@ def test_target_auto_install_main_executable(self):
         self.expect("settings show target.auto-install-main-executable",
             substrs=["target.auto-install-main-executable (boolean) = false"])
 
-        self.runCmd("platform select %s"%configuration.lldb_platform_name)
-        self.runCmd("platform connect %s" % (connect_url))
-
         # Create the target with the original file.
         self.runCmd("target create --remote-file %s %s "%
-                                        (os.path.join(working_dir,dest.GetFilename()),
+                                        (dest.fullpath,
                                             self.getBuildArtifact("a.out")))
 
         target = self.dbg.GetSelectedTarget()


        


More information about the lldb-commits mailing list