1 # Copyright (C) 2023-2024 Free Software Foundation, Inc. 2 # This program is free software; you can redistribute it and/or modify 3 # it under the terms of the GNU General Public License as published by 4 # the Free Software Foundation; either version 3 of the License, or 5 # (at your option) any later version. 6 # 7 # This program is distributed in the hope that it will be useful, 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # GNU General Public License for more details. 11 # 12 # You should have received a copy of the GNU General Public License 13 # along with this program. If not, see <http://www.gnu.org/licenses/>. 14 15 # Test custom MI notifications implemented in Python. 16 17 load_lib gdb-python.exp 18 load_lib mi-support.exp 19 set MIFLAGS "-i=mi" 20 21 gdb_exit 22 if {[mi_gdb_start]} { 23 return 24 } 25 26 if {[lsearch -exact [mi_get_features] python] < 0} { 27 unsupported "python support is disabled" 28 return -1 29 } 30 31 standard_testfile 32 33 mi_gdb_test "set python print-stack full" \ 34 ".*\\^done" \ 35 "set python print-stack full" 36 37 mi_gdb_test "python gdb.notify_mi('-test-notification')" \ 38 ".*=-test-notification\r\n\\^done" \ 39 "python notification, no additional data parameter" 40 41 mi_gdb_test "python gdb.notify_mi('-test-notification', None)" \ 42 ".*=-test-notification\r\n\\^done" \ 43 "python notification, no additional data" 44 45 mi_gdb_test "python gdb.notify_mi('-test-notification', \{ 'data1' : 1 , 'data2' : 2 })" \ 46 ".*=-test-notification,data1=\"1\",data2=\"2\"\r\n\\^done" \ 47 "python notification, with additional data" 48 49 mi_gdb_test "python gdb.notify_mi('-test-notification', 1)" \ 50 ".*\\^error,msg=\".*\"" \ 51 "python notification, invalid additional data" 52 53 mi_gdb_test "python gdb.notify_mi('', None)" \ 54 ".*\\^error,msg=\".*\"" \ 55 "python notification, empty notification name" 56 57 mi_gdb_test "python gdb.notify_mi('**invalid**', None)" \ 58 ".*\\^error,msg=\".*\"" \ 59 "python notification, invalid notification name" 60 61 mi_gdb_test "python gdb.notify_mi(\[1,2,3\], None)" \ 62 ".*\\^error,msg=\".*\"" \ 63 "python notification, non-string notification name" 64 65 mi_gdb_test "python gdb.notify_mi()" \ 66 ".*\\^error,msg=\".*\"" \ 67 "python notification, no arguments passed" 68 69 mi_gdb_test "python gdb.notify_mi('thread-group-added', \{'id' : 'i2'\})" \ 70 ".*=thread-group-added,id=\"i2\"\r\n\\^done" \ 71 "python notification, using existing internal notification name" 72