+ -re ".*$gdb_prompt $" { fail "complete 'p &values\[0\] -> a'" }
+ timeout { fail "(timeout) complete 'p &values\[0\] -> a' 2" }
+ }
+
+# The following tests used to simply try to complete `${objdir}/file',
+# and so on. The problem is that ${objdir} can be very long; the
+# completed filename may be more than eighty characters wide. When
+# this happens, readline tries to manage things, producing output that
+# may make sense on the screen, but is rather hard for our script to
+# recognize.
+#
+# In the case that motivated this change, the (gdb) prompt occupied
+# the leftmost six columns, and `${objdir}/' was seventy-four
+# characters long --- eighty in all. After printing the slash,
+# readline emitted a space, a carriage return, and then `Makefile'
+# (the tab character being received as input after `Make'.
+#
+# Basically, you have to let readline do whatever it's going to do to
+# make the screen look right. If it happens to use a different
+# strategy on Tuesdays to get the cursor in the right place, that's
+# not something the testsuite should care about.
+#
+# So, we avoid long lines. We `cd' to ${objdir} first, and then do
+# the completion relative to the current directory.
+
+# ${srcdir} may be a relative path. We want to make sure we end up
+# in the right directory - so make sure we know where it is.
+set mydir [pwd]
+cd ${srcdir}
+set fullsrcdir [pwd]
+cd ${mydir}
+
+# If the directory name contains a '+' we must escape it, adding a backslash.
+# If not, the test below will fail because it will interpret the '+' as a
+# regexp operator. We use string_to_regexp for this purpose.
+
+gdb_test "cd ${fullsrcdir}" \
+ "Working directory [string_to_regexp ${fullsrcdir}].*" \
+ "cd to \${srcdir}"
+
+send_gdb "complete file ./gdb.base/compl\n"
+sleep 1
+gdb_expect {
+ -re "file ./gdb.base/completion\\.exp.*$gdb_prompt $"
+ { pass "complete-command 'file ./gdb.base/compl'"}
+ -re ".*$gdb_prompt $" { fail "complete-command 'file ./gdb.base/compl'" }
+ timeout { fail "(timeout) complete-command 'file ./gdb.base/compl'" }
+}
+
+send_gdb "file ./gdb.base/complet\t"
+sleep 1
+gdb_expect {
+ -re "^file ./gdb.base/completion\\.exp $"\
+ { send_gdb "\n"
+ # Ignore the exact error message.
+ gdb_test_multiple "" "complete 'file ./gdb.base/complet'" {
+ -re "\r\nA program is being debugged already\\.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\) $" {
+ send_gdb "n\n"
+ exp_continue
+ }
+ -re ".*$gdb_prompt $" { pass "complete 'file ./gdb.base/complet'" }
+ }
+ }
+ -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/complet'" }
+ timeout { fail "(timeout) complete 'file ./gdb.base/complet'" }