[Lldb-commits] [lldb] d219a71 - [lldb][lldb-dap][tests] Make sure evaluate test exists with no errors. (#140788)
via lldb-commits
lldb-commits at lists.llvm.org
Wed May 21 10:17:42 PDT 2025
Author: Ebuka Ezike
Date: 2025-05-21T18:17:38+01:00
New Revision: d219a71849f9209b01ee9e71af83747ad44b2a18
URL: https://github.com/llvm/llvm-project/commit/d219a71849f9209b01ee9e71af83747ad44b2a18
DIFF: https://github.com/llvm/llvm-project/commit/d219a71849f9209b01ee9e71af83747ad44b2a18.diff
LOG: [lldb][lldb-dap][tests] Make sure evaluate test exists with no errors. (#140788)
Added:
Modified:
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 4028ae4a2525f..3d90715ca7248 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -116,7 +116,7 @@ def verify_breakpoint_hit(self, breakpoint_ids, timeout=DEFAULT_TIMEOUT):
# location.
description = body["description"]
for breakpoint_id in breakpoint_ids:
- match_desc = "breakpoint %s." % (breakpoint_id)
+ match_desc = f"breakpoint {breakpoint_id}."
if match_desc in description:
return
self.assertTrue(False, f"breakpoint not hit, stopped_events={stopped_events}")
@@ -312,6 +312,9 @@ def continue_to_next_stop(self, timeout=DEFAULT_TIMEOUT):
self.do_continue()
return self.dap_server.wait_for_stopped(timeout)
+ def continue_to_breakpoint(self, breakpoint_id: str, timeout=DEFAULT_TIMEOUT):
+ self.continue_to_breakpoints((breakpoint_id), timeout)
+
def continue_to_breakpoints(self, breakpoint_ids, timeout=DEFAULT_TIMEOUT):
self.do_continue()
self.verify_breakpoint_hit(breakpoint_ids, timeout)
diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
index 2166e88151986..0d2774b281710 100644
--- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
+++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
@@ -5,10 +5,8 @@
import re
import lldbdap_testcase
-import dap_server
-from lldbsuite.test import lldbutil
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
@@ -45,20 +43,32 @@ def run_test_evaluate_expressions(
enableAutoVariableSummaries=enableAutoVariableSummaries,
)
source = "main.cpp"
- self.set_source_breakpoints(
- source,
- [
- line_number(source, "// breakpoint 1"),
- line_number(source, "// breakpoint 2"),
- line_number(source, "// breakpoint 3"),
- line_number(source, "// breakpoint 4"),
- line_number(source, "// breakpoint 5"),
- line_number(source, "// breakpoint 6"),
- line_number(source, "// breakpoint 7"),
- line_number(source, "// breakpoint 8"),
- ],
+ breakpoint_lines = [
+ line_number(source, "// breakpoint 1"),
+ line_number(source, "// breakpoint 2"),
+ line_number(source, "// breakpoint 3"),
+ line_number(source, "// breakpoint 4"),
+ line_number(source, "// breakpoint 5"),
+ line_number(source, "// breakpoint 6"),
+ line_number(source, "// breakpoint 7"),
+ line_number(source, "// breakpoint 8"),
+ ]
+ breakpoint_ids = self.set_source_breakpoints(source, breakpoint_lines)
+
+ self.assertEqual(
+ len(breakpoint_ids),
+ len(breakpoint_lines),
+ "Did not resolve all the breakpoints.",
)
- self.continue_to_next_stop()
+ breakpoint_1 = breakpoint_ids[0]
+ breakpoint_2 = breakpoint_ids[1]
+ breakpoint_3 = breakpoint_ids[2]
+ breakpoint_4 = breakpoint_ids[3]
+ breakpoint_5 = breakpoint_ids[4]
+ breakpoint_6 = breakpoint_ids[5]
+ breakpoint_7 = breakpoint_ids[6]
+ breakpoint_8 = breakpoint_ids[7]
+ self.continue_to_breakpoint(breakpoint_1)
# Expressions at breakpoint 1, which is in main
self.assertEvaluate("var1", "20")
@@ -124,7 +134,7 @@ def run_test_evaluate_expressions(
self.assertEvaluateFailure("foo_var")
# Expressions at breakpoint 2, which is an anonymous block
- self.continue_to_next_stop()
+ self.continue_to_breakpoint(breakpoint_2)
self.assertEvaluate("var1", "20")
self.assertEvaluate("var2", "2") #
diff erent variable with the same name
self.assertEvaluate("static_int", "42")
@@ -162,7 +172,7 @@ def run_test_evaluate_expressions(
self.assertEvaluateFailure("foo_var")
# Expressions at breakpoint 3, which is inside a_function
- self.continue_to_next_stop()
+ self.continue_to_breakpoint(breakpoint_3)
self.assertEvaluate("list", "42")
self.assertEvaluate("static_int", "42")
self.assertEvaluate("non_static_int", "43")
@@ -188,28 +198,30 @@ def run_test_evaluate_expressions(
self.assertEvaluateFailure("foo_var")
# Now we check that values are updated after stepping
- self.continue_to_next_stop()
+ self.continue_to_breakpoint(breakpoint_4)
self.assertEvaluate("my_vec", "size=2")
- self.continue_to_next_stop()
+ self.continue_to_breakpoint(breakpoint_5)
self.assertEvaluate("my_vec", "size=3")
self.assertEvaluate("my_map", "size=2")
- self.continue_to_next_stop()
+ self.continue_to_breakpoint(breakpoint_6)
self.assertEvaluate("my_map", "size=3")
self.assertEvaluate("my_bool_vec", "size=1")
- self.continue_to_next_stop()
+ self.continue_to_breakpoint(breakpoint_7)
self.assertEvaluate("my_bool_vec", "size=2")
+ self.continue_to_breakpoint(breakpoint_8)
# Test memory read, especially with 'empty' repeat commands.
if context == "repl":
- self.continue_to_next_stop()
self.assertEvaluate("memory read -c 1 &my_ints", ".* 05 .*\n")
self.assertEvaluate("", ".* 0a .*\n")
self.assertEvaluate("", ".* 0f .*\n")
self.assertEvaluate("", ".* 14 .*\n")
self.assertEvaluate("", ".* 19 .*\n")
+ self.continue_to_exit()
+
@skipIfWindows
def test_generic_evaluate_expressions(self):
# Tests context-less expression evaluations
More information about the lldb-commits
mailing list