[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 7 14:02:40 PDT 2024


================
@@ -0,0 +1,27 @@
+from typing_extensions import override
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CommandOverrideCallback(TestBase):
+    def setUp(self):
+        TestBase.setUp(self)
+        self.line = line_number("main.c", "Hello world.")
+
+    def test_command_override_callback(self):
+        self.build()
+        exe = self.getBuildArtifact("a.out")
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        ci = self.dbg.GetCommandInterpreter()
+        self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
+
+        def foo(*command_args):
+            pass
+
+        self.assertTrue(ci.SetCommandOverrideCallback("breakpoint set", foo))
+        self.expect("breakpoint set -n main", substrs=["Breakpoint"])
----------------
JDevlieghere wrote:

This doesn't test the baton or the fact that the function was called. You should have the foo callback modify a variable or something and verify that the function has been called. 

https://github.com/llvm/llvm-project/pull/94518


More information about the lldb-commits mailing list