Skip to content

Commit 2a39024

Browse files
committed
Update Python tests for lldb-server on Windows
Summary: Thanks to Hui Huang and reviewers for all the help with this patch! Reviewers: labath, jfb, clayborg Reviewed By: labath Subscribers: Hui, clayborg, dexonsmith, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D61687 llvm-svn: 368776
1 parent 2a312fc commit 2a39024

17 files changed

+87
-17
lines changed

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,8 @@ def run_suite():
12161216
# Don't do debugserver tests on anything except OS X.
12171217
configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform
12181218

1219-
# Don't do lldb-server (llgs) tests on anything except Linux.
1220-
configuration.dont_do_llgs_test = not ("linux" in target_platform)
1219+
# Don't do lldb-server (llgs) tests on anything except Linux and Windows.
1220+
configuration.dont_do_llgs_test = not ("linux" in target_platform) and not ("windows" in target_platform)
12211221

12221222
# Collect tests from the specified testing directories. If a test
12231223
# subdirectory filter is explicitly specified, limit the search to that

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def supports_auxv(self):
104104
# tests don't get skipped.
105105
#
106106

107+
@skipIfWindows # no auxv support.
107108
@llgs_test
108109
def test_supports_auxv_llgs(self):
109110
self.init_llgs_test()
@@ -127,6 +128,7 @@ def test_auxv_data_is_correct_size_debugserver(self):
127128
self.set_inferior_startup_launch()
128129
self.auxv_data_is_correct_size()
129130

131+
@skipIfWindows
130132
@llgs_test
131133
def test_auxv_data_is_correct_size_llgs(self):
132134
self.init_llgs_test()
@@ -165,6 +167,7 @@ def test_auxv_keys_look_valid_debugserver(self):
165167
self.set_inferior_startup_launch()
166168
self.auxv_keys_look_valid()
167169

170+
@skipIfWindows
168171
@llgs_test
169172
def test_auxv_keys_look_valid_llgs(self):
170173
self.init_llgs_test()
@@ -212,6 +215,7 @@ def test_auxv_chunked_reads_work_debugserver(self):
212215
self.set_inferior_startup_launch()
213216
self.auxv_chunked_reads_work()
214217

218+
@skipIfWindows
215219
@llgs_test
216220
def test_auxv_chunked_reads_work_llgs(self):
217221
self.init_llgs_test()

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteKill.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
1414
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
1515

1616
def attach_commandline_kill_after_initial_stop(self):
17+
reg_expr = r"^\$[XW][0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}"
1718
procs = self.prep_debug_monitor_and_inferior()
1819
self.test_sequence.add_log_lines([
1920
"read packet: $k#6b",
20-
{"direction": "send", "regex": r"^\$X[0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}"},
21+
{"direction": "send", "regex": reg_expr},
2122
], True)
2223

2324
if self.stub_sends_two_stop_notifications_on_kill:
2425
# Add an expectation for a second X result for stubs that send two
2526
# of these.
2627
self.test_sequence.add_log_lines([
27-
{"direction": "send", "regex": r"^\$X[0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}"},
28+
{"direction": "send", "regex": reg_expr},
2829
], True)
2930

3031
self.expect_gdbremote_sequence()

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import print_function
22

3-
3+
import json
44
import gdbremote_testcase
55
import lldbgdbserverutils
66
from lldbsuite.support import seven
@@ -20,9 +20,9 @@ def module_info(self):
2020
info = self.parse_process_info_response(context)
2121

2222
self.test_sequence.add_log_lines([
23-
'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % (
24-
lldbutil.append_to_process_working_directory(self, "a.out"),
25-
seven.unhexlify(info["triple"])),
23+
'read packet: $jModulesInfo:%s]#00' % json.dumps(
24+
[{"file":lldbutil.append_to_process_working_directory(self, "a.out"),
25+
"triple":seven.unhexlify(info["triple"])}]),
2626
{"direction": "send",
2727
"regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}',
2828
"capture": {1: "spec"}},

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteProcessInfo.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,11 @@ def test_qProcessInfo_contains_cputype_cpusubtype_llgs_darwin(self):
174174
self.build()
175175
self.qProcessInfo_contains_keys(set(['cputype', 'cpusubtype']))
176176

177-
@skipUnlessPlatform(["linux"])
178177
@llgs_test
179-
def test_qProcessInfo_contains_triple_llgs_linux(self):
178+
def test_qProcessInfo_contains_triple_ppid_llgs(self):
180179
self.init_llgs_test()
181180
self.build()
182-
self.qProcessInfo_contains_keys(set(['triple']))
181+
self.qProcessInfo_contains_keys(set(['triple', 'parent-pid']))
183182

184183
@skipUnlessDarwin
185184
@debugserver_test
@@ -202,9 +201,9 @@ def test_qProcessInfo_does_not_contain_triple_llgs_darwin(self):
202201
# for the remote Host and Process.
203202
self.qProcessInfo_does_not_contain_keys(set(['triple']))
204203

205-
@skipUnlessPlatform(["linux"])
204+
@skipIfDarwin
206205
@llgs_test
207-
def test_qProcessInfo_does_not_contain_cputype_cpusubtype_llgs_linux(self):
206+
def test_qProcessInfo_does_not_contain_cputype_cpusubtype_llgs(self):
208207
self.init_llgs_test()
209208
self.build()
210209
self.qProcessInfo_does_not_contain_keys(set(['cputype', 'cpusubtype']))

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteSingleStep.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_single_step_only_steps_one_instruction_with_s_debugserver(self):
2020
self.single_step_only_steps_one_instruction(
2121
use_Hc_packet=True, step_instruction="s")
2222

23+
@skipIfWindows # No pty support to test any inferior std -i/e/o
2324
@llgs_test
2425
@expectedFailureAndroid(
2526
bugnumber="llvm.org/pr24739",

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ def test_stop_reply_reports_multiple_threads_debugserver(self):
205205
self.set_inferior_startup_launch()
206206
self.stop_reply_reports_multiple_threads(5)
207207

208+
# In current implementation of llgs on Windows, as a response to '\x03' packet, the debugger
209+
# of the native process will trigger a call to DebugBreakProcess that will create a new thread
210+
# to handle the exception debug event. So one more stop thread will be notified to the
211+
# delegate, e.g. llgs. So tests below to assert the stop threads number will all fail.
212+
@expectedFailureAll(oslist=["windows"])
208213
@llgs_test
209214
def test_stop_reply_reports_multiple_threads_llgs(self):
210215
self.init_llgs_test()
@@ -226,6 +231,7 @@ def test_no_QListThreadsInStopReply_supplies_no_threads_debugserver(self):
226231
self.set_inferior_startup_launch()
227232
self.no_QListThreadsInStopReply_supplies_no_threads(5)
228233

234+
@expectedFailureAll(oslist=["windows"])
229235
@llgs_test
230236
def test_no_QListThreadsInStopReply_supplies_no_threads_llgs(self):
231237
self.init_llgs_test()
@@ -263,6 +269,7 @@ def test_stop_reply_reports_correct_threads_debugserver(self):
263269
self.set_inferior_startup_launch()
264270
self.stop_reply_reports_correct_threads(5)
265271

272+
@expectedFailureAll(oslist=["windows"])
266273
@llgs_test
267274
def test_stop_reply_reports_correct_threads_llgs(self):
268275
self.init_llgs_test()
@@ -287,6 +294,7 @@ def stop_reply_contains_thread_pcs(self, thread_count):
287294
self.assertTrue(int(stop_reply_pcs[thread_id], 16)
288295
== int(threads_info_pcs[thread_id], 16))
289296

297+
@expectedFailureAll(oslist=["windows"])
290298
@llgs_test
291299
def test_stop_reply_contains_thread_pcs_llgs(self):
292300
self.init_llgs_test()

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
5454
# Wait until all threads have started.
5555
threads = self.wait_for_thread_count(thread_count, timeout_seconds=3)
5656
self.assertIsNotNone(threads)
57-
self.assertEqual(len(threads), thread_count)
57+
58+
# On Windows, there could be more threads spawned. For example, DebugBreakProcess will
59+
# create a new thread from the debugged process to handle an exception event. So here we
60+
# assert 'GreaterEqual' condition.
61+
triple = self.dbg.GetSelectedPlatform().GetTriple()
62+
if re.match(".*-.*-windows", triple):
63+
self.assertGreaterEqual(len(threads), thread_count)
64+
else:
65+
self.assertEqual(len(threads), thread_count)
5866

5967
# Grab stop reply for each thread via qThreadStopInfo{tid:hex}.
6068
stop_replies = {}
@@ -101,7 +109,12 @@ def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
101109

102110
def qThreadStopInfo_works_for_multiple_threads(self, thread_count):
103111
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
104-
self.assertEqual(len(stop_replies), thread_count)
112+
triple = self.dbg.GetSelectedPlatform().GetTriple()
113+
# Consider one more thread created by calling DebugBreakProcess.
114+
if re.match(".*-.*-windows", triple):
115+
self.assertGreaterEqual(len(stop_replies), thread_count)
116+
else:
117+
self.assertEqual(len(stop_replies), thread_count)
105118

106119
@debugserver_test
107120
def test_qThreadStopInfo_works_for_multiple_threads_debugserver(self):
@@ -130,7 +143,13 @@ def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
130143
stop_replies.values()) if stop_reason != 0)
131144

132145
# All but one thread should report no stop reason.
133-
self.assertEqual(no_stop_reason_count, thread_count - 1)
146+
triple = self.dbg.GetSelectedPlatform().GetTriple()
147+
148+
# Consider one more thread created by calling DebugBreakProcess.
149+
if re.match(".*-.*-windows", triple):
150+
self.assertGreaterEqual(no_stop_reason_count, thread_count - 1)
151+
else:
152+
self.assertEqual(no_stop_reason_count, thread_count - 1)
134153

135154
# Only one thread should should indicate a stop reason.
136155
self.assertEqual(with_stop_reason_count, 1)
@@ -172,7 +191,8 @@ def test_qThreadStopInfo_has_valid_thread_names_debugserver(self):
172191
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out")
173192

174193
# test requires OS with set, equal thread names by default.
175-
@skipUnlessPlatform(["linux"])
194+
# Windows thread does not have name property, equal names as the process's by default.
195+
@skipUnlessPlatform(["linux", "windows"])
176196
@llgs_test
177197
def test_qThreadStopInfo_has_valid_thread_names_llgs(self):
178198
self.init_llgs_test()

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_vCont.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def test_single_step_only_steps_one_instruction_with_Hc_vCont_s_debugserver(
105105
self.single_step_only_steps_one_instruction(
106106
use_Hc_packet=True, step_instruction="vCont;s")
107107

108+
@skipIfWindows # No pty support to test O* & I* notification packets.
108109
@llgs_test
109110
@expectedFailureAndroid(
110111
bugnumber="llvm.org/pr24739",
@@ -136,6 +137,7 @@ def test_single_step_only_steps_one_instruction_with_vCont_s_thread_debugserver(
136137
self.single_step_only_steps_one_instruction(
137138
use_Hc_packet=False, step_instruction="vCont;s:{thread}")
138139

140+
@skipIfWindows # No pty support to test O* & I* notification packets.
139141
@llgs_test
140142
@expectedFailureAndroid(
141143
bugnumber="llvm.org/pr24739",

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def test_inferior_print_exit_debugserver(self):
156156
self.build()
157157
self.inferior_print_exit()
158158

159+
@skipIfWindows # No pty support to test any inferior output
159160
@llgs_test
160161
@expectedFlakeyLinux("llvm.org/pr25652")
161162
def test_inferior_print_exit_llgs(self):
@@ -434,6 +435,7 @@ def qRegisterInfo_contains_avx_registers(self):
434435
self.targetHasAVX(),
435436
"Advanced Vector Extensions" in register_sets)
436437

438+
@expectedFailureAll(oslist=["windows"]) # no avx for now.
437439
@llgs_test
438440
def test_qRegisterInfo_contains_avx_registers_llgs(self):
439441
self.init_llgs_test()
@@ -478,6 +480,7 @@ def test_qThreadInfo_contains_thread_attach_debugserver(self):
478480
self.set_inferior_startup_attach()
479481
self.qThreadInfo_contains_thread()
480482

483+
@expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
481484
@llgs_test
482485
def test_qThreadInfo_contains_thread_attach_llgs(self):
483486
self.init_llgs_test()
@@ -536,6 +539,7 @@ def test_qThreadInfo_matches_qC_attach_debugserver(self):
536539
self.set_inferior_startup_attach()
537540
self.qThreadInfo_matches_qC()
538541

542+
@expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
539543
@llgs_test
540544
def test_qThreadInfo_matches_qC_attach_llgs(self):
541545
self.init_llgs_test()
@@ -664,6 +668,7 @@ def test_Hg_switches_to_3_threads_launch_debugserver(self):
664668
self.set_inferior_startup_launch()
665669
self.Hg_switches_to_3_threads()
666670

671+
@expectedFailureAll(oslist=["windows"]) # expect 4 threads
667672
@llgs_test
668673
def test_Hg_switches_to_3_threads_launch_llgs(self):
669674
self.init_llgs_test()
@@ -679,6 +684,7 @@ def test_Hg_switches_to_3_threads_attach_debugserver(self):
679684
self.set_inferior_startup_attach()
680685
self.Hg_switches_to_3_threads()
681686

687+
@expectedFailureAll(oslist=["windows"]) # expecting one more thread
682688
@llgs_test
683689
def test_Hg_switches_to_3_threads_attach_llgs(self):
684690
self.init_llgs_test()
@@ -808,6 +814,7 @@ def test_Hc_then_Csignal_signals_correct_thread_launch_debugserver(self):
808814
# expectations about fixed signal numbers.
809815
self.Hc_then_Csignal_signals_correct_thread(self.TARGET_EXC_BAD_ACCESS)
810816

817+
@skipIfWindows # no SIGSEGV support
811818
@llgs_test
812819
def test_Hc_then_Csignal_signals_correct_thread_launch_llgs(self):
813820
self.init_llgs_test()
@@ -876,6 +883,7 @@ def test_m_packet_reads_memory_debugserver(self):
876883
self.set_inferior_startup_launch()
877884
self.m_packet_reads_memory()
878885

886+
@skipIfWindows # No pty support to test any inferior output
879887
@llgs_test
880888
def test_m_packet_reads_memory_llgs(self):
881889
self.init_llgs_test()
@@ -966,6 +974,7 @@ def test_qMemoryRegionInfo_reports_code_address_as_executable_debugserver(
966974
self.set_inferior_startup_launch()
967975
self.qMemoryRegionInfo_reports_code_address_as_executable()
968976

977+
@skipIfWindows # No pty support to test any inferior output
969978
@llgs_test
970979
def test_qMemoryRegionInfo_reports_code_address_as_executable_llgs(self):
971980
self.init_llgs_test()
@@ -1031,6 +1040,7 @@ def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_debugserv
10311040
self.set_inferior_startup_launch()
10321041
self.qMemoryRegionInfo_reports_stack_address_as_readable_writeable()
10331042

1043+
@skipIfWindows # No pty support to test any inferior output
10341044
@llgs_test
10351045
def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_llgs(
10361046
self):
@@ -1096,6 +1106,7 @@ def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_debugserve
10961106
self.set_inferior_startup_launch()
10971107
self.qMemoryRegionInfo_reports_heap_address_as_readable_writeable()
10981108

1109+
@skipIfWindows # No pty support to test any inferior output
10991110
@llgs_test
11001111
def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_llgs(
11011112
self):
@@ -1248,6 +1259,7 @@ def test_software_breakpoint_set_and_remove_work_debugserver(self):
12481259
self.set_inferior_startup_launch()
12491260
self.breakpoint_set_and_remove_work(want_hardware=False)
12501261

1262+
@skipIfWindows # No pty support to test any inferior output
12511263
@llgs_test
12521264
@expectedFlakeyLinux("llvm.org/pr25652")
12531265
def test_software_breakpoint_set_and_remove_work_llgs(self):
@@ -1384,6 +1396,7 @@ def test_written_M_content_reads_back_correctly_debugserver(self):
13841396
self.set_inferior_startup_launch()
13851397
self.written_M_content_reads_back_correctly()
13861398

1399+
@skipIfWindows # No pty support to test any inferior output
13871400
@llgs_test
13881401
@expectedFlakeyLinux("llvm.org/pr25652")
13891402
def test_written_M_content_reads_back_correctly_llgs(self):
@@ -1559,6 +1572,7 @@ def test_P_and_p_thread_suffix_work_debugserver(self):
15591572
self.set_inferior_startup_launch()
15601573
self.P_and_p_thread_suffix_work()
15611574

1575+
@skipIfWindows
15621576
@llgs_test
15631577
def test_P_and_p_thread_suffix_work_llgs(self):
15641578
self.init_llgs_test()

lldb/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubSetSID.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def test_sid_is_same_without_setsid_debugserver(self):
4747
self.set_inferior_startup_launch()
4848
self.sid_is_same_without_setsid()
4949

50+
@skipIfWindows
5051
@llgs_test
5152
@skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
5253
@expectedFailureAll(oslist=['freebsd'])
@@ -62,6 +63,7 @@ def test_sid_is_different_with_setsid_debugserver(self):
6263
self.set_inferior_startup_launch()
6364
self.sid_is_different_with_setsid()
6465

66+
@skipIfWindows
6567
@llgs_test
6668
@skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
6769
def test_sid_is_different_with_setsid_llgs(self):
@@ -76,6 +78,7 @@ def test_sid_is_different_with_S_debugserver(self):
7678
self.set_inferior_startup_launch()
7779
self.sid_is_different_with_S()
7880

81+
@skipIfWindows
7982
@llgs_test
8083
@skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
8184
def test_sid_is_different_with_S_llgs(self):

lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ def init_llgs_test(self, use_named_pipe=True):
233233
# Remote platforms don't support named pipe based port negotiation
234234
use_named_pipe = False
235235

236+
triple = self.dbg.GetSelectedPlatform().GetTriple()
237+
if re.match(".*-.*-windows", triple):
238+
self.skipTest("Remotely testing is not supported on Windows yet.")
239+
236240
# Grab the ppid from /proc/[shell pid]/stat
237241
err, retcode, shell_stat = self.run_platform_command(
238242
"cat /proc/$$/stat")
@@ -258,6 +262,10 @@ def init_llgs_test(self, use_named_pipe=True):
258262
# Remove if it's there.
259263
self.debug_monitor_exe = re.sub(r' \(deleted\)$', '', exe)
260264
else:
265+
# Need to figure out how to create a named pipe on Windows.
266+
if platform.system() == 'Windows':
267+
use_named_pipe = False
268+
261269
self.debug_monitor_exe = get_lldb_server_exe()
262270
if not self.debug_monitor_exe:
263271
self.skipTest("lldb-server exe not found")

lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_inferior_abort_received_debugserver(self):
3636
self.build()
3737
self.inferior_abort_received()
3838

39+
@skipIfWindows # No signal is sent on Windows.
3940
@llgs_test
4041
# std::abort() on <= API 16 raises SIGSEGV - b.android.com/179836
4142
@expectedFailureAndroid(api_levels=list(range(16 + 1)))

0 commit comments

Comments
 (0)