2 import gdbremote_testcase
3 from lldbsuite
.test
.lldbtest
import *
4 from lldbsuite
.test
.decorators
import *
5 from lldbgdbserverutils
import *
8 class GdbRemoteCompletionTestCase(gdbremote_testcase
.GdbRemoteTestCaseBase
):
9 def init_lldb_server(self
):
10 self
.debug_monitor_exe
= get_lldb_server_exe()
11 if not self
.debug_monitor_exe
:
12 self
.skipTest("lldb-server exe not found")
13 port_file
= tempfile
.NamedTemporaryFile().name
14 commandline_args
= ["platform", "--listen", "*:0", "--socket-file", port_file
]
15 server
= self
.spawnSubprocess(
16 get_lldb_server_exe(), commandline_args
, install_remote
=False
18 self
.assertIsNotNone(server
)
19 self
.stub_hostname
= "localhost"
20 self
.port
= int(lldbutil
.wait_for_file_on_target(self
, port_file
))
21 self
.sock
= self
.create_socket()
22 self
._server
= Server(self
.sock
, server
)
26 def generate_hex_path(self
, target
):
27 return str(os
.path
.join(self
.getBuildDir(), target
)).encode().hex()
30 @add_test_categories(["llgs"])
31 def test_autocomplete_path(self
):
33 self
.init_lldb_server()
35 # Test file-included completion when flag is set to 0.
36 self
.test_sequence
.add_log_lines(
38 "read packet: $qPathComplete:0,{}#00".format(
39 self
.generate_hex_path("main")
41 "send packet: $M{},{}#00".format(
42 self
.generate_hex_path("main.d"), self
.generate_hex_path("main.o")
48 # Test directory-only completion when flag is set to 1.
49 os
.makedirs(os
.path
.join(self
.getBuildDir(), "test"))
50 self
.test_sequence
.add_log_lines(
52 "read packet: $qPathComplete:1,{}#00".format(
53 self
.generate_hex_path("tes")
55 "send packet: $M{}{}#00".format(
56 self
.generate_hex_path("test"), os
.path
.sep
.encode().hex()
57 ), # "test/" or "test\".
62 self
.expect_gdbremote_sequence()