[lldb] Deduplicate some lldb-server tests

Merge llgs and debugserver flavours
This commit is contained in:
Pavel Labath 2020-12-19 21:06:48 +01:00
parent dd756e3e84
commit 76a718ee93
7 changed files with 69 additions and 222 deletions

View File

@ -1,17 +1,17 @@
import gdbremote_testcase
import lldbgdbserverutils
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
def attach_with_vAttach(self):
def test_attach_with_vAttach(self):
self.build()
self.set_inferior_startup_attach_manually()
# Start the inferior, start the debug monitor, nothing is attached yet.
procs = self.prep_debug_monitor_and_inferior(
inferior_args=["sleep:60"])
@ -49,15 +49,3 @@ class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertIsNotNone(pid_text)
reported_pid = int(pid_text, base=16)
self.assertEqual(reported_pid, inferior.pid)
@debugserver_test
def test_attach_with_vAttach_debugserver(self):
self.build()
self.set_inferior_startup_attach_manually()
self.attach_with_vAttach()
@llgs_test
def test_attach_with_vAttach_llgs(self):
self.build()
self.set_inferior_startup_attach_manually()
self.attach_with_vAttach()

View File

@ -34,7 +34,7 @@ class GdbRemoteCompletionTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
def generate_hex_path(self, target):
return str(os.path.join(self.getBuildDir(), target)).encode().hex()
@llgs_test
@add_test_categories(["llgs"])
def test_autocomplete_path(self):
self.build()
self.init_lldb_server()

View File

@ -57,7 +57,55 @@ class TestGdbRemoteExpeditedRegisters(
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
self.trace("{} reg_info:{}".format(generic_register_name, reg_info))
def stop_notification_contains_aarch64_vg_register(self):
def test_stop_notification_contains_any_registers(self):
self.build()
self.set_inferior_startup_launch()
# Generate a stop reply, parse out expedited registers from stop
# notification.
expedited_registers = self.gather_expedited_registers()
# Verify we have at least one expedited register.
self.assertTrue(len(expedited_registers) > 0)
def test_stop_notification_contains_no_duplicate_registers(self):
self.build()
self.set_inferior_startup_launch()
# Generate a stop reply, parse out expedited registers from stop
# notification.
expedited_registers = self.gather_expedited_registers()
# Verify no expedited register was specified multiple times.
for (reg_num, value) in list(expedited_registers.items()):
if (isinstance(value, list)) and (len(value) > 0):
self.fail(
"expedited register number {} specified more than once ({} times)".format(
reg_num, len(value)))
def test_stop_notification_contains_pc_register(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_generic_register("pc")
@skipIf(triple='^powerpc64') # powerpc64 has no FP register
def test_stop_notification_contains_fp_register(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_generic_register("fp")
def test_stop_notification_contains_sp_register(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_generic_register("sp")
@skipIf(archs=no_match(["aarch64"]))
@skipIf(oslist=no_match(['linux']))
def test_stop_notification_contains_vg_register(self):
if not self.isAArch64SVE():
self.skipTest('SVE registers must be supported.')
self.build()
self.set_inferior_startup_launch()
# Generate a stop reply, parse out expedited registers from stop
# notification.
expedited_registers = self.gather_expedited_registers()
@ -75,103 +123,3 @@ class TestGdbRemoteExpeditedRegisters(
# Ensure the expedited registers contained it.
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
self.trace("{} reg_info:{}".format('vg', reg_info))
def stop_notification_contains_any_registers(self):
# Generate a stop reply, parse out expedited registers from stop
# notification.
expedited_registers = self.gather_expedited_registers()
# Verify we have at least one expedited register.
self.assertTrue(len(expedited_registers) > 0)
@debugserver_test
def test_stop_notification_contains_any_registers_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_any_registers()
@llgs_test
def test_stop_notification_contains_any_registers_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_any_registers()
def stop_notification_contains_no_duplicate_registers(self):
# Generate a stop reply, parse out expedited registers from stop
# notification.
expedited_registers = self.gather_expedited_registers()
# Verify no expedited register was specified multiple times.
for (reg_num, value) in list(expedited_registers.items()):
if (isinstance(value, list)) and (len(value) > 0):
self.fail(
"expedited register number {} specified more than once ({} times)".format(
reg_num, len(value)))
@debugserver_test
def test_stop_notification_contains_no_duplicate_registers_debugserver(
self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_no_duplicate_registers()
@llgs_test
def test_stop_notification_contains_no_duplicate_registers_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_no_duplicate_registers()
def stop_notification_contains_pc_register(self):
self.stop_notification_contains_generic_register("pc")
@debugserver_test
def test_stop_notification_contains_pc_register_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_pc_register()
@llgs_test
def test_stop_notification_contains_pc_register_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_pc_register()
# powerpc64 has no FP register
@skipIf(triple='^powerpc64')
def stop_notification_contains_fp_register(self):
self.stop_notification_contains_generic_register("fp")
@debugserver_test
def test_stop_notification_contains_fp_register_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_fp_register()
@llgs_test
def test_stop_notification_contains_fp_register_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_fp_register()
def stop_notification_contains_sp_register(self):
self.stop_notification_contains_generic_register("sp")
@debugserver_test
def test_stop_notification_contains_sp_register_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_sp_register()
@llgs_test
def test_stop_notification_contains_sp_register_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_sp_register()
@llgs_test
@skipIf(archs=no_match(["aarch64"]))
@skipIf(oslist=no_match(['linux']))
def test_stop_notification_contains_vg_register_llgs(self):
if not self.isAArch64SVE():
self.skipTest('SVE registers must be supported.')
self.build()
self.set_inferior_startup_launch()
self.stop_notification_contains_aarch64_vg_register()

View File

@ -99,26 +99,12 @@ class TestGdbRemoteHostInfo(GdbRemoteTestCaseBase):
"qHostInfo is missing the following required "
"keys: " + str(missing_keys))
@debugserver_test
def test_qHostInfo_returns_at_least_one_key_val_pair_debugserver(self):
self.build()
self.get_qHostInfo_response()
@llgs_test
def test_qHostInfo_returns_at_least_one_key_val_pair_llgs(self):
def test_qHostInfo_returns_at_least_one_key_val_pair(self):
self.build()
self.get_qHostInfo_response()
@skipUnlessDarwin
@debugserver_test
def test_qHostInfo_contains_darwin_required_keys_debugserver(self):
self.build()
host_info_dict = self.get_qHostInfo_response()
self.validate_darwin_minimum_host_info_keys(host_info_dict)
@skipUnlessDarwin
@llgs_test
def test_qHostInfo_contains_darwin_required_keys_llgs(self):
def test_qHostInfo_contains_darwin_required_keys(self):
self.build()
host_info_dict = self.get_qHostInfo_response()
self.validate_darwin_minimum_host_info_keys(host_info_dict)

View File

@ -1,13 +1,9 @@
import unittest2
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@ -104,31 +100,25 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
return (stop_replies, thread_dicts)
def qThreadStopInfo_works_for_multiple_threads(self, thread_count):
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
@skipIfNetBSD
def test_qThreadStopInfo_works_for_multiple_threads(self):
self.build()
self.set_inferior_startup_launch()
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.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)
self.assertGreaterEqual(len(stop_replies), self.THREAD_COUNT)
else:
self.assertEqual(len(stop_replies), thread_count)
self.assertEqual(len(stop_replies), self.THREAD_COUNT)
@debugserver_test
def test_qThreadStopInfo_works_for_multiple_threads_debugserver(self):
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48418")
@expectedFailureNetBSD
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(self):
self.build()
self.set_inferior_startup_launch()
self.qThreadStopInfo_works_for_multiple_threads(self.THREAD_COUNT)
@llgs_test
@skipIfNetBSD
def test_qThreadStopInfo_works_for_multiple_threads_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.qThreadStopInfo_works_for_multiple_threads(self.THREAD_COUNT)
def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
self, thread_count):
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.THREAD_COUNT)
self.assertIsNotNone(stop_replies)
no_stop_reason_count = sum(
@ -143,53 +133,9 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
# Consider one more thread created by calling DebugBreakProcess.
if re.match(".*-.*-windows", triple):
self.assertGreaterEqual(no_stop_reason_count, thread_count - 1)
self.assertGreaterEqual(no_stop_reason_count, self.THREAD_COUNT - 1)
else:
self.assertEqual(no_stop_reason_count, thread_count - 1)
self.assertEqual(no_stop_reason_count, self.THREAD_COUNT - 1)
# Only one thread should should indicate a stop reason.
self.assertEqual(with_stop_reason_count, 1)
@debugserver_test
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_debugserver(
self):
self.build()
self.set_inferior_startup_launch()
self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
self.THREAD_COUNT)
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48418")
@expectedFailureNetBSD
@llgs_test
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_llgs(
self):
self.build()
self.set_inferior_startup_launch()
self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
self.THREAD_COUNT)
def qThreadStopInfo_has_valid_thread_names(
self, thread_count, expected_thread_name):
(_, thread_dicts) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
self.assertIsNotNone(thread_dicts)
for thread_dict in list(thread_dicts.values()):
name = thread_dict.get("name")
self.assertIsNotNone(name)
self.assertEqual(name, expected_thread_name)
@unittest2.skip("MacOSX doesn't have a default thread name")
@debugserver_test
def test_qThreadStopInfo_has_valid_thread_names_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out")
# test requires OS with set, equal thread names by default.
# 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.build()
self.set_inferior_startup_launch()
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out")

View File

@ -11,33 +11,16 @@ class TestGdbRemoteConnection(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@debugserver_test
def test_reverse_connect_debugserver(self):
self._reverse_connect()
@llgs_test
@skipIfRemote # reverse connect is not a supported use case for now
def test_reverse_connect_llgs(self):
self._reverse_connect()
def _reverse_connect(self):
# Reverse connect is the default connection method.
self.connect_to_debug_monitor()
# Verify we can do the handshake. If that works, we'll call it good.
self.do_handshake(self.sock)
@debugserver_test
@skipIfRemote
def test_named_pipe_debugserver(self):
self._named_pipe()
@llgs_test
@skipIfRemote
@skipIfWindows
def test_named_pipe_llgs(self):
self._named_pipe()
def _named_pipe(self):
family, type, proto, _, addr = socket.getaddrinfo(
self.stub_hostname, 0, proto=socket.IPPROTO_TCP)[0]
self.sock = socket.socket(family, type, proto)

View File

@ -46,7 +46,6 @@ class TestGdbRemote_QPassSignals(gdbremote_testcase.GdbRemoteTestCaseBase):
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@llgs_test
@skipUnlessPlatform(["linux", "android"])
def test_q_pass_signals(self):
self.build()
@ -61,7 +60,6 @@ class TestGdbRemote_QPassSignals(gdbremote_testcase.GdbRemoteTestCaseBase):
self.expect_signal(signo)
self.expect_exit_code(len(signals_to_ignore))
@llgs_test
@skipUnlessPlatform(["linux", "android"])
def test_change_signals_at_runtime(self):
self.build()
@ -80,7 +78,6 @@ class TestGdbRemote_QPassSignals(gdbremote_testcase.GdbRemoteTestCaseBase):
@skipIfWindows # no signal support
@expectedFailureNetBSD
@llgs_test
def test_default_signals_behavior(self):
self.build()
self.set_inferior_startup_launch()
@ -93,7 +90,6 @@ class TestGdbRemote_QPassSignals(gdbremote_testcase.GdbRemoteTestCaseBase):
self.expect_exit_code(0)
@llgs_test
@skipUnlessPlatform(["linux", "android"])
def test_support_q_pass_signals(self):
self.build()