aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-mi-cmd.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.python/py-mi-cmd.exp')
-rw-r--r--gdb/testsuite/gdb.python/py-mi-cmd.exp65
1 files changed, 57 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.python/py-mi-cmd.exp
index 28c71cd..7c630f6 100644
--- a/gdb/testsuite/gdb.python/py-mi-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2024 Free Software Foundation, Inc.
+# Copyright (C) 2019-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@@ -119,13 +119,47 @@ mi_gdb_test "-pycmd dash-key" \
# With this argument the command raises a gdb.GdbError with no message
# string. GDB considers this a bug in the user program, so prints a
# backtrace, and a generic error message.
-mi_gdb_test "-pycmd exp" \
- [multi_line ".*&\"Traceback \\(most recent call last\\):..\"" \
- "&\"\[^\r\n\]+${testfile}.py\[^\r\n\]+\"" \
- "&\"\[^\r\n\]+raise gdb.GdbError\\(\\)..\"" \
- "&\"gdb.GdbError..\"" \
- "\\^error,msg=\"Error occurred in Python\\.\""] \
- "-pycmd exp"
+
+set line1 \
+ [string_to_regexp {Traceback (most recent call last):\n}]
+set line2 \
+ [string cat \
+ [string_to_regexp { File \"}] \
+ "\[^\r\n\]+" \
+ [string_to_regexp ${testfile}.py] \
+ [string_to_regexp {\", line }] \
+ $decimal \
+ [string_to_regexp {, in invoke\n}]]
+set line3 \
+ [string_to_regexp { raise gdb.GdbError()\n}]
+set line4 \
+ [string_to_regexp {gdb.GdbError\n}]
+set errline \
+ [string_to_regexp {^error,msg="Error occurred in Python."}]
+
+set start_line \
+ [string_to_regexp {&"}]
+set end_line \
+ [string_to_regexp {"}]
+
+# With python <= 3.12.
+set re1 \
+ [multi_line \
+ $start_line$line1$end_line \
+ $start_line$line2$end_line \
+ $start_line$line3$end_line \
+ $start_line$line4$end_line \
+ $errline]
+
+# With python >= 3.13.
+set re2 \
+ [multi_line \
+ $start_line$line1$end_line \
+ $start_line$line2$line3$end_line \
+ $start_line$line4$end_line \
+ $errline]
+
+mi_gdb_test "-pycmd exp" ($re1|$re2)
mi_gdb_test "python pycmd2('-pycmd')" \
".*\\^done" \
@@ -199,6 +233,21 @@ mi_gdb_test "-abc str" \
"\\^error,msg=\"Undefined MI command: abc\",code=\"undefined-command\"" \
"-abc str, but now the command is gone"
+mi_gdb_test "python cmd.installed = None" \
+ ".*\r\n\\^error,msg=\"Error occurred in Python: gdb\\.MICommand\\.installed must be set to a bool, not None\"" \
+ "re-install the mi command using value None"
+
+mi_gdb_test "python cmd.installed = 1" \
+ ".*\r\n\\^error,msg=\"Error occurred in Python: gdb\\.MICommand\\.installed must be set to a bool, not int\"" \
+ "re-install the mi command using an int value"
+
+mi_gdb_test "python print(cmd.installed)" \
+ [multi_line \
+ ".*" \
+ "~\"False\\\\n\"" \
+ "\\^done"] \
+ "cmd is still not installed"
+
mi_gdb_test "python cmd.installed = True" \
".*\\^done" \
"re-install the mi command"