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() 30a2f4f7daSPavel Labath self._server = Server(self.sock, server) 313cd8d7b1SGongyu Deng 32*872b1da6SPavel Labath self.do_handshake() 333cd8d7b1SGongyu Deng 343cd8d7b1SGongyu Deng def generate_hex_path(self, target): 353cd8d7b1SGongyu Deng return str(os.path.join(self.getBuildDir(), target)).encode().hex() 363cd8d7b1SGongyu Deng 3776a718eeSPavel Labath @add_test_categories(["llgs"]) 383cd8d7b1SGongyu Deng def test_autocomplete_path(self): 393cd8d7b1SGongyu Deng self.build() 403cd8d7b1SGongyu Deng self.init_lldb_server() 413cd8d7b1SGongyu Deng 423cd8d7b1SGongyu Deng # Test file-included completion when flag is set to 0. 433cd8d7b1SGongyu Deng self.test_sequence.add_log_lines( 443cd8d7b1SGongyu Deng ["read packet: $qPathComplete:0,{}#00".format( 453cd8d7b1SGongyu Deng self.generate_hex_path("main")), 463cd8d7b1SGongyu Deng "send packet: $M{},{}#00".format( 473cd8d7b1SGongyu Deng self.generate_hex_path("main.d"), 483cd8d7b1SGongyu Deng self.generate_hex_path("main.o")) 493cd8d7b1SGongyu Deng ], 503cd8d7b1SGongyu Deng True) 513cd8d7b1SGongyu Deng 523cd8d7b1SGongyu Deng # Test directory-only completion when flag is set to 1. 533cd8d7b1SGongyu Deng os.makedirs(os.path.join(self.getBuildDir(), "test")) 543cd8d7b1SGongyu Deng self.test_sequence.add_log_lines( 553cd8d7b1SGongyu Deng ["read packet: $qPathComplete:1,{}#00".format( 563cd8d7b1SGongyu Deng self.generate_hex_path("tes")), 573cd8d7b1SGongyu Deng "send packet: $M{}{}#00".format( 583cd8d7b1SGongyu Deng self.generate_hex_path("test"), 593cd8d7b1SGongyu Deng os.path.sep.encode().hex()) # "test/" or "test\". 603cd8d7b1SGongyu Deng ], 613cd8d7b1SGongyu Deng True) 623cd8d7b1SGongyu Deng 633cd8d7b1SGongyu Deng self.expect_gdbremote_sequence() 64