199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest target commands: target.auto-install-main-executable. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 568bb51acSPavel Labathimport socket 699451b44SJordan Rupprechtimport time 768bb51acSPavel Labathimport lldbgdbserverutils 899451b44SJordan Rupprecht 999451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 1099451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 1199451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 1299451b44SJordan Rupprecht 1399451b44SJordan Rupprecht 1468bb51acSPavel Labathclass TestAutoInstallMainExecutable(TestBase): 1568bb51acSPavel Labath NO_DEBUG_INFO_TESTCASE = True 1699451b44SJordan Rupprecht 1768bb51acSPavel Labath @skipIfRemote 1858917054SStella Stamenova @skipIfWindows # This test is flaky on Windows 1999451b44SJordan Rupprecht def test_target_auto_install_main_executable(self): 2048e3da13SPavel Labath if lldbgdbserverutils.get_lldb_server_exe() is None: 2148e3da13SPavel Labath self.skipTest("lldb-server not found") 2299451b44SJordan Rupprecht self.build() 2399451b44SJordan Rupprecht 2468bb51acSPavel Labath hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0] 2568bb51acSPavel Labath listen_url = "[%s]:0" % hostname 2699451b44SJordan Rupprecht 2768bb51acSPavel Labath port_file = self.getBuildArtifact("port") 2899451b44SJordan Rupprecht commandline_args = [ 2999451b44SJordan Rupprecht "platform", 3099451b44SJordan Rupprecht "--listen", 3199451b44SJordan Rupprecht listen_url, 3268bb51acSPavel Labath "--socket-file", 33*2238dcc3SJonas Devlieghere port_file, 34*2238dcc3SJonas Devlieghere ] 35*2238dcc3SJonas Devlieghere self.spawnSubprocess(lldbgdbserverutils.get_lldb_server_exe(), commandline_args) 3699451b44SJordan Rupprecht 3768bb51acSPavel Labath socket_id = lldbutil.wait_for_file_on_target(self, port_file) 3899451b44SJordan Rupprecht 3968bb51acSPavel Labath new_platform = lldb.SBPlatform("remote-" + self.getPlatform()) 40a31130f6STatyana Krasnukha self.dbg.SetSelectedPlatform(new_platform) 4199451b44SJordan Rupprecht 4268bb51acSPavel Labath connect_url = "connect://[%s]:%s" % (hostname, socket_id) 4368bb51acSPavel Labath connect_opts = lldb.SBPlatformConnectOptions(connect_url) 4468bb51acSPavel Labath self.assertSuccess(new_platform.ConnectRemote(connect_opts)) 4568bb51acSPavel Labath 4668bb51acSPavel Labath wd = self.getBuildArtifact("wd") 4768bb51acSPavel Labath os.mkdir(wd) 4868bb51acSPavel Labath new_platform.SetWorkingDirectory(wd) 4968bb51acSPavel Labath 5068bb51acSPavel Labath # Manually install the modified binary. 5168bb51acSPavel Labath src_device = lldb.SBFileSpec(self.getBuildArtifact("a.device.out")) 5268bb51acSPavel Labath dest = lldb.SBFileSpec(os.path.join(wd, "a.out")) 5368bb51acSPavel Labath self.assertSuccess(new_platform.Put(src_device, dest)) 5499451b44SJordan Rupprecht 5599451b44SJordan Rupprecht # Test the default setting. 56*2238dcc3SJonas Devlieghere self.expect( 57*2238dcc3SJonas Devlieghere "settings show target.auto-install-main-executable", 5835674976SPavel Labath substrs=["target.auto-install-main-executable (boolean) = true"], 59*2238dcc3SJonas Devlieghere msg="Default settings for target.auto-install-main-executable failed.", 60*2238dcc3SJonas Devlieghere ) 6199451b44SJordan Rupprecht 6299451b44SJordan Rupprecht # Disable the auto install. 6335674976SPavel Labath self.runCmd("settings set target.auto-install-main-executable false") 64*2238dcc3SJonas Devlieghere self.expect( 65*2238dcc3SJonas Devlieghere "settings show target.auto-install-main-executable", 66*2238dcc3SJonas Devlieghere substrs=["target.auto-install-main-executable (boolean) = false"], 67*2238dcc3SJonas Devlieghere ) 6899451b44SJordan Rupprecht 6999451b44SJordan Rupprecht # Create the target with the original file. 70*2238dcc3SJonas Devlieghere self.runCmd( 71*2238dcc3SJonas Devlieghere "target create --remote-file %s %s " 72*2238dcc3SJonas Devlieghere % (dest.fullpath, self.getBuildArtifact("a.out")) 73*2238dcc3SJonas Devlieghere ) 7499451b44SJordan Rupprecht 7548e3da13SPavel Labath self.expect("process launch", substrs=["exited with status = 74"]) 76