Skip to content

Commit 76a718e

Browse files
committed
[lldb] Deduplicate some lldb-server tests
Merge llgs and debugserver flavours
1 parent dd756e3 commit 76a718e

File tree

7 files changed

+47
-200
lines changed

7 files changed

+47
-200
lines changed

lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
2-
31
import gdbremote_testcase
42
import lldbgdbserverutils
53
from lldbsuite.test.decorators import *
64
from lldbsuite.test.lldbtest import *
75
from lldbsuite.test import lldbutil
86

9-
107
class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
118

129
mydir = TestBase.compute_mydir(__file__)
1310

14-
def attach_with_vAttach(self):
11+
def test_attach_with_vAttach(self):
12+
self.build()
13+
self.set_inferior_startup_attach_manually()
14+
1515
# Start the inferior, start the debug monitor, nothing is attached yet.
1616
procs = self.prep_debug_monitor_and_inferior(
1717
inferior_args=["sleep:60"])
@@ -49,15 +49,3 @@ def attach_with_vAttach(self):
4949
self.assertIsNotNone(pid_text)
5050
reported_pid = int(pid_text, base=16)
5151
self.assertEqual(reported_pid, inferior.pid)
52-
53-
@debugserver_test
54-
def test_attach_with_vAttach_debugserver(self):
55-
self.build()
56-
self.set_inferior_startup_attach_manually()
57-
self.attach_with_vAttach()
58-
59-
@llgs_test
60-
def test_attach_with_vAttach_llgs(self):
61-
self.build()
62-
self.set_inferior_startup_attach_manually()
63-
self.attach_with_vAttach()

lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def init_lldb_server(self):
3434
def generate_hex_path(self, target):
3535
return str(os.path.join(self.getBuildDir(), target)).encode().hex()
3636

37-
@llgs_test
37+
@add_test_categories(["llgs"])
3838
def test_autocomplete_path(self):
3939
self.build()
4040
self.init_lldb_server()

lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py

Lines changed: 27 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -57,45 +57,21 @@ def stop_notification_contains_generic_register(
5757
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
5858
self.trace("{} reg_info:{}".format(generic_register_name, reg_info))
5959

60-
def stop_notification_contains_aarch64_vg_register(self):
61-
# Generate a stop reply, parse out expedited registers from stop
62-
# notification.
63-
expedited_registers = self.gather_expedited_registers()
64-
self.assertIsNotNone(expedited_registers)
65-
self.assertTrue(len(expedited_registers) > 0)
66-
67-
# Gather target register infos.
68-
reg_infos = self.gather_register_infos()
69-
70-
# Find the vg register.
71-
reg_info = self.find_register_with_name_and_dwarf_regnum(
72-
reg_infos, 'vg', '46')
73-
self.assertIsNotNone(reg_info)
74-
75-
# Ensure the expedited registers contained it.
76-
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
77-
self.trace("{} reg_info:{}".format('vg', reg_info))
60+
def test_stop_notification_contains_any_registers(self):
61+
self.build()
62+
self.set_inferior_startup_launch()
7863

79-
def stop_notification_contains_any_registers(self):
8064
# Generate a stop reply, parse out expedited registers from stop
8165
# notification.
8266
expedited_registers = self.gather_expedited_registers()
8367
# Verify we have at least one expedited register.
8468
self.assertTrue(len(expedited_registers) > 0)
8569

86-
@debugserver_test
87-
def test_stop_notification_contains_any_registers_debugserver(self):
88-
self.build()
89-
self.set_inferior_startup_launch()
90-
self.stop_notification_contains_any_registers()
9170

92-
@llgs_test
93-
def test_stop_notification_contains_any_registers_llgs(self):
71+
def test_stop_notification_contains_no_duplicate_registers(self):
9472
self.build()
9573
self.set_inferior_startup_launch()
96-
self.stop_notification_contains_any_registers()
9774

98-
def stop_notification_contains_no_duplicate_registers(self):
9975
# Generate a stop reply, parse out expedited registers from stop
10076
# notification.
10177
expedited_registers = self.gather_expedited_registers()
@@ -106,72 +82,44 @@ def stop_notification_contains_no_duplicate_registers(self):
10682
"expedited register number {} specified more than once ({} times)".format(
10783
reg_num, len(value)))
10884

109-
@debugserver_test
110-
def test_stop_notification_contains_no_duplicate_registers_debugserver(
111-
self):
112-
self.build()
113-
self.set_inferior_startup_launch()
114-
self.stop_notification_contains_no_duplicate_registers()
115-
116-
@llgs_test
117-
def test_stop_notification_contains_no_duplicate_registers_llgs(self):
85+
def test_stop_notification_contains_pc_register(self):
11886
self.build()
11987
self.set_inferior_startup_launch()
120-
self.stop_notification_contains_no_duplicate_registers()
121-
122-
def stop_notification_contains_pc_register(self):
12388
self.stop_notification_contains_generic_register("pc")
12489

125-
@debugserver_test
126-
def test_stop_notification_contains_pc_register_debugserver(self):
90+
@skipIf(triple='^powerpc64') # powerpc64 has no FP register
91+
def test_stop_notification_contains_fp_register(self):
12792
self.build()
12893
self.set_inferior_startup_launch()
129-
self.stop_notification_contains_pc_register()
130-
131-
@llgs_test
132-
def test_stop_notification_contains_pc_register_llgs(self):
133-
self.build()
134-
self.set_inferior_startup_launch()
135-
self.stop_notification_contains_pc_register()
136-
137-
# powerpc64 has no FP register
138-
@skipIf(triple='^powerpc64')
139-
def stop_notification_contains_fp_register(self):
14094
self.stop_notification_contains_generic_register("fp")
14195

142-
@debugserver_test
143-
def test_stop_notification_contains_fp_register_debugserver(self):
96+
def test_stop_notification_contains_sp_register(self):
14497
self.build()
14598
self.set_inferior_startup_launch()
146-
self.stop_notification_contains_fp_register()
147-
148-
@llgs_test
149-
def test_stop_notification_contains_fp_register_llgs(self):
150-
self.build()
151-
self.set_inferior_startup_launch()
152-
self.stop_notification_contains_fp_register()
153-
154-
def stop_notification_contains_sp_register(self):
15599
self.stop_notification_contains_generic_register("sp")
156100

157-
@debugserver_test
158-
def test_stop_notification_contains_sp_register_debugserver(self):
159-
self.build()
160-
self.set_inferior_startup_launch()
161-
self.stop_notification_contains_sp_register()
162-
163-
@llgs_test
164-
def test_stop_notification_contains_sp_register_llgs(self):
165-
self.build()
166-
self.set_inferior_startup_launch()
167-
self.stop_notification_contains_sp_register()
168-
169-
@llgs_test
170101
@skipIf(archs=no_match(["aarch64"]))
171102
@skipIf(oslist=no_match(['linux']))
172-
def test_stop_notification_contains_vg_register_llgs(self):
103+
def test_stop_notification_contains_vg_register(self):
173104
if not self.isAArch64SVE():
174105
self.skipTest('SVE registers must be supported.')
175106
self.build()
176107
self.set_inferior_startup_launch()
177-
self.stop_notification_contains_aarch64_vg_register()
108+
109+
# Generate a stop reply, parse out expedited registers from stop
110+
# notification.
111+
expedited_registers = self.gather_expedited_registers()
112+
self.assertIsNotNone(expedited_registers)
113+
self.assertTrue(len(expedited_registers) > 0)
114+
115+
# Gather target register infos.
116+
reg_infos = self.gather_register_infos()
117+
118+
# Find the vg register.
119+
reg_info = self.find_register_with_name_and_dwarf_regnum(
120+
reg_infos, 'vg', '46')
121+
self.assertIsNotNone(reg_info)
122+
123+
# Ensure the expedited registers contained it.
124+
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
125+
self.trace("{} reg_info:{}".format('vg', reg_info))

lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,12 @@ def validate_darwin_minimum_host_info_keys(self, host_info_dict):
9999
"qHostInfo is missing the following required "
100100
"keys: " + str(missing_keys))
101101

102-
@debugserver_test
103-
def test_qHostInfo_returns_at_least_one_key_val_pair_debugserver(self):
102+
def test_qHostInfo_returns_at_least_one_key_val_pair(self):
104103
self.build()
105104
self.get_qHostInfo_response()
106105

107-
@llgs_test
108-
def test_qHostInfo_returns_at_least_one_key_val_pair_llgs(self):
109-
self.build()
110-
self.get_qHostInfo_response()
111-
112-
@skipUnlessDarwin
113-
@debugserver_test
114-
def test_qHostInfo_contains_darwin_required_keys_debugserver(self):
115-
self.build()
116-
host_info_dict = self.get_qHostInfo_response()
117-
self.validate_darwin_minimum_host_info_keys(host_info_dict)
118-
119106
@skipUnlessDarwin
120-
@llgs_test
121-
def test_qHostInfo_contains_darwin_required_keys_llgs(self):
107+
def test_qHostInfo_contains_darwin_required_keys(self):
122108
self.build()
123109
host_info_dict = self.get_qHostInfo_response()
124110
self.validate_darwin_minimum_host_info_keys(host_info_dict)

lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py

Lines changed: 13 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
2-
3-
41
import unittest2
52
import gdbremote_testcase
63
from lldbsuite.test.decorators import *
74
from lldbsuite.test.lldbtest import *
85
from lldbsuite.test import lldbutil
96

10-
117
class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
128

139
mydir = TestBase.compute_mydir(__file__)
@@ -104,31 +100,25 @@ def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
104100

105101
return (stop_replies, thread_dicts)
106102

107-
def qThreadStopInfo_works_for_multiple_threads(self, thread_count):
108-
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
103+
@skipIfNetBSD
104+
def test_qThreadStopInfo_works_for_multiple_threads(self):
105+
self.build()
106+
self.set_inferior_startup_launch()
107+
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.THREAD_COUNT)
109108
triple = self.dbg.GetSelectedPlatform().GetTriple()
110109
# Consider one more thread created by calling DebugBreakProcess.
111110
if re.match(".*-.*-windows", triple):
112-
self.assertGreaterEqual(len(stop_replies), thread_count)
111+
self.assertGreaterEqual(len(stop_replies), self.THREAD_COUNT)
113112
else:
114-
self.assertEqual(len(stop_replies), thread_count)
113+
self.assertEqual(len(stop_replies), self.THREAD_COUNT)
115114

116-
@debugserver_test
117-
def test_qThreadStopInfo_works_for_multiple_threads_debugserver(self):
118-
self.build()
119-
self.set_inferior_startup_launch()
120-
self.qThreadStopInfo_works_for_multiple_threads(self.THREAD_COUNT)
121-
122-
@llgs_test
123-
@skipIfNetBSD
124-
def test_qThreadStopInfo_works_for_multiple_threads_llgs(self):
115+
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48418")
116+
@expectedFailureNetBSD
117+
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(self):
125118
self.build()
126119
self.set_inferior_startup_launch()
127-
self.qThreadStopInfo_works_for_multiple_threads(self.THREAD_COUNT)
128120

129-
def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
130-
self, thread_count):
131-
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
121+
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.THREAD_COUNT)
132122
self.assertIsNotNone(stop_replies)
133123

134124
no_stop_reason_count = sum(
@@ -143,53 +133,9 @@ def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
143133

144134
# Consider one more thread created by calling DebugBreakProcess.
145135
if re.match(".*-.*-windows", triple):
146-
self.assertGreaterEqual(no_stop_reason_count, thread_count - 1)
136+
self.assertGreaterEqual(no_stop_reason_count, self.THREAD_COUNT - 1)
147137
else:
148-
self.assertEqual(no_stop_reason_count, thread_count - 1)
138+
self.assertEqual(no_stop_reason_count, self.THREAD_COUNT - 1)
149139

150140
# Only one thread should should indicate a stop reason.
151141
self.assertEqual(with_stop_reason_count, 1)
152-
153-
@debugserver_test
154-
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_debugserver(
155-
self):
156-
self.build()
157-
self.set_inferior_startup_launch()
158-
self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
159-
self.THREAD_COUNT)
160-
161-
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48418")
162-
@expectedFailureNetBSD
163-
@llgs_test
164-
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_llgs(
165-
self):
166-
self.build()
167-
self.set_inferior_startup_launch()
168-
self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
169-
self.THREAD_COUNT)
170-
171-
def qThreadStopInfo_has_valid_thread_names(
172-
self, thread_count, expected_thread_name):
173-
(_, thread_dicts) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
174-
self.assertIsNotNone(thread_dicts)
175-
176-
for thread_dict in list(thread_dicts.values()):
177-
name = thread_dict.get("name")
178-
self.assertIsNotNone(name)
179-
self.assertEqual(name, expected_thread_name)
180-
181-
@unittest2.skip("MacOSX doesn't have a default thread name")
182-
@debugserver_test
183-
def test_qThreadStopInfo_has_valid_thread_names_debugserver(self):
184-
self.build()
185-
self.set_inferior_startup_launch()
186-
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out")
187-
188-
# test requires OS with set, equal thread names by default.
189-
# Windows thread does not have name property, equal names as the process's by default.
190-
@skipUnlessPlatform(["linux", "windows"])
191-
@llgs_test
192-
def test_qThreadStopInfo_has_valid_thread_names_llgs(self):
193-
self.build()
194-
self.set_inferior_startup_launch()
195-
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out")

lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,16 @@ class TestGdbRemoteConnection(gdbremote_testcase.GdbRemoteTestCaseBase):
1111

1212
mydir = TestBase.compute_mydir(__file__)
1313

14-
@debugserver_test
15-
def test_reverse_connect_debugserver(self):
16-
self._reverse_connect()
17-
18-
@llgs_test
1914
@skipIfRemote # reverse connect is not a supported use case for now
2015
def test_reverse_connect_llgs(self):
21-
self._reverse_connect()
22-
23-
def _reverse_connect(self):
2416
# Reverse connect is the default connection method.
2517
self.connect_to_debug_monitor()
2618
# Verify we can do the handshake. If that works, we'll call it good.
2719
self.do_handshake(self.sock)
2820

29-
@debugserver_test
30-
@skipIfRemote
31-
def test_named_pipe_debugserver(self):
32-
self._named_pipe()
33-
34-
@llgs_test
3521
@skipIfRemote
3622
@skipIfWindows
3723
def test_named_pipe_llgs(self):
38-
self._named_pipe()
39-
40-
def _named_pipe(self):
4124
family, type, proto, _, addr = socket.getaddrinfo(
4225
self.stub_hostname, 0, proto=socket.IPPROTO_TCP)[0]
4326
self.sock = socket.socket(family, type, proto)

0 commit comments

Comments
 (0)