22Test lldb-dap attach request
33"""
44
5-
65import dap_server
76from lldbsuite .test .decorators import *
87from lldbsuite .test .lldbtest import *
@@ -25,7 +24,7 @@ def spawn_and_wait(program, delay):
2524 process .wait ()
2625
2726
28- @skipIf
27+ @skip
2928class TestDAP_attach (lldbdap_testcase .DAPTestCaseBase ):
3029 def set_and_hit_breakpoint (self , continueToExit = True ):
3130 source = "main.c"
@@ -45,8 +44,7 @@ def test_by_pid(self):
4544 """
4645 Tests attaching to a process by process ID.
4746 """
48- self .build_and_create_debug_adapter ()
49- program = self .getBuildArtifact ("a.out" )
47+ program = self .build_and_create_debug_adapter_for_attach ()
5048 self .process = subprocess .Popen (
5149 [program ],
5250 stdin = subprocess .PIPE ,
@@ -61,34 +59,15 @@ def test_by_name(self):
6159 """
6260 Tests attaching to a process by process name.
6361 """
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 )
62+ program = self .build_and_create_debug_adapter_for_attach ()
7563
7664 # Use a file as a synchronization point between test and inferior.
7765 pid_file_path = lldbutil .append_to_process_working_directory (
7866 self , "pid_file_%d" % (int (time .time ()))
7967 )
8068
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-
8969 popen = self .spawnSubprocess (program , [pid_file_path ])
90-
91- pid = lldbutil .wait_for_file_on_target (self , pid_file_path )
70+ lldbutil .wait_for_file_on_target (self , pid_file_path )
9271
9372 self .attach (program = program )
9473 self .set_and_hit_breakpoint (continueToExit = True )
@@ -101,8 +80,7 @@ def test_by_name_waitFor(self):
10180 next instance of a process to be launched, ingoring all current
10281 ones.
10382 """
104- self .build_and_create_debug_adapter ()
105- program = self .getBuildArtifact ("a.out" )
83+ program = self .build_and_create_debug_adapter_for_attach ()
10684 self .spawn_thread = threading .Thread (
10785 target = spawn_and_wait ,
10886 args = (
@@ -136,8 +114,8 @@ def test_commands(self):
136114 "terminateCommands" are a list of LLDB commands that get executed when
137115 the debugger session terminates.
138116 """
139- self .build_and_create_debug_adapter ()
140- program = self . getBuildArtifact ( "a.out" )
117+ program = self .build_and_create_debug_adapter_for_attach ()
118+
141119 # Here we just create a target and launch the process as a way to test
142120 # if we are able to use attach commands to create any kind of a target
143121 # and use it for debugging
@@ -209,8 +187,8 @@ def test_terminate_commands(self):
209187 Tests that the "terminateCommands", that can be passed during
210188 attach, are run when the debugger is disconnected.
211189 """
212- self .build_and_create_debug_adapter ()
213- program = self . getBuildArtifact ( "a.out" )
190+ program = self .build_and_create_debug_adapter_for_attach ()
191+
214192 # Here we just create a target and launch the process as a way to test
215193 # if we are able to use attach commands to create any kind of a target
216194 # and use it for debugging
0 commit comments