Add copyright headers.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / readline.exp
index 511cb6ba2e5fe352a80a9bea97b35397c9c11ecb..ef7fa130c80688c71f406fc82f663eab9cbdc442 100644 (file)
@@ -1,21 +1,17 @@
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright 2002-2014 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 2 of the License, or
+# 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file was written by Tom Tromey <tromey@redhat.com>
 
@@ -139,29 +135,21 @@ proc operate_and_get_next {name args} {
     set count [expr {$count + 2}]
   }
 
-  return 1
-}
-
+  # Match the prompt so the next test starts at the right place.
+  gdb_test "" ".*" "$name - final prompt"
 
-if $tracelevel {
-  strace $tracelevel
+  return 1
 }
 
-# Don't let a .inputrc file or an existing setting of INPUTRC mess up
-# the test results.  Even if /dev/null doesn't exist on the particular
-# platform, the readline library will use the default setting just by
-# failing to open the file.  OTOH, opening /dev/null successfully will
-# also result in the default settings being used since nothing will be
-# read from this file.
-global env
-if [info exists env(INPUTRC)] {
-    set old_inputrc $env(INPUTRC)
-}
-set env(INPUTRC) "/dev/null"
 
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
+if { ![readline_is_used] } {
+    unsupported "readline isn't used."
+    return -1
+}
+
 set oldtimeout1 $timeout
 set timeout 30
 
@@ -178,6 +166,18 @@ operate_and_get_next "operate-and-get-next with secondary prompt" \
   "p 5" "" \
   "end" ".* = 5"
 
+# Verify that arrow keys work in secondary prompts.  The control
+# sequence is a hard-coded VT100 up arrow.
+gdb_test "print 42" "\\\$\[0-9\]* = 42"
+set msg "arrow keys with secondary prompt"
+gdb_test_multiple "if 1 > 0\n\033\[A\033\[A\nend" $msg {
+    -re ".*\\\$\[0-9\]* = 42\r\n$gdb_prompt $" {
+       pass $msg
+    }
+    -re ".*Undefined command:.*$gdb_prompt $" {
+       fail $msg
+    }
+}
 
 # Now repeat the first test with a history file that fills the entire
 # history list.
@@ -202,11 +202,6 @@ operate_and_get_next "Simple operate-and-get-next" \
 
 
 # Restore globals modified in this test...
-if [info exists old_inputrc] {
-    set env(INPUTRC) $old_inputrc
-} else {
-    unset env(INPUTRC)
-}
 if [info exists old_gdbhistfile] {
     set env(GDBHISTFILE) $old_gdbhistfile
 } else {
This page took 0.033821 seconds and 4 git commands to generate.