22Test lldb-dap attach request
33"""
44
5-
65import dap_server
76from lldbsuite .test .decorators import *
87from lldbsuite .test .lldbtest import *
98from lldbsuite .test import lldbutil
109import lldbdap_testcase
1110import os
11+ import uuid
1212import shutil
1313import subprocess
1414import tempfile
@@ -25,7 +25,7 @@ def spawn_and_wait(program, delay):
2525 process .wait ()
2626
2727
28- @skipIf
28+ @skip
2929class TestDAP_attach (lldbdap_testcase .DAPTestCaseBase ):
3030 def set_and_hit_breakpoint (self , continueToExit = True ):
3131 source = "main.c"
@@ -45,8 +45,9 @@ def test_by_pid(self):
4545 """
4646 Tests attaching to a process by process ID.
4747 """
48- self .build_and_create_debug_adapter ()
49- program = self .getBuildArtifact ("a.out" )
48+ unique_name = str (uuid .uuid4 ())
49+ self .build_and_create_debug_adapter (dictionary = {"EXE" : unique_name })
50+ program = self .getBuildArtifact (unique_name )
5051 self .process = subprocess .Popen (
5152 [program ],
5253 stdin = subprocess .PIPE ,
@@ -61,34 +62,17 @@ def test_by_name(self):
6162 """
6263 Tests attaching to a process by process name.
6364 """
64- self .build_and_create_debug_adapter ()
65- orig_program = self .getBuildArtifact ("a.out" )
66- # Since we are going to attach by process name, we need a unique
67- # process name that has minimal chance to match a process that is
68- # already running. To do this we use tempfile.mktemp() to give us a
69- # full path to a location where we can copy our executable. We then
70- # run this copy to ensure we don't get the error "more that one
71- # process matches 'a.out'".
72- program = tempfile .mktemp ()
73- shutil .copyfile (orig_program , program )
74- shutil .copymode (orig_program , program )
65+ unique_name = str (uuid .uuid4 ())
66+ self .build_and_create_debug_adapter (dictionary = {"EXE" : unique_name })
67+ program = self .getBuildArtifact (unique_name )
7568
7669 # Use a file as a synchronization point between test and inferior.
7770 pid_file_path = lldbutil .append_to_process_working_directory (
7871 self , "pid_file_%d" % (int (time .time ()))
7972 )
8073
81- def cleanup ():
82- if os .path .exists (program ):
83- os .unlink (program )
84- self .run_platform_command ("rm %s" % (pid_file_path ))
85-
86- # Execute the cleanup function during test case tear down.
87- self .addTearDownHook (cleanup )
88-
8974 popen = self .spawnSubprocess (program , [pid_file_path ])
90-
91- pid = lldbutil .wait_for_file_on_target (self , pid_file_path )
75+ lldbutil .wait_for_file_on_target (self , pid_file_path )
9276
9377 self .attach (program = program )
9478 self .set_and_hit_breakpoint (continueToExit = True )
@@ -136,8 +120,10 @@ def test_commands(self):
136120 "terminateCommands" are a list of LLDB commands that get executed when
137121 the debugger session terminates.
138122 """
139- self .build_and_create_debug_adapter ()
140- program = self .getBuildArtifact ("a.out" )
123+ unique_name = str (uuid .uuid4 ())
124+ self .build_and_create_debug_adapter (dictionary = {"EXE" : unique_name })
125+ program = self .getBuildArtifact (unique_name )
126+
141127 # Here we just create a target and launch the process as a way to test
142128 # if we are able to use attach commands to create any kind of a target
143129 # and use it for debugging
@@ -209,8 +195,10 @@ def test_terminate_commands(self):
209195 Tests that the "terminateCommands", that can be passed during
210196 attach, are run when the debugger is disconnected.
211197 """
212- self .build_and_create_debug_adapter ()
213- program = self .getBuildArtifact ("a.out" )
198+ unique_name = str (uuid .uuid4 ())
199+ self .build_and_create_debug_adapter (dictionary = {"EXE" : unique_name })
200+ program = self .getBuildArtifact (unique_name )
201+
214202 # Here we just create a target and launch the process as a way to test
215203 # if we are able to use attach commands to create any kind of a target
216204 # and use it for debugging
0 commit comments