13cd8d7b1SGongyu Dengimport tempfile 23cd8d7b1SGongyu Dengimport gdbremote_testcase 33cd8d7b1SGongyu Dengfrom lldbsuite.test.lldbtest import * 43cd8d7b1SGongyu Dengfrom lldbsuite.test.decorators import * 53cd8d7b1SGongyu Dengfrom lldbgdbserverutils import * 63cd8d7b1SGongyu Deng 73cd8d7b1SGongyu Dengclass GdbRemoteCompletionTestCase(gdbremote_testcase.GdbRemoteTestCaseBase): 83cd8d7b1SGongyu Deng mydir = TestBase.compute_mydir(__file__) 93cd8d7b1SGongyu Deng 103cd8d7b1SGongyu Deng def init_lldb_server(self): 113cd8d7b1SGongyu Deng self.debug_monitor_exe = get_lldb_server_exe() 123cd8d7b1SGongyu Deng if not self.debug_monitor_exe: 133cd8d7b1SGongyu Deng self.skipTest("lldb-server exe not found") 143cd8d7b1SGongyu Deng port_file = tempfile.NamedTemporaryFile().name 153cd8d7b1SGongyu Deng commandline_args = [ 163cd8d7b1SGongyu Deng "platform", 173cd8d7b1SGongyu Deng "--listen", 183cd8d7b1SGongyu Deng "*:0", 193cd8d7b1SGongyu Deng "--socket-file", 203cd8d7b1SGongyu Deng port_file 213cd8d7b1SGongyu Deng ] 223cd8d7b1SGongyu Deng server = self.spawnSubprocess( 233cd8d7b1SGongyu Deng get_lldb_server_exe(), 243cd8d7b1SGongyu Deng commandline_args, 253cd8d7b1SGongyu Deng install_remote=False) 263cd8d7b1SGongyu Deng self.assertIsNotNone(server) 273cd8d7b1SGongyu Deng self.stub_hostname = "localhost" 283cd8d7b1SGongyu Deng self.port = int(lldbutil.wait_for_file_on_target(self, port_file)) 293cd8d7b1SGongyu Deng self.sock = self.create_socket() 30*a2f4f7daSPavel Labath self._server = Server(self.sock, server) 313cd8d7b1SGongyu Deng 323cd8d7b1SGongyu Deng self.add_no_ack_remote_stream() 333cd8d7b1SGongyu Deng 343cd8d7b1SGongyu Deng def generate_hex_path(self, target): 353cd8d7b1SGongyu Deng return str(os.path.join(self.getBuildDir(), target)).encode().hex() 363cd8d7b1SGongyu Deng 373cd8d7b1SGongyu Deng @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet 383cd8d7b1SGongyu Deng @llgs_test 393cd8d7b1SGongyu Deng def test_autocomplete_path(self): 403cd8d7b1SGongyu Deng self.build() 413cd8d7b1SGongyu Deng self.init_lldb_server() 423cd8d7b1SGongyu Deng 433cd8d7b1SGongyu Deng # Test file-included completion when flag is set to 0. 443cd8d7b1SGongyu Deng self.test_sequence.add_log_lines( 453cd8d7b1SGongyu Deng ["read packet: $qPathComplete:0,{}#00".format( 463cd8d7b1SGongyu Deng self.generate_hex_path("main")), 473cd8d7b1SGongyu Deng "send packet: $M{},{}#00".format( 483cd8d7b1SGongyu Deng self.generate_hex_path("main.d"), 493cd8d7b1SGongyu Deng self.generate_hex_path("main.o")) 503cd8d7b1SGongyu Deng ], 513cd8d7b1SGongyu Deng True) 523cd8d7b1SGongyu Deng 533cd8d7b1SGongyu Deng # Test directory-only completion when flag is set to 1. 543cd8d7b1SGongyu Deng os.makedirs(os.path.join(self.getBuildDir(), "test")) 553cd8d7b1SGongyu Deng self.test_sequence.add_log_lines( 563cd8d7b1SGongyu Deng ["read packet: $qPathComplete:1,{}#00".format( 573cd8d7b1SGongyu Deng self.generate_hex_path("tes")), 583cd8d7b1SGongyu Deng "send packet: $M{}{}#00".format( 593cd8d7b1SGongyu Deng self.generate_hex_path("test"), 603cd8d7b1SGongyu Deng os.path.sep.encode().hex()) # "test/" or "test\". 613cd8d7b1SGongyu Deng ], 623cd8d7b1SGongyu Deng True) 633cd8d7b1SGongyu Deng 643cd8d7b1SGongyu Deng self.expect_gdbremote_sequence() 65