forked from OSchip/llvm-project
[lldb/test] Remove the "expect_captures" feature of lldb-server tests
This functionality is used exactly once, and it is trivial to implement it differently (capture into two distinct variables, and compare for equality afterwards).
This commit is contained in:
parent
2494243ed3
commit
ded660495f
|
@ -381,8 +381,7 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
|
|||
is_send_to_remote=True,
|
||||
exact_payload=None,
|
||||
regex=None,
|
||||
capture=None,
|
||||
expect_captures=None):
|
||||
capture=None):
|
||||
"""Create an entry representing one piece of the I/O to/from a gdb remote debug monitor.
|
||||
|
||||
Args:
|
||||
|
@ -399,16 +398,12 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
|
|||
no-ack makes the checksum content essentially
|
||||
undefined.
|
||||
|
||||
regex: currently only valid for receives from gdbremote.
|
||||
When specified (and only if exact_payload is None),
|
||||
indicates the gdbremote response must match the given
|
||||
regex. Match groups in the regex can be used for two
|
||||
different purposes: saving the match (see capture
|
||||
arg), or validating that a match group matches a
|
||||
previously established value (see expect_captures). It
|
||||
is perfectly valid to have just a regex arg and to
|
||||
specify neither capture or expect_captures args. This
|
||||
arg only makes sense if exact_payload is not
|
||||
regex: currently only valid for receives from gdbremote. When
|
||||
specified (and only if exact_payload is None), indicates the
|
||||
gdbremote response must match the given regex. Match groups in
|
||||
the regex can be used for the matching portion (see capture
|
||||
arg). It is perfectly valid to have just a regex arg without a
|
||||
capture arg. This arg only makes sense if exact_payload is not
|
||||
specified.
|
||||
|
||||
capture: if specified, is a dictionary of regex match
|
||||
|
@ -417,24 +412,12 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
|
|||
index. For example, {1:"thread_id"} will store capture
|
||||
group 1's content in the context dictionary where
|
||||
"thread_id" is the key and the match group value is
|
||||
the value. The value stored off can be used later in a
|
||||
expect_captures expression. This arg only makes sense
|
||||
when regex is specified.
|
||||
|
||||
expect_captures: if specified, is a dictionary of regex
|
||||
match group indices (should start with 1) to variable
|
||||
names, where the match group should match the value
|
||||
existing in the context at the given variable name.
|
||||
For example, {2:"thread_id"} indicates that the second
|
||||
match group must match the value stored under the
|
||||
context's previously stored "thread_id" key. This arg
|
||||
only makes sense when regex is specified.
|
||||
the value. This arg only makes sense when regex is specified.
|
||||
"""
|
||||
self._is_send_to_remote = is_send_to_remote
|
||||
self.exact_payload = exact_payload
|
||||
self.regex = regex
|
||||
self.capture = capture
|
||||
self.expect_captures = expect_captures
|
||||
|
||||
def is_send_to_remote(self):
|
||||
return self._is_send_to_remote
|
||||
|
@ -473,15 +456,6 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
|
|||
# above.
|
||||
context[var_name] = capture_text
|
||||
|
||||
if self.expect_captures:
|
||||
# Handle comparing matched groups to context dictionary entries.
|
||||
for group_index, var_name in list(self.expect_captures.items()):
|
||||
capture_text = match.group(group_index)
|
||||
if not capture_text:
|
||||
raise Exception(
|
||||
"No content to expect for group index {}".format(group_index))
|
||||
asserter.assertEqual(capture_text, context[var_name])
|
||||
|
||||
return context
|
||||
|
||||
def assert_match(self, asserter, actual_packet, context=None):
|
||||
|
@ -658,8 +632,7 @@ class MatchRemoteOutputEntry(GdbRemoteEntryBase):
|
|||
with 1) to variable names that will store the capture group indicated by the
|
||||
index. For example, {1:"thread_id"} will store capture group 1's content in the
|
||||
context dictionary where "thread_id" is the key and the match group value is
|
||||
the value. The value stored off can be used later in a expect_captures expression.
|
||||
This arg only makes sense when regex is specified.
|
||||
the value. This arg only makes sense when regex is specified.
|
||||
"""
|
||||
|
||||
def __init__(self, regex=None, regex_mode="match", capture=None):
|
||||
|
@ -783,7 +756,6 @@ class GdbRemoteTestSequence(object):
|
|||
direction = line.get("direction", None)
|
||||
regex = line.get("regex", None)
|
||||
capture = line.get("capture", None)
|
||||
expect_captures = line.get("expect_captures", None)
|
||||
|
||||
# Compile the regex.
|
||||
if regex and (isinstance(regex, str)):
|
||||
|
@ -798,8 +770,7 @@ class GdbRemoteTestSequence(object):
|
|||
GdbRemoteEntry(
|
||||
is_send_to_remote=True,
|
||||
regex=regex,
|
||||
capture=capture,
|
||||
expect_captures=expect_captures))
|
||||
capture=capture))
|
||||
else:
|
||||
# Log line represents content to be expected from the remote debug monitor.
|
||||
# if self.logger:
|
||||
|
@ -808,8 +779,7 @@ class GdbRemoteTestSequence(object):
|
|||
GdbRemoteEntry(
|
||||
is_send_to_remote=False,
|
||||
regex=regex,
|
||||
capture=capture,
|
||||
expect_captures=expect_captures))
|
||||
capture=capture))
|
||||
elif entry_type == "multi_response":
|
||||
self.entries.append(MultiResponseGdbRemoteEntry(line))
|
||||
elif entry_type == "output_match":
|
||||
|
|
|
@ -78,13 +78,14 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
|
|||
self.test_sequence.add_log_lines(["read packet: $qC#00",
|
||||
{"direction": "send",
|
||||
"regex": r"^\$QC([0-9a-fA-F]+)#",
|
||||
"capture": {1: "thread_id"}},
|
||||
"capture": {1: "thread_id_QC"}},
|
||||
"read packet: $?#00",
|
||||
{"direction": "send",
|
||||
"regex": r"^\$T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+)",
|
||||
"expect_captures": {1: "thread_id"}}],
|
||||
"capture": {1: "thread_id_?"}}],
|
||||
True)
|
||||
self.expect_gdbremote_sequence()
|
||||
context = self.expect_gdbremote_sequence()
|
||||
self.assertEqual(context.get("thread_id_QC"), context.get("thread_id_?"))
|
||||
|
||||
def test_attach_commandline_continue_app_exits(self):
|
||||
self.build()
|
||||
|
|
Loading…
Reference in New Issue