def debugserver_test(func):
"""Decorate the item as a debugserver test."""
- func.debug_server = "debugserver"
return add_test_categories(["debugserver"])(func)
def llgs_test(func):
"""Decorate the item as a lldb-server test."""
- func.debug_server = "llgs"
return add_test_categories(["llgs"])(func)
pass
+class GdbRemoteTestCaseFactory(type):
+
+ def __new__(cls, name, bases, attrs):
+ newattrs = {}
+ for attrname, attrvalue in attrs.items():
+ if not attrname.startswith("test"):
+ newattrs[attrname] = attrvalue
+ continue
+
+ # If any debug server categories were explicitly tagged, assume
+ # that list to be authoritative. If none were specified, try
+ # all of them.
+ all_categories = set(["debugserver", "llgs"])
+ categories = set(
+ getattr(attrvalue, "categories", [])) & all_categories
+ if not categories:
+ categories = all_categories
+
+ for cat in categories:
+ @decorators.add_test_categories([cat])
+ @wraps(attrvalue)
+ def test_method(self, attrvalue=attrvalue):
+ return attrvalue(self)
+
+ method_name = attrname + "_" + cat
+ test_method.__name__ = method_name
+ test_method.debug_server = cat
+ newattrs[method_name] = test_method
+
+ return super(GdbRemoteTestCaseFactory, cls).__new__(
+ cls, name, bases, newattrs)
+
+@add_metaclass(GdbRemoteTestCaseFactory)
class GdbRemoteTestCaseBase(Base):
# Default time out in seconds. The timeout is increased tenfold under Asan.
mydir = TestBase.compute_mydir(__file__)
- def inferior_exit_0(self):
- self.prep_debug_monitor_and_inferior()
- self.test_sequence.add_log_lines(
- ["read packet: $vCont;c#a8",
- "send packet: $W00#00"],
- True)
-
- self.expect_gdbremote_sequence()
-
- @debugserver_test
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def test_inferior_exit_0_debugserver(self):
+ def _test_inferior_exit(self, retval):
self.build()
- self.inferior_exit_0()
-
- @llgs_test
- def test_inferior_exit_0_llgs(self):
- self.build()
- self.inferior_exit_0()
-
- def inferior_exit_42(self):
- RETVAL = 42
procs = self.prep_debug_monitor_and_inferior(
- inferior_args=["retval:%d" % RETVAL])
+ inferior_args=["retval:%d" % retval])
self.test_sequence.add_log_lines(
["read packet: $vCont;c#a8",
- "send packet: $W{0:02x}#00".format(RETVAL)],
+ "send packet: $W{0:02x}#00".format(retval)],
True)
self.expect_gdbremote_sequence()
- @debugserver_test
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def test_inferior_exit_42_debugserver(self):
- self.build()
- self.inferior_exit_42()
+ def test_inferior_exit_0(self):
+ self._test_inferior_exit(0)
- @llgs_test
- def test_inferior_exit_42_llgs(self):
- self.build()
- self.inferior_exit_42()
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_inferior_exit_42(self):
+ self._test_inferior_exit(42)
class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def attach_commandline_kill_after_initial_stop(self):
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_attach_commandline_kill_after_initial_stop(self):
+ self.build()
+ self.set_inferior_startup_attach()
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([
self.assertFalse(
lldbgdbserverutils.process_is_running(
procs["inferior"].pid, False))
-
- @debugserver_test
- def test_attach_commandline_kill_after_initial_stop_debugserver(self):
- self.build()
- self.set_inferior_startup_attach()
- self.attach_commandline_kill_after_initial_stop()
-
- @llgs_test
- def test_attach_commandline_kill_after_initial_stop_llgs(self):
- self.build()
- self.set_inferior_startup_attach()
- self.attach_commandline_kill_after_initial_stop()
mydir = TestBase.compute_mydir(__file__)
- def module_info(self):
+ @add_test_categories(["llgs"])
+ def test_module_info(self):
+ self.build()
+ self.set_inferior_startup_launch()
procs = self.prep_debug_monitor_and_inferior()
self.add_process_info_collection_packets()
context = self.expect_gdbremote_sequence()
self.assertRegexpMatches(spec, '"file_size":\d+')
self.assertRegexpMatches(spec, '"triple":"\w*-\w*-.*"')
self.assertRegexpMatches(spec, '"uuid":"[A-Fa-f0-9]+"')
-
- @llgs_test
- def test_module_info(self):
- self.build()
- self.set_inferior_startup_launch()
- self.module_info()
-
-
-
import gdbremote_testcase
import lldbgdbserverutils
from lldbsuite.test.decorators import *
mydir = TestBase.compute_mydir(__file__)
- def qProcessInfo_returns_running_process(self):
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_qProcessInfo_returns_running_process(self):
+ self.build()
procs = self.prep_debug_monitor_and_inferior()
self.add_process_info_collection_packets()
# If possible, verify that the process is running.
self.assertTrue(lldbgdbserverutils.process_is_running(pid, True))
- @debugserver_test
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def test_qProcessInfo_returns_running_process_debugserver(self):
- self.build()
- self.qProcessInfo_returns_running_process()
-
- @llgs_test
- def test_qProcessInfo_returns_running_process_llgs(self):
+ def test_attach_commandline_qProcessInfo_reports_correct_pid(self):
self.build()
- self.qProcessInfo_returns_running_process()
-
- def attach_commandline_qProcessInfo_reports_correct_pid(self):
+ self.set_inferior_startup_attach()
procs = self.prep_debug_monitor_and_inferior()
self.assertIsNotNone(procs)
self.add_process_info_collection_packets()
reported_pid = int(pid_text, base=16)
self.assertEqual(reported_pid, procs["inferior"].pid)
- @debugserver_test
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def test_attach_commandline_qProcessInfo_reports_correct_pid_debugserver(
- self):
+ def test_qProcessInfo_reports_valid_endian(self):
self.build()
- self.set_inferior_startup_attach()
- self.attach_commandline_qProcessInfo_reports_correct_pid()
-
- @llgs_test
- def test_attach_commandline_qProcessInfo_reports_correct_pid_llgs(self):
- self.build()
- self.set_inferior_startup_attach()
- self.attach_commandline_qProcessInfo_reports_correct_pid()
-
- def qProcessInfo_reports_valid_endian(self):
procs = self.prep_debug_monitor_and_inferior()
self.add_process_info_collection_packets()
# Ensure the process id looks reasonable.
endian = process_info.get("endian")
self.assertIsNotNone(endian)
- self.assertTrue(endian in ["little", "big", "pdp"])
-
- @debugserver_test
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def test_qProcessInfo_reports_valid_endian_debugserver(self):
- self.build()
- self.qProcessInfo_reports_valid_endian()
-
- @llgs_test
- def test_qProcessInfo_reports_valid_endian_llgs(self):
- self.build()
- self.qProcessInfo_reports_valid_endian()
+ self.assertIn(endian, ["little", "big", "pdp"])
def qProcessInfo_contains_keys(self, expected_key_set):
procs = self.prep_debug_monitor_and_inferior()
set(),
"the listed keys were present but unexpected in qProcessInfo result")
- @skipUnlessDarwin
- @debugserver_test
+ @add_test_categories(["debugserver"])
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def test_qProcessInfo_contains_cputype_cpusubtype_debugserver_darwin(self):
- self.build()
- self.qProcessInfo_contains_keys(set(['cputype', 'cpusubtype']))
-
- @skipUnlessDarwin
- @llgs_test
- def test_qProcessInfo_contains_cputype_cpusubtype_llgs_darwin(self):
+ def test_qProcessInfo_contains_cputype_cpusubtype(self):
self.build()
self.qProcessInfo_contains_keys(set(['cputype', 'cpusubtype']))
- @llgs_test
- def test_qProcessInfo_contains_triple_ppid_llgs(self):
+ @add_test_categories(["llgs"])
+ def test_qProcessInfo_contains_triple_ppid(self):
self.build()
self.qProcessInfo_contains_keys(set(['triple', 'parent-pid']))
- @skipUnlessDarwin
- @debugserver_test
+ @add_test_categories(["debugserver"])
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- def test_qProcessInfo_does_not_contain_triple_debugserver_darwin(self):
- self.build()
- # We don't expect to see triple on darwin. If we do, we'll prefer triple
- # to cputype/cpusubtype and skip some darwin-based ProcessGDBRemote ArchSpec setup
- # for the remote Host and Process.
- self.qProcessInfo_does_not_contain_keys(set(['triple']))
-
- @skipUnlessDarwin
- @llgs_test
- def test_qProcessInfo_does_not_contain_triple_llgs_darwin(self):
+ def test_qProcessInfo_does_not_contain_triple(self):
self.build()
# We don't expect to see triple on darwin. If we do, we'll prefer triple
# to cputype/cpusubtype and skip some darwin-based ProcessGDBRemote ArchSpec setup
# for the remote Host and Process.
self.qProcessInfo_does_not_contain_keys(set(['triple']))
- @skipIfDarwin
- @llgs_test
- def test_qProcessInfo_does_not_contain_cputype_cpusubtype_llgs(self):
+ @add_test_categories(["llgs"])
+ def test_qProcessInfo_does_not_contain_cputype_cpusubtype(self):
self.build()
self.qProcessInfo_does_not_contain_keys(set(['cputype', 'cpusubtype']))
mydir = TestBase.compute_mydir(__file__)
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
def grp_register_save_restore_works(self, with_suffix):
# Start up the process, use thread suffix, grab main thread id.
inferior_args = ["message:main entered", "sleep:5"]
self.assertIsNotNone(final_reg_values)
self.assertEqual(final_reg_values, initial_reg_values)
- @debugserver_test
- def test_grp_register_save_restore_works_with_suffix_debugserver(self):
- USE_THREAD_SUFFIX = True
- self.build()
- self.set_inferior_startup_launch()
- self.grp_register_save_restore_works(USE_THREAD_SUFFIX)
-
- @llgs_test
- def test_grp_register_save_restore_works_with_suffix_llgs(self):
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_grp_register_save_restore_works_with_suffix(self):
USE_THREAD_SUFFIX = True
self.build()
self.set_inferior_startup_launch()
self.grp_register_save_restore_works(USE_THREAD_SUFFIX)
- @debugserver_test
- def test_grp_register_save_restore_works_no_suffix_debugserver(self):
- USE_THREAD_SUFFIX = False
- self.build()
- self.set_inferior_startup_launch()
- self.grp_register_save_restore_works(USE_THREAD_SUFFIX)
-
- @llgs_test
- def test_grp_register_save_restore_works_no_suffix_llgs(self):
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_grp_register_save_restore_works_no_suffix(self):
USE_THREAD_SUFFIX = False
self.build()
self.set_inferior_startup_launch()
-
-
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
mydir = TestBase.compute_mydir(__file__)
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- @debugserver_test
- def test_single_step_only_steps_one_instruction_with_s_debugserver(self):
- self.build()
- self.set_inferior_startup_launch()
- 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
@skipIf(triple='^mips')
- def test_single_step_only_steps_one_instruction_with_s_llgs(self):
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_single_step_only_steps_one_instruction_with_s(self):
self.build()
self.set_inferior_startup_launch()
self.single_step_only_steps_one_instruction(
-
import json
import re
return thread_pcs
- def QListThreadsInStopReply_supported(self):
+
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_QListThreadsInStopReply_supported(self):
+ self.build()
+ self.set_inferior_startup_launch()
procs = self.prep_debug_monitor_and_inferior()
self.test_sequence.add_log_lines(
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
+ # 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"])
+ @skipIfNetBSD
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- @debugserver_test
- def test_QListThreadsInStopReply_supported_debugserver(self):
+ def test_stop_reply_reports_multiple_threads(self):
self.build()
self.set_inferior_startup_launch()
- self.QListThreadsInStopReply_supported()
-
- @llgs_test
- def test_QListThreadsInStopReply_supported_llgs(self):
- self.build()
- self.set_inferior_startup_launch()
- self.QListThreadsInStopReply_supported()
-
- def stop_reply_reports_multiple_threads(self, thread_count):
# Gather threads from stop notification when QThreadsInStopReply is
# enabled.
stop_reply_threads = self.gather_stop_reply_threads(
- self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
- self.assertEqual(len(stop_reply_threads), thread_count)
+ self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, 5)
+ self.assertEqual(len(stop_reply_threads), 5)
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- @debugserver_test
- def test_stop_reply_reports_multiple_threads_debugserver(self):
- self.build()
- 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"])
@skipIfNetBSD
- @llgs_test
- def test_stop_reply_reports_multiple_threads_llgs(self):
+ def test_no_QListThreadsInStopReply_supplies_no_threads(self):
self.build()
self.set_inferior_startup_launch()
- self.stop_reply_reports_multiple_threads(5)
-
- def no_QListThreadsInStopReply_supplies_no_threads(self, thread_count):
# Gather threads from stop notification when QThreadsInStopReply is not
# enabled.
- stop_reply_threads = self.gather_stop_reply_threads(None, thread_count)
+ stop_reply_threads = self.gather_stop_reply_threads(None, 5)
self.assertEqual(len(stop_reply_threads), 0)
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- @debugserver_test
- def test_no_QListThreadsInStopReply_supplies_no_threads_debugserver(self):
- self.build()
- self.set_inferior_startup_launch()
- self.no_QListThreadsInStopReply_supplies_no_threads(5)
-
@expectedFailureAll(oslist=["windows"])
@skipIfNetBSD
- @llgs_test
- def test_no_QListThreadsInStopReply_supplies_no_threads_llgs(self):
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_stop_reply_reports_correct_threads(self):
self.build()
self.set_inferior_startup_launch()
- self.no_QListThreadsInStopReply_supplies_no_threads(5)
-
- def stop_reply_reports_correct_threads(self, thread_count):
# Gather threads from stop notification when QThreadsInStopReply is
# enabled.
+ thread_count = 5
stop_reply_threads = self.gather_stop_reply_threads(
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
self.assertEqual(len(stop_reply_threads), thread_count)
# Ensure each thread in q{f,s}ThreadInfo appears in stop reply threads
for tid in threads:
- self.assertTrue(tid in stop_reply_threads)
-
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- @debugserver_test
- def test_stop_reply_reports_correct_threads_debugserver(self):
- self.build()
- self.set_inferior_startup_launch()
- self.stop_reply_reports_correct_threads(5)
+ self.assertIn(tid, stop_reply_threads)
@expectedFailureAll(oslist=["windows"])
@skipIfNetBSD
- @llgs_test
- def test_stop_reply_reports_correct_threads_llgs(self):
+ @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
+ def test_stop_reply_contains_thread_pcs(self):
self.build()
self.set_inferior_startup_launch()
- self.stop_reply_reports_correct_threads(5)
-
- def stop_reply_contains_thread_pcs(self, thread_count):
+ thread_count = 5
results = self.gather_stop_reply_pcs(
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
stop_reply_pcs = results["thread_pcs"]
self.assertEqual(len(threads_info_pcs), thread_count)
for thread_id in stop_reply_pcs:
- self.assertTrue(thread_id in threads_info_pcs)
- self.assertTrue(int(stop_reply_pcs[thread_id], 16)
- == int(threads_info_pcs[thread_id], 16))
-
- @expectedFailureAll(oslist=["windows"])
- @skipIfNetBSD
- @llgs_test
- def test_stop_reply_contains_thread_pcs_llgs(self):
- self.build()
- self.set_inferior_startup_launch()
- self.stop_reply_contains_thread_pcs(5)
-
- @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
- @debugserver_test
- def test_stop_reply_contains_thread_pcs_debugserver(self):
- self.build()
- self.set_inferior_startup_launch()
- self.stop_reply_contains_thread_pcs(5)
+ self.assertIn(thread_id, threads_info_pcs)
+ self.assertEqual(int(stop_reply_pcs[thread_id], 16),
+ int(threads_info_pcs[thread_id], 16))