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 *
9
8
from lldbsuite .test import lldbutil
10
9
import lldbdap_testcase
11
10
import os
11
+ import uuid
12
12
import shutil
13
13
import subprocess
14
14
import tempfile
@@ -25,7 +25,7 @@ def spawn_and_wait(program, delay):
25
25
process .wait ()
26
26
27
27
28
- @skipIf
28
+ @skip
29
29
class TestDAP_attach (lldbdap_testcase .DAPTestCaseBase ):
30
30
def set_and_hit_breakpoint (self , continueToExit = True ):
31
31
source = "main.c"
@@ -45,8 +45,9 @@ def test_by_pid(self):
45
45
"""
46
46
Tests attaching to a process by process ID.
47
47
"""
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 )
50
51
self .process = subprocess .Popen (
51
52
[program ],
52
53
stdin = subprocess .PIPE ,
@@ -61,34 +62,17 @@ def test_by_name(self):
61
62
"""
62
63
Tests attaching to a process by process name.
63
64
"""
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 )
75
68
76
69
# Use a file as a synchronization point between test and inferior.
77
70
pid_file_path = lldbutil .append_to_process_working_directory (
78
71
self , "pid_file_%d" % (int (time .time ()))
79
72
)
80
73
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
74
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 )
92
76
93
77
self .attach (program = program )
94
78
self .set_and_hit_breakpoint (continueToExit = True )
@@ -136,8 +120,10 @@ def test_commands(self):
136
120
"terminateCommands" are a list of LLDB commands that get executed when
137
121
the debugger session terminates.
138
122
"""
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
+
141
127
# Here we just create a target and launch the process as a way to test
142
128
# if we are able to use attach commands to create any kind of a target
143
129
# and use it for debugging
@@ -209,8 +195,10 @@ def test_terminate_commands(self):
209
195
Tests that the "terminateCommands", that can be passed during
210
196
attach, are run when the debugger is disconnected.
211
197
"""
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
+
214
202
# Here we just create a target and launch the process as a way to test
215
203
# if we are able to use attach commands to create any kind of a target
216
204
# and use it for debugging
0 commit comments