brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 165fae7 Raw
76 lines · python
1"""2Test target commands: target.auto-install-main-executable.3"""4 5import socket6import time7import lldbgdbserverutils8 9from lldbsuite.test.decorators import *10from lldbsuite.test.lldbtest import *11from lldbsuite.test import lldbutil12 13 14class TestAutoInstallMainExecutable(TestBase):15    NO_DEBUG_INFO_TESTCASE = True16 17    @skipIfRemote18    @skipIfWindows  # This test is flaky on Windows19    def test_target_auto_install_main_executable(self):20        if lldbgdbserverutils.get_lldb_server_exe() is None:21            self.skipTest("lldb-server not found")22        self.build()23 24        hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0]25        listen_url = "[%s]:0" % hostname26 27        port_file = self.getBuildArtifact("port")28        commandline_args = [29            "platform",30            "--listen",31            listen_url,32            "--socket-file",33            port_file,34        ]35        self.spawnSubprocess(lldbgdbserverutils.get_lldb_server_exe(), commandline_args)36 37        socket_id = lldbutil.wait_for_file_on_target(self, port_file)38 39        new_platform = lldb.SBPlatform("remote-" + self.getPlatform())40        self.dbg.SetSelectedPlatform(new_platform)41 42        connect_url = "connect://[%s]:%s" % (hostname, socket_id)43        connect_opts = lldb.SBPlatformConnectOptions(connect_url)44        self.assertSuccess(new_platform.ConnectRemote(connect_opts))45 46        wd = self.getBuildArtifact("wd")47        os.mkdir(wd)48        new_platform.SetWorkingDirectory(wd)49 50        # Manually install the modified binary.51        src_device = lldb.SBFileSpec(self.getBuildArtifact("a.device.out"))52        dest = lldb.SBFileSpec(os.path.join(wd, "a.out"))53        self.assertSuccess(new_platform.Put(src_device, dest))54 55        # Test the default setting.56        self.expect(57            "settings show target.auto-install-main-executable",58            substrs=["target.auto-install-main-executable (boolean) = true"],59            msg="Default settings for target.auto-install-main-executable failed.",60        )61 62        # Disable the auto install.63        self.runCmd("settings set target.auto-install-main-executable false")64        self.expect(65            "settings show target.auto-install-main-executable",66            substrs=["target.auto-install-main-executable (boolean) = false"],67        )68 69        # Create the target with the original file.70        self.runCmd(71            "target create --remote-file %s %s "72            % (dest.fullpath, self.getBuildArtifact("a.out"))73        )74 75        self.expect("process launch", substrs=["exited with status = 74"])76