Files
binutils-gdb/gdb/testsuite/gdb.base/eof-exit.exp
Andrew Burgess 47b8bb38fc gdb/testsuite: fix test failure when building against readline v7
The test added in the commit:

  commit a6b413d24c
  Date:   Fri Mar 11 14:44:03 2022 +0000

      gdb: work around prompt corruption caused by bracketed-paste-mode

Was not written with readline 7 in mind, only readline 8+.  Between
readline 7 and 8 the escape sequence used to disable bracketed paste
mode changed, an additional '\r' character was added to the end.  In
fact, it was the addition of this '\r' character that triggered the
issue for which the above commit is part of the solution.

Anyway, the test tries to spot the case where the output from GDB is
not perfect, but does have the above work around applied.  However,
the pattern in the test assumes that the problematic '\r' will be
present, and this is only true for readline 8+.  With readline 7 the
test was failing.

In this commit I generalise the pattern a little so that the test will
still KFAIL with readline 7.

It's a little unfortunate that the test is KFAILing with readline 7,
as without the problematic '\r' there's actually no reason that GDB
couldn't "do the right thing" in this case, in which case, the test
would PASS, but that would require changes within GDB itself.

My preference then is that initially we patch the test to get it
KFAILing, then in a separate commit I can modify GDB so that it can
PASS with readline 7.
2022-03-29 14:39:58 +01:00

89 lines
2.6 KiB
Plaintext

# 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 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
}
}
}
}