1 # Copyright (C) 2020-2024 Free Software Foundation, Inc. 2 # 3 # This program is free software; you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation; either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 # Test a TUI window implemented in Python. 17 18 load_lib gdb-python.exp 19 require allow_python_tests allow_tui_tests 20 tuiterm_env 21 22 # This test doesn't care about the inferior. 23 standard_testfile py-arch.c 24 25 if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { 26 return -1 27 } 28 29 clean_restart 30 31 Term::clean_restart 24 80 $testfile 32 33 set remote_python_file [gdb_remote_download host \ 34 ${srcdir}/${subdir}/${testfile}.py] 35 gdb_test_no_output "source ${remote_python_file}" \ 36 "source ${testfile}.py" 37 38 gdb_test_no_output "tui new-layout test test 1 status 0 cmd 1" 39 gdb_test_no_output "tui new-layout fail fail 1 status 0 cmd 1" 40 41 if {![Term::enter_tui]} { 42 unsupported "TUI not supported" 43 return 44 } 45 46 Term::command "python print('tui_enabled=' + str(tui_enabled))" 47 Term::check_contents "tui start event" "tui_enabled=True" 48 49 Term::command "layout test" 50 Term::check_contents "test title" \ 51 "This Is The Title" 52 Term::check_contents "Window display" "Test: 0" 53 54 Term::command "python delete_window_title ()" 55 Term::check_contents "error message after trying to delete title" \ 56 "TypeError.*: Cannot delete \"title\" attribute\\." 57 Term::check_contents "title is unchanged" \ 58 "This Is The Title" 59 60 Term::command "python change_window_title ()" 61 Term::check_contents "test new title" \ 62 "New Title" 63 64 Term::resize 51 51 65 # Remember that a resize request actually does two resizes... 66 Term::check_contents "Window was updated" "Test: 2" 67 68 Term::command "layout fail" 69 70 Term::command "tui disable" 71 gdb_test "python print('tui_enabled=' + str(tui_enabled))" \ 72 "tui_enabled=False" \ 73 "tui disable event" 74