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 93cd8d7b1SGongyu Deng def init_lldb_server(self): 103cd8d7b1SGongyu Deng self.debug_monitor_exe = get_lldb_server_exe() 113cd8d7b1SGongyu Deng if not self.debug_monitor_exe: 123cd8d7b1SGongyu Deng self.skipTest("lldb-server exe not found") 133cd8d7b1SGongyu Deng port_file = tempfile.NamedTemporaryFile().name 143cd8d7b1SGongyu Deng commandline_args = [ 153cd8d7b1SGongyu Deng "platform", 163cd8d7b1SGongyu Deng "--listen", 173cd8d7b1SGongyu Deng "*:0", 183cd8d7b1SGongyu Deng "--socket-file", 193cd8d7b1SGongyu Deng port_file 203cd8d7b1SGongyu Deng ] 213cd8d7b1SGongyu Deng server = self.spawnSubprocess( 223cd8d7b1SGongyu Deng get_lldb_server_exe(), 233cd8d7b1SGongyu Deng commandline_args, 243cd8d7b1SGongyu Deng install_remote=False) 253cd8d7b1SGongyu Deng self.assertIsNotNone(server) 263cd8d7b1SGongyu Deng self.stub_hostname = "localhost" 273cd8d7b1SGongyu Deng self.port = int(lldbutil.wait_for_file_on_target(self, port_file)) 283cd8d7b1SGongyu Deng self.sock = self.create_socket() 29a2f4f7daSPavel Labath self._server = Server(self.sock, server) 303cd8d7b1SGongyu Deng 31*872b1da6SPavel Labath self.do_handshake() 323cd8d7b1SGongyu Deng 333cd8d7b1SGongyu Deng def generate_hex_path(self, target): 343cd8d7b1SGongyu Deng return str(os.path.join(self.getBuildDir(), target)).encode().hex() 353cd8d7b1SGongyu Deng 3676a718eeSPavel Labath @add_test_categories(["llgs"]) 373cd8d7b1SGongyu Deng def test_autocomplete_path(self): 383cd8d7b1SGongyu Deng self.build() 393cd8d7b1SGongyu Deng self.init_lldb_server() 403cd8d7b1SGongyu Deng 413cd8d7b1SGongyu Deng # Test file-included completion when flag is set to 0. 423cd8d7b1SGongyu Deng self.test_sequence.add_log_lines( 433cd8d7b1SGongyu Deng ["read packet: $qPathComplete:0,{}#00".format( 443cd8d7b1SGongyu Deng self.generate_hex_path("main")), 453cd8d7b1SGongyu Deng "send packet: $M{},{}#00".format( 463cd8d7b1SGongyu Deng self.generate_hex_path("main.d"), 473cd8d7b1SGongyu Deng self.generate_hex_path("main.o")) 483cd8d7b1SGongyu Deng ], 493cd8d7b1SGongyu Deng True) 503cd8d7b1SGongyu Deng 513cd8d7b1SGongyu Deng # Test directory-only completion when flag is set to 1. 523cd8d7b1SGongyu Deng os.makedirs(os.path.join(self.getBuildDir(), "test")) 533cd8d7b1SGongyu Deng self.test_sequence.add_log_lines( 543cd8d7b1SGongyu Deng ["read packet: $qPathComplete:1,{}#00".format( 553cd8d7b1SGongyu Deng self.generate_hex_path("tes")), 563cd8d7b1SGongyu Deng "send packet: $M{}{}#00".format( 573cd8d7b1SGongyu Deng self.generate_hex_path("test"), 583cd8d7b1SGongyu Deng os.path.sep.encode().hex()) # "test/" or "test\". 593cd8d7b1SGongyu Deng ], 603cd8d7b1SGongyu Deng True) 613cd8d7b1SGongyu Deng 623cd8d7b1SGongyu Deng self.expect_gdbremote_sequence() 63