Skip to content

Commit e6bd01e

Browse files
[lldb] Test running lldb-server through symlink
1 parent 6f2d070 commit e6bd01e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,42 @@ def test_platform_process_launch_gdb_server(self):
5858

5959
self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
6060
self.expect("run", substrs=["unable to launch a GDB server on"], error=True)
61+
62+
@skipIfRemote
63+
@skipUnlessPlatform(["linux"])
64+
@add_test_categories(["lldb-server"])
65+
def test_lldb_server_weird_symlinks(self):
66+
self.build()
67+
68+
hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0]
69+
listen_url = "[%s]:0" % hostname
70+
71+
port_file = self.getBuildArtifact("port")
72+
commandline_args = [
73+
"platform",
74+
"--listen",
75+
listen_url,
76+
"--socket-file",
77+
port_file,
78+
]
79+
80+
# Run lldb-server from a symlink without any binary called "lldb-server" in the directory.
81+
new_lldb_server = self.getBuildArtifact(
82+
"lldb-server-with-an-unconventional-name"
83+
)
84+
os.symlink(lldbgdbserverutils.get_lldb_server_exe(), new_lldb_server)
85+
86+
proc = self.spawnSubprocess(new_lldb_server, commandline_args)
87+
socket_id = lldbutil.wait_for_file_on_target(self, port_file)
88+
89+
new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
90+
self.dbg.SetSelectedPlatform(new_platform)
91+
92+
connect_url = "connect://[%s]:%s" % (hostname, socket_id)
93+
self.runCmd("platform connect %s" % connect_url)
94+
self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
95+
self.runCmd("run")
96+
self.expect(
97+
"process status",
98+
patterns=["Process .* exited with status = 0"],
99+
)

0 commit comments

Comments
 (0)