OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [readline.exp] - Blame information for rev 227

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2002, 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
2
 
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 3 of the License, or
6
# (at your option) any later version.
7
#
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.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see .
15
 
16
# This file was written by Tom Tromey 
17
 
18
# This file is part of the gdb testsuite.
19
 
20
#
21
# Tests for readline operations.
22
#
23
 
24
# This function is used to test operate-and-get-next.
25
# NAME is the name of the test.
26
# ARGS is a list of alternating commands and expected results.
27
proc operate_and_get_next {name args} {
28
  global gdb_prompt
29
 
30
  set my_gdb_prompt "($gdb_prompt| >)"
31
 
32
  set reverse {}
33
  foreach {item result} $args {
34
    verbose "sending $item"
35
    sleep 1
36
 
37
    # We can't use gdb_test here because we might see a " >" prompt.
38
    set status 0
39
    send_gdb "$item\n"
40
    gdb_expect {
41
      -re "$item" {
42
        # Ok
43
      }
44
      timeout {
45
        set status 1
46
      }
47
    }
48
 
49
    if {! $status} {
50
      gdb_expect {
51
        -re "$result" {
52
          # Ok.
53
        }
54
        timeout {
55
          set status 1
56
        }
57
      }
58
    }
59
 
60
    if {$status} {
61
      fail "$name - send $item"
62
      return 0
63
    }
64
    pass "$name - send $item"
65
 
66
    set reverse [linsert $reverse 0 $item $result]
67
  }
68
 
69
  # Now use C-p to go back to the start.
70
  foreach {item result} $reverse {
71
    # Actually send C-p followed by C-l.  This lets us recognize the
72
    # command when gdb prints it again.
73
    send_gdb "\x10\x0c"
74
    set status 0
75
    gdb_expect {
76
      -re "$item" {
77
        # Ok
78
      }
79
      timeout {
80
        set status 1
81
      }
82
    }
83
    if {$status} {
84
      fail "$name - C-p to $item"
85
      return 0
86
    }
87
    pass "$name - C-p to $item"
88
  }
89
 
90
  # Now C-o through the list.  Don't send the command, since it is
91
  # already there.  Strip off the first command from the list so we
92
  # can see the next command inside the loop.
93
  set count 0
94
  foreach {item result} $args {
95
    set status 0
96
 
97
    # If this isn't the first item, make sure we see the command at
98
    # the prompt.
99
    if {$count > 0} {
100
      gdb_expect {
101
        -re ".*$item" {
102
          # Ok
103
        }
104
        timeout {
105
          set status 1
106
        }
107
      }
108
    }
109
 
110
    if {! $status} {
111
      # For the last item, send a simple \n instead of C-o.
112
      if {$count == [llength $args] - 2} {
113
        send_gdb "\n"
114
      } else {
115
        # 15 is C-o.
116
        send_gdb [format %c 15]
117
      }
118
      set status 0
119
      gdb_expect {
120
        -re "$result" {
121
          # Ok
122
        }
123
        timeout {
124
          set status 1
125
        }
126
      }
127
    }
128
 
129
    if {$status} {
130
      fail "$name - C-o for $item"
131
      return 0
132
    }
133
    pass "$name - C-o for $item"
134
 
135
    set count [expr {$count + 2}]
136
  }
137
 
138
  # Match the prompt so the next test starts at the right place.
139
  gdb_test "" "" "$name - final prompt"
140
 
141
  return 1
142
}
143
 
144
 
145
if $tracelevel {
146
  strace $tracelevel
147
}
148
 
149
gdb_start
150
gdb_reinitialize_dir $srcdir/$subdir
151
 
152
set oldtimeout1 $timeout
153
set timeout 30
154
 
155
 
156
# A simple test of operate-and-get-next.
157
operate_and_get_next "Simple operate-and-get-next" \
158
  "p 1" ".* = 1" \
159
  "p 2" ".* = 2" \
160
  "p 3" ".* = 3"
161
 
162
# Test operate-and-get-next with a secondary prompt.
163
operate_and_get_next "operate-and-get-next with secondary prompt" \
164
  "if 1 > 0" "" \
165
  "p 5" "" \
166
  "end" ".* = 5"
167
 
168
# Verify that arrow keys work in secondary prompts.  The control
169
# sequence is a hard-coded VT100 up arrow.
170
gdb_test "print 42" "\\\$\[0-9\]* = 42"
171
set msg "arrow keys with secondary prompt"
172
gdb_test_multiple "if 1 > 0\n\033\[A\033\[A\nend" $msg {
173
    -re ".*\\\$\[0-9\]* = 42\r\n$gdb_prompt $" {
174
        pass $msg
175
    }
176
    -re ".*Undefined command:.*$gdb_prompt $" {
177
        fail $msg
178
    }
179
}
180
 
181
# Now repeat the first test with a history file that fills the entire
182
# history list.
183
 
184
if [info exists env(GDBHISTFILE)] {
185
    set old_gdbhistfile $env(GDBHISTFILE)
186
}
187
if [info exists env(HISTSIZE)] {
188
    set old_histsize $env(HISTSIZE)
189
}
190
set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
191
set env(HISTSIZE) "10"
192
 
193
gdb_exit
194
gdb_start
195
gdb_reinitialize_dir $srcdir/$subdir
196
 
197
operate_and_get_next "Simple operate-and-get-next" \
198
  "p 7" ".* = 7" \
199
  "p 8" ".* = 8" \
200
  "p 9" ".* = 9"
201
 
202
 
203
# Restore globals modified in this test...
204
if [info exists old_gdbhistfile] {
205
    set env(GDBHISTFILE) $old_gdbhistfile
206
} else {
207
    unset env(GDBHISTFILE)
208
}
209
if [info exists old_histsize] {
210
    set env(HISTSIZE) $old_histsize
211
} else {
212
    unset env(HISTSIZE)
213
}
214
set timeout $oldtimeout1
215
 
216
return 0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.