1 # Copyright 2002 Free Software Foundation, Inc.
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Tom Tromey <tromey@redhat.com>
22 # This file is part of the gdb testsuite.
25 # Tests for readline operations.
28 # This function is used to test operate-and-get-next.
29 # NAME is the name of the test.
30 # ARGS is a list of alternating commands and expected results.
31 proc operate_and_get_next {name args} {
34 set my_gdb_prompt "($gdb_prompt| >)"
37 foreach {item result} $args {
38 verbose "sending $item"
41 # We can't use gdb_test here because we might see a " >" prompt.
65 fail "$name - send $item"
68 pass "$name - send $item"
70 set reverse [linsert $reverse 0 $item $result]
73 # Now use C-p to go back to the start.
74 foreach {item result} $reverse {
75 # Actually send C-p followed by C-l. This lets us recognize the
76 # command when gdb prints it again.
88 fail "$name - C-p to $item"
91 pass "$name - C-p to $item"
94 # Now C-o through the list. Don't send the command, since it is
95 # already there. Strip off the first command from the list so we
96 # can see the next command inside the loop.
98 foreach {item result} $args {
101 # If this isn't the first item, make sure we see the command at
115 # For the last item, send a simple \n instead of C-o.
116 if {$count == [llength $args] - 2} {
120 send_gdb [format %c 15]
134 fail "$name - C-o for $item"
137 pass "$name - C-o for $item"
139 set count [expr {$count + 2}]
150 # Don't let a .inputrc file or an existing setting of INPUTRC mess up
151 # the test results. Even if /dev/null doesn't exist on the particular
152 # platform, the readline library will use the default setting just by
153 # failing to open the file. OTOH, opening /dev/null successfully will
154 # also result in the default settings being used since nothing will be
155 # read from this file.
157 if [info exists env(INPUTRC)] {
158 set old_inputrc $env(INPUTRC)
160 set env(INPUTRC) "/dev/null"
163 gdb_reinitialize_dir $srcdir/$subdir
165 set oldtimeout1 $timeout
169 # A simple test of operate-and-get-next.
170 operate_and_get_next "Simple operate-and-get-next" \
175 # Test operate-and-get-next with a secondary prompt.
176 operate_and_get_next "operate-and-get-next with secondary prompt" \
182 # Restore globals modified in this test...
183 if [info exists old_inputrc] {
184 set env(INPUTRC) $old_inputrc
188 set timeout $oldtimeout1