1
1
"""
2
- Test lldb-dap setBreakpoints request
2
+ Test lldb-dap threads request
3
3
"""
4
4
5
5
from lldbsuite .test .decorators import *
9
9
10
10
11
11
class TestDAP_threads (lldbdap_testcase .DAPTestCaseBase ):
12
- @skipIfWindows
13
12
def test_correct_thread (self ):
14
13
"""
15
14
Tests that the correct thread is selected if we continue from
@@ -19,7 +18,7 @@ def test_correct_thread(self):
19
18
"""
20
19
program = self .getBuildArtifact ("a.out" )
21
20
self .build_and_launch (program )
22
- source = "main.c "
21
+ source = "main.cpp "
23
22
breakpoint_line = line_number (source , "// break here" )
24
23
lines = [breakpoint_line ]
25
24
# Set breakpoint in the thread function
@@ -42,8 +41,10 @@ def test_correct_thread(self):
42
41
)
43
42
self .assertFalse (stopped_event [0 ]["body" ]["preserveFocusHint" ])
44
43
self .assertTrue (stopped_event [0 ]["body" ]["threadCausedFocus" ])
44
+ # All threads should be named Thread {index}
45
+ threads = self .dap_server .get_threads ()
46
+ self .assertTrue (all (len (t ["name" ]) > 0 for t in threads ))
45
47
46
- @skipIfWindows
47
48
def test_thread_format (self ):
48
49
"""
49
50
Tests the support for custom thread formats.
@@ -54,7 +55,7 @@ def test_thread_format(self):
54
55
customThreadFormat = "This is thread index #${thread.index}" ,
55
56
stopCommands = ["thread list" ],
56
57
)
57
- source = "main.c "
58
+ source = "main.cpp "
58
59
breakpoint_line = line_number (source , "// break here" )
59
60
lines = [breakpoint_line ]
60
61
# Set breakpoint in the thread function
@@ -63,8 +64,18 @@ def test_thread_format(self):
63
64
len (breakpoint_ids ), len (lines ), "expect correct number of breakpoints"
64
65
)
65
66
self .continue_to_breakpoints (breakpoint_ids )
66
- # We are stopped at the second thread
67
+ # We are stopped at the first thread
67
68
threads = self .dap_server .get_threads ()
68
69
print ("got thread" , threads )
69
- self .assertEqual (threads [0 ]["name" ], "This is thread index #1" )
70
- self .assertEqual (threads [1 ]["name" ], "This is thread index #2" )
70
+ if self .getPlatform () == "windows" :
71
+ # Windows creates a thread pool once WaitForSingleObject is called
72
+ # by thread.join(). As we are in the thread function, we can't be
73
+ # certain that join() has been called yet and a thread pool has
74
+ # been created, thus we only check for the first two threads.
75
+ names = list (sorted (t ["name" ] for t in threads ))[:2 ]
76
+ self .assertEqual (
77
+ names , ["This is thread index #1" , "This is thread index #2" ]
78
+ )
79
+ else :
80
+ self .assertEqual (threads [0 ]["name" ], "This is thread index #1" )
81
+ self .assertEqual (threads [1 ]["name" ], "This is thread index #2" )
0 commit comments