Skip to content

Commit

Permalink
Update Python tests for lldb-server on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aaronsm committed Aug 14, 2019
1 parent 2a312fc commit 2a39024
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,8 @@ def run_suite():
# Don't do debugserver tests on anything except OS X.
configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform

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

# Collect tests from the specified testing directories. If a test
# subdirectory filter is explicitly specified, limit the search to that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def supports_auxv(self):
# tests don't get skipped.
#

@skipIfWindows # no auxv support.
@llgs_test
def test_supports_auxv_llgs(self):
self.init_llgs_test()
Expand All @@ -127,6 +128,7 @@ def test_auxv_data_is_correct_size_debugserver(self):
self.set_inferior_startup_launch()
self.auxv_data_is_correct_size()

@skipIfWindows
@llgs_test
def test_auxv_data_is_correct_size_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -165,6 +167,7 @@ def test_auxv_keys_look_valid_debugserver(self):
self.set_inferior_startup_launch()
self.auxv_keys_look_valid()

@skipIfWindows
@llgs_test
def test_auxv_keys_look_valid_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -212,6 +215,7 @@ def test_auxv_chunked_reads_work_debugserver(self):
self.set_inferior_startup_launch()
self.auxv_chunked_reads_work()

@skipIfWindows
@llgs_test
def test_auxv_chunked_reads_work_llgs(self):
self.init_llgs_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet

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

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

self.expect_gdbremote_sequence()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function


import json
import gdbremote_testcase
import lldbgdbserverutils
from lldbsuite.support import seven
Expand All @@ -20,9 +20,9 @@ def module_info(self):
info = self.parse_process_info_response(context)

self.test_sequence.add_log_lines([
'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % (
lldbutil.append_to_process_working_directory(self, "a.out"),
seven.unhexlify(info["triple"])),
'read packet: $jModulesInfo:%s]#00' % json.dumps(
[{"file":lldbutil.append_to_process_working_directory(self, "a.out"),
"triple":seven.unhexlify(info["triple"])}]),
{"direction": "send",
"regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}',
"capture": {1: "spec"}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,11 @@ def test_qProcessInfo_contains_cputype_cpusubtype_llgs_darwin(self):
self.build()
self.qProcessInfo_contains_keys(set(['cputype', 'cpusubtype']))

@skipUnlessPlatform(["linux"])
@llgs_test
def test_qProcessInfo_contains_triple_llgs_linux(self):
def test_qProcessInfo_contains_triple_ppid_llgs(self):
self.init_llgs_test()
self.build()
self.qProcessInfo_contains_keys(set(['triple']))
self.qProcessInfo_contains_keys(set(['triple', 'parent-pid']))

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

@skipUnlessPlatform(["linux"])
@skipIfDarwin
@llgs_test
def test_qProcessInfo_does_not_contain_cputype_cpusubtype_llgs_linux(self):
def test_qProcessInfo_does_not_contain_cputype_cpusubtype_llgs(self):
self.init_llgs_test()
self.build()
self.qProcessInfo_does_not_contain_keys(set(['cputype', 'cpusubtype']))
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_single_step_only_steps_one_instruction_with_s_debugserver(self):
self.single_step_only_steps_one_instruction(
use_Hc_packet=True, step_instruction="s")

@skipIfWindows # No pty support to test any inferior std -i/e/o
@llgs_test
@expectedFailureAndroid(
bugnumber="llvm.org/pr24739",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ def test_stop_reply_reports_multiple_threads_debugserver(self):
self.set_inferior_startup_launch()
self.stop_reply_reports_multiple_threads(5)

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

@expectedFailureAll(oslist=["windows"])
@llgs_test
def test_no_QListThreadsInStopReply_supplies_no_threads_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -263,6 +269,7 @@ def test_stop_reply_reports_correct_threads_debugserver(self):
self.set_inferior_startup_launch()
self.stop_reply_reports_correct_threads(5)

@expectedFailureAll(oslist=["windows"])
@llgs_test
def test_stop_reply_reports_correct_threads_llgs(self):
self.init_llgs_test()
Expand All @@ -287,6 +294,7 @@ def stop_reply_contains_thread_pcs(self, thread_count):
self.assertTrue(int(stop_reply_pcs[thread_id], 16)
== int(threads_info_pcs[thread_id], 16))

@expectedFailureAll(oslist=["windows"])
@llgs_test
def test_stop_reply_contains_thread_pcs_llgs(self):
self.init_llgs_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
# Wait until all threads have started.
threads = self.wait_for_thread_count(thread_count, timeout_seconds=3)
self.assertIsNotNone(threads)
self.assertEqual(len(threads), thread_count)

# On Windows, there could be more threads spawned. For example, DebugBreakProcess will
# create a new thread from the debugged process to handle an exception event. So here we
# assert 'GreaterEqual' condition.
triple = self.dbg.GetSelectedPlatform().GetTriple()
if re.match(".*-.*-windows", triple):
self.assertGreaterEqual(len(threads), thread_count)
else:
self.assertEqual(len(threads), thread_count)

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

def qThreadStopInfo_works_for_multiple_threads(self, thread_count):
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
self.assertEqual(len(stop_replies), thread_count)
triple = self.dbg.GetSelectedPlatform().GetTriple()
# Consider one more thread created by calling DebugBreakProcess.
if re.match(".*-.*-windows", triple):
self.assertGreaterEqual(len(stop_replies), thread_count)
else:
self.assertEqual(len(stop_replies), thread_count)

@debugserver_test
def test_qThreadStopInfo_works_for_multiple_threads_debugserver(self):
Expand Down Expand Up @@ -130,7 +143,13 @@ def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
stop_replies.values()) if stop_reason != 0)

# All but one thread should report no stop reason.
self.assertEqual(no_stop_reason_count, thread_count - 1)
triple = self.dbg.GetSelectedPlatform().GetTriple()

# Consider one more thread created by calling DebugBreakProcess.
if re.match(".*-.*-windows", triple):
self.assertGreaterEqual(no_stop_reason_count, thread_count - 1)
else:
self.assertEqual(no_stop_reason_count, thread_count - 1)

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

# test requires OS with set, equal thread names by default.
@skipUnlessPlatform(["linux"])
# Windows thread does not have name property, equal names as the process's by default.
@skipUnlessPlatform(["linux", "windows"])
@llgs_test
def test_qThreadStopInfo_has_valid_thread_names_llgs(self):
self.init_llgs_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def test_single_step_only_steps_one_instruction_with_Hc_vCont_s_debugserver(
self.single_step_only_steps_one_instruction(
use_Hc_packet=True, step_instruction="vCont;s")

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

@skipIfWindows # No pty support to test O* & I* notification packets.
@llgs_test
@expectedFailureAndroid(
bugnumber="llvm.org/pr24739",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_inferior_print_exit_debugserver(self):
self.build()
self.inferior_print_exit()

@skipIfWindows # No pty support to test any inferior output
@llgs_test
@expectedFlakeyLinux("llvm.org/pr25652")
def test_inferior_print_exit_llgs(self):
Expand Down Expand Up @@ -434,6 +435,7 @@ def qRegisterInfo_contains_avx_registers(self):
self.targetHasAVX(),
"Advanced Vector Extensions" in register_sets)

@expectedFailureAll(oslist=["windows"]) # no avx for now.
@llgs_test
def test_qRegisterInfo_contains_avx_registers_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -478,6 +480,7 @@ def test_qThreadInfo_contains_thread_attach_debugserver(self):
self.set_inferior_startup_attach()
self.qThreadInfo_contains_thread()

@expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
@llgs_test
def test_qThreadInfo_contains_thread_attach_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -536,6 +539,7 @@ def test_qThreadInfo_matches_qC_attach_debugserver(self):
self.set_inferior_startup_attach()
self.qThreadInfo_matches_qC()

@expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
@llgs_test
def test_qThreadInfo_matches_qC_attach_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -664,6 +668,7 @@ def test_Hg_switches_to_3_threads_launch_debugserver(self):
self.set_inferior_startup_launch()
self.Hg_switches_to_3_threads()

@expectedFailureAll(oslist=["windows"]) # expect 4 threads
@llgs_test
def test_Hg_switches_to_3_threads_launch_llgs(self):
self.init_llgs_test()
Expand All @@ -679,6 +684,7 @@ def test_Hg_switches_to_3_threads_attach_debugserver(self):
self.set_inferior_startup_attach()
self.Hg_switches_to_3_threads()

@expectedFailureAll(oslist=["windows"]) # expecting one more thread
@llgs_test
def test_Hg_switches_to_3_threads_attach_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -808,6 +814,7 @@ def test_Hc_then_Csignal_signals_correct_thread_launch_debugserver(self):
# expectations about fixed signal numbers.
self.Hc_then_Csignal_signals_correct_thread(self.TARGET_EXC_BAD_ACCESS)

@skipIfWindows # no SIGSEGV support
@llgs_test
def test_Hc_then_Csignal_signals_correct_thread_launch_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -876,6 +883,7 @@ def test_m_packet_reads_memory_debugserver(self):
self.set_inferior_startup_launch()
self.m_packet_reads_memory()

@skipIfWindows # No pty support to test any inferior output
@llgs_test
def test_m_packet_reads_memory_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -966,6 +974,7 @@ def test_qMemoryRegionInfo_reports_code_address_as_executable_debugserver(
self.set_inferior_startup_launch()
self.qMemoryRegionInfo_reports_code_address_as_executable()

@skipIfWindows # No pty support to test any inferior output
@llgs_test
def test_qMemoryRegionInfo_reports_code_address_as_executable_llgs(self):
self.init_llgs_test()
Expand Down Expand Up @@ -1031,6 +1040,7 @@ def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_debugserv
self.set_inferior_startup_launch()
self.qMemoryRegionInfo_reports_stack_address_as_readable_writeable()

@skipIfWindows # No pty support to test any inferior output
@llgs_test
def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_llgs(
self):
Expand Down Expand Up @@ -1096,6 +1106,7 @@ def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_debugserve
self.set_inferior_startup_launch()
self.qMemoryRegionInfo_reports_heap_address_as_readable_writeable()

@skipIfWindows # No pty support to test any inferior output
@llgs_test
def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_llgs(
self):
Expand Down Expand Up @@ -1248,6 +1259,7 @@ def test_software_breakpoint_set_and_remove_work_debugserver(self):
self.set_inferior_startup_launch()
self.breakpoint_set_and_remove_work(want_hardware=False)

@skipIfWindows # No pty support to test any inferior output
@llgs_test
@expectedFlakeyLinux("llvm.org/pr25652")
def test_software_breakpoint_set_and_remove_work_llgs(self):
Expand Down Expand Up @@ -1384,6 +1396,7 @@ def test_written_M_content_reads_back_correctly_debugserver(self):
self.set_inferior_startup_launch()
self.written_M_content_reads_back_correctly()

@skipIfWindows # No pty support to test any inferior output
@llgs_test
@expectedFlakeyLinux("llvm.org/pr25652")
def test_written_M_content_reads_back_correctly_llgs(self):
Expand Down Expand Up @@ -1559,6 +1572,7 @@ def test_P_and_p_thread_suffix_work_debugserver(self):
self.set_inferior_startup_launch()
self.P_and_p_thread_suffix_work()

@skipIfWindows
@llgs_test
def test_P_and_p_thread_suffix_work_llgs(self):
self.init_llgs_test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_sid_is_same_without_setsid_debugserver(self):
self.set_inferior_startup_launch()
self.sid_is_same_without_setsid()

@skipIfWindows
@llgs_test
@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
@expectedFailureAll(oslist=['freebsd'])
Expand All @@ -62,6 +63,7 @@ def test_sid_is_different_with_setsid_debugserver(self):
self.set_inferior_startup_launch()
self.sid_is_different_with_setsid()

@skipIfWindows
@llgs_test
@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
def test_sid_is_different_with_setsid_llgs(self):
Expand All @@ -76,6 +78,7 @@ def test_sid_is_different_with_S_debugserver(self):
self.set_inferior_startup_launch()
self.sid_is_different_with_S()

@skipIfWindows
@llgs_test
@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
def test_sid_is_different_with_S_llgs(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def init_llgs_test(self, use_named_pipe=True):
# Remote platforms don't support named pipe based port negotiation
use_named_pipe = False

triple = self.dbg.GetSelectedPlatform().GetTriple()
if re.match(".*-.*-windows", triple):
self.skipTest("Remotely testing is not supported on Windows yet.")

# Grab the ppid from /proc/[shell pid]/stat
err, retcode, shell_stat = self.run_platform_command(
"cat /proc/$$/stat")
Expand All @@ -258,6 +262,10 @@ def init_llgs_test(self, use_named_pipe=True):
# Remove if it's there.
self.debug_monitor_exe = re.sub(r' \(deleted\)$', '', exe)
else:
# Need to figure out how to create a named pipe on Windows.
if platform.system() == 'Windows':
use_named_pipe = False

self.debug_monitor_exe = get_lldb_server_exe()
if not self.debug_monitor_exe:
self.skipTest("lldb-server exe not found")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_inferior_abort_received_debugserver(self):
self.build()
self.inferior_abort_received()

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

0 comments on commit 2a39024

Please sign in to comment.