2
2
Test lldb-dap attach request
3
3
"""
4
4
5
-
6
5
import dap_server
7
6
from lldbsuite .test .decorators import *
8
7
from lldbsuite .test .lldbtest import *
@@ -25,7 +24,7 @@ def spawn_and_wait(program, delay):
25
24
process .wait ()
26
25
27
26
28
- @skipIf
27
+ @skip
29
28
class TestDAP_attach (lldbdap_testcase .DAPTestCaseBase ):
30
29
def set_and_hit_breakpoint (self , continueToExit = True ):
31
30
source = "main.c"
@@ -45,8 +44,7 @@ def test_by_pid(self):
45
44
"""
46
45
Tests attaching to a process by process ID.
47
46
"""
48
- self .build_and_create_debug_adapter ()
49
- program = self .getBuildArtifact ("a.out" )
47
+ program = self .build_and_create_debug_adapter_for_attach ()
50
48
self .process = subprocess .Popen (
51
49
[program ],
52
50
stdin = subprocess .PIPE ,
@@ -61,34 +59,15 @@ def test_by_name(self):
61
59
"""
62
60
Tests attaching to a process by process name.
63
61
"""
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 ()
75
63
76
64
# Use a file as a synchronization point between test and inferior.
77
65
pid_file_path = lldbutil .append_to_process_working_directory (
78
66
self , "pid_file_%d" % (int (time .time ()))
79
67
)
80
68
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
-
89
69
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 )
92
71
93
72
self .attach (program = program )
94
73
self .set_and_hit_breakpoint (continueToExit = True )
@@ -101,8 +80,7 @@ def test_by_name_waitFor(self):
101
80
next instance of a process to be launched, ingoring all current
102
81
ones.
103
82
"""
104
- self .build_and_create_debug_adapter ()
105
- program = self .getBuildArtifact ("a.out" )
83
+ program = self .build_and_create_debug_adapter_for_attach ()
106
84
self .spawn_thread = threading .Thread (
107
85
target = spawn_and_wait ,
108
86
args = (
@@ -136,8 +114,8 @@ def test_commands(self):
136
114
"terminateCommands" are a list of LLDB commands that get executed when
137
115
the debugger session terminates.
138
116
"""
139
- self .build_and_create_debug_adapter ()
140
- program = self . getBuildArtifact ( "a.out" )
117
+ program = self .build_and_create_debug_adapter_for_attach ()
118
+
141
119
# Here we just create a target and launch the process as a way to test
142
120
# if we are able to use attach commands to create any kind of a target
143
121
# and use it for debugging
@@ -209,8 +187,8 @@ def test_terminate_commands(self):
209
187
Tests that the "terminateCommands", that can be passed during
210
188
attach, are run when the debugger is disconnected.
211
189
"""
212
- self .build_and_create_debug_adapter ()
213
- program = self . getBuildArtifact ( "a.out" )
190
+ program = self .build_and_create_debug_adapter_for_attach ()
191
+
214
192
# Here we just create a target and launch the process as a way to test
215
193
# if we are able to use attach commands to create any kind of a target
216
194
# and use it for debugging
0 commit comments