aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-mi-cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.python/py-mi-cmd.py')
-rw-r--r--gdb/testsuite/gdb.python/py-mi-cmd.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.py b/gdb/testsuite/gdb.python/py-mi-cmd.py
index c7bf5b7..2c86c90 100644
--- a/gdb/testsuite/gdb.python/py-mi-cmd.py
+++ b/gdb/testsuite/gdb.python/py-mi-cmd.py
@@ -118,3 +118,30 @@ def free_invoke(obj, args):
# these as a Python function which is then called from the exp script.
def run_exception_tests():
print("PASS")
+
+
+# Run some execute_mi tests. This is easier to do from Python.
+def run_execute_mi_tests():
+ # Install the command.
+ cmd = pycmd1("-pycmd")
+ # Pass in a representative subset of the pycmd1 keys, and then
+ # check that the result via MI is the same as the result via a
+ # direct Python call. Note that some results won't compare as
+ # equal -- for example, a Python MI command can return a tuple,
+ # but that will be translated to a Python list.
+ for name in ("int", "str", "dct"):
+ expect = cmd.invoke([name])
+ got = gdb.execute_mi("-pycmd", name)
+ if expect != got:
+ print("FAIL: saw " + repr(got) + ", but expected " + repr(expect))
+ return
+ ok = False
+ try:
+ gdb.execute_mi("-pycmd", "exp")
+ # Due to the "denaturation" problem, we have to expect a gdb.error
+ # here and not a gdb.GdbError.
+ except gdb.error:
+ ok = True
+ if not ok:
+ print("FAIL: did not throw exception")
+ print("PASS")