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