diff options
Diffstat (limited to 'gdb/testsuite/gdb.base/eof-exit.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/eof-exit.exp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/eof-exit.exp b/gdb/testsuite/gdb.base/eof-exit.exp new file mode 100644 index 00000000000..ad5f33d2f10 --- /dev/null +++ b/gdb/testsuite/gdb.base/eof-exit.exp @@ -0,0 +1,88 @@ +# Copyright (C) 2022 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 +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This test script checks how GDB handles exiting with ctrl-d. + +# Start GDB, and then close it by sendig ctrl-d. Check that the +# string 'quit' appears where we expect it too. +proc run_test {} { + clean_restart + + # The gdb_start call above swallows the GDB prompt, and we want + # the prompt for the test below. + # + # Send a newline character, which will cause GDB to redisplay the + # prompt. + send_gdb "\n" + gdb_test_multiple "" "discard newline" { + -re "^\r\n" { + } + } + + # Send GDB a ctrl-d. Check that we see the 'quit' string in the + # expected place. + send_gdb "\004" + gdb_test_multiple "" "close GDB with eof" { + -re "$::gdb_prompt \[^\n\]*\r\[^\n\]*quit" { + fail "$gdb_test_name (misplaced \\r)" + } + -re "$::gdb_prompt (?:\[^\n\]*\r)?\[^\n\]*\r\nquit\r\n" { + # For versions of readline that don't include the + # RL_STATE_EOF patch, then the 'quit' is printed on the + # subsequent line. + kfail gdb/28833 "$gdb_test_name (older version of readline)" + } + -re "$::gdb_prompt quit\[^\n\]*\r\n\[^\n\]*\r\n$" { + # There was a bug where GDB would print an extra blank + # line after the 'quit', this catches that case. + fail $gdb_test_name + } + -re "$::gdb_prompt \[^\n\r\]*quit\[^\n\]*\r\n\[^\n\]*$" { + pass $gdb_test_name + } + eof { + fail "$gdb_test_name (missed the prompt)" + } + } +} + +with_test_prefix "default" { + run_test +} + +save_vars { env(TERM) } { + setenv TERM ansi + + with_test_prefix "with non-dump terminal" { + run_test + + save_vars { env(INPUTRC) } { + + # Create an inputrc file that turns bracketed paste mode + # on. This is usually turned off (see lib/gdb.exp), but + # for the next test we want to see what happens with this + # on. + set inputrc [standard_output_file inputrc] + set fd [open "$inputrc" w] + puts $fd "set enable-bracketed-paste on" + close $fd + + setenv INPUTRC "$inputrc" + with_test_prefix "with bracketed-paste-mode on" { + run_test + } + } + } +} |