@@ -58,3 +58,45 @@ 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+ self .getBuildArtifact ("a.out" ),
80+ "foo" ,
81+ ]
82+
83+ # Run lldb-server from a symlink without any binary called "lldb-server" in the directory.
84+ llgs_hiding_directory = self .getBuildArtifact ("hiding-directory" )
85+ new_lldb_server_link = self .getBuildArtifact (
86+ "lldb-server-with-an-unconventional-name"
87+ )
88+ new_lldb_server = os .path .join (llgs_hiding_directory , "lldb-server" )
89+ os .makedirs (llgs_hiding_directory )
90+ shutil .copy (lldbgdbserverutils .get_lldb_server_exe (), new_lldb_server )
91+ os .symlink (new_lldb_server , new_lldb_server_link )
92+
93+ self .spawnSubprocess (new_lldb_server_link , commandline_args )
94+ socket_id = lldbutil .wait_for_file_on_target (self , port_file )
95+
96+ new_platform = lldb .SBPlatform ("remote-" + self .getPlatform ())
97+ self .dbg .SetSelectedPlatform (new_platform )
98+
99+ connect_url = "connect://[%s]:%s" % (hostname , socket_id )
100+ self .runCmd ("platform connect %s" % connect_url )
101+ self .runCmd ("target create {}" .format (self .getBuildArtifact ("a.out" )))
102+ self .expect ("run" , error = False )
0 commit comments