[Lldb-commits] [lldb] ded6604 - [lldb/test] Remove the "expect_captures" feature of lldb-server tests
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 14 12:09:11 PDT 2021
Author: Pavel Labath
Date: 2021-04-14T21:08:55+02:00
New Revision: ded660495f4e6514823db9ebadbbfa7653c061f3
URL: https://github.com/llvm/llvm-project/commit/ded660495f4e6514823db9ebadbbfa7653c061f3
DIFF: https://github.com/llvm/llvm-project/commit/ded660495f4e6514823db9ebadbbfa7653c061f3.diff
LOG: [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).
Added:
Modified:
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index a769cb1226fc4..4323e97126d01 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -381,8 +381,7 @@ def __init__(
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 @@ def __init__(
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
-
diff erent 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 @@ def __init__(
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 @@ def _assert_regex_match(self, asserter, actual_packet, context):
# 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 @@ def add_log_lines(self, log_lines, remote_input_is_read):
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 @@ def add_log_lines(self, log_lines, remote_input_is_read):
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 @@ def add_log_lines(self, log_lines, remote_input_is_read):
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":
diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 02bd3637906b4..39079bdf4a0f8 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -78,13 +78,14 @@ def test_first_launch_stop_reply_thread_matches_first_qC(self):
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()
More information about the lldb-commits
mailing list