11"""
2- Test lldb-dap setBreakpoints request
2+ Test lldb-dap threads request
33"""
44
55from lldbsuite .test .decorators import *
99
1010
1111class TestDAP_threads (lldbdap_testcase .DAPTestCaseBase ):
12- @skipIfWindows
1312 def test_correct_thread (self ):
1413 """
1514 Tests that the correct thread is selected if we continue from
@@ -19,7 +18,7 @@ def test_correct_thread(self):
1918 """
2019 program = self .getBuildArtifact ("a.out" )
2120 self .build_and_launch (program )
22- source = "main.c "
21+ source = "main.cpp "
2322 breakpoint_line = line_number (source , "// break here" )
2423 lines = [breakpoint_line ]
2524 # Set breakpoint in the thread function
@@ -42,8 +41,10 @@ def test_correct_thread(self):
4241 )
4342 self .assertFalse (stopped_event [0 ]["body" ]["preserveFocusHint" ])
4443 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 ))
4547
46- @skipIfWindows
4748 def test_thread_format (self ):
4849 """
4950 Tests the support for custom thread formats.
@@ -54,7 +55,7 @@ def test_thread_format(self):
5455 customThreadFormat = "This is thread index #${thread.index}" ,
5556 stopCommands = ["thread list" ],
5657 )
57- source = "main.c "
58+ source = "main.cpp "
5859 breakpoint_line = line_number (source , "// break here" )
5960 lines = [breakpoint_line ]
6061 # Set breakpoint in the thread function
@@ -63,8 +64,18 @@ def test_thread_format(self):
6364 len (breakpoint_ids ), len (lines ), "expect correct number of breakpoints"
6465 )
6566 self .continue_to_breakpoints (breakpoint_ids )
66- # We are stopped at the second thread
67+ # We are stopped at the first thread
6768 threads = self .dap_server .get_threads ()
6869 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