1 # Copyright (C) 1998, 1999, 2002 Red Hat, 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 # This file was written by Keith Seitz (keiths@cygnus.com)
19 # Read in the standard defs file
21 if {![gdbtk_read_defs]} {
25 global objdir test_ran
27 set console [ManagedWin::open Console]
28 set text [$console test set _twin]
32 # Helper functions for this module #
37 # Invoke STRING as a command in the console window and
39 proc console_command {string} {
42 # Save current position
43 set line [lindex [split [$text index cmdmark] .] 0]
46 # Insert and invoke command
47 $text insert end $string
52 set end [lindex [split [$text index cmdmark] .] 0]
54 return [$text get $line.0 [list $end.0 lineend]]
58 # Return the command line
59 proc get_cmd_line {} {
63 set index [$text index cmdmark]
64 return [$text get [list $index linestart] [list $index lineend]]
67 # clear_command_line --
68 # Clear the command line
69 proc clear_command_line {} {
71 $text delete {cmdmark + 1 char} insert
84 # Test: console-misc-1
85 # Desc: Change console prompt
86 gdbtk_test console-misc-1 {change console prompt} {
87 # Insert the "set prompt" command into the text widget
88 console_command {set prompt (test) }
90 $text get {cmdmark linestart} {cmdmark lineend}
93 console_command {set prompt (gdb) }
100 # Test: console-paste-1
101 # Desc: Paste the X selection into console window
102 gdbtk_test console-paste-1 {paste X text} {
103 # This is cheesy, but it works... Create a text widget
104 # which holds the current selection...
106 .test_text insert end "this is some pasted text"
107 .test_text tag add sel 1.0 {1.0 lineend}
108 event generate .test_text <<Copy>>
109 event generate $text <<Paste>>
111 } {(gdb) this is some pasted text}
121 # Test: console-error-1
122 # Desc: Check if console window reports internal gdb errors
123 gdbtk_test console-error-1 {invoke unknown command} {
124 console_command {this_command_doesn't_exist}
125 } {Error: Undefined command: "this". Try "help".
132 # Test: console-history-1.1
133 # Desc: Exercise the up-history functionality
134 gdbtk_test console-history-1.1 {up history once} {
135 # Add some commands into the command buffer
136 console_command {show annotate}
137 console_command {show complaints}
138 console_command {show confirm}
139 console_command {show height}
140 console_command {show language}
141 console_command {show print demangle}
142 console_command {show remotebaud}
143 console_command {show remotebreak}
144 console_command {show remotecache}
145 console_command {show remotedebug}
146 console_command {show remotedevice}
147 console_command {show remotelogbase}
148 console_command {help quit}
149 console_command {help si}
150 # this doesn't seem to work reliably: event generate $text <Up>
151 $console test _previous
158 # Test: console-history-1.2
159 # Desc: Exercise the up-history functionality
160 gdbtk_test console-history-1.2 {up history twice} {
161 # Add some commands into the command buffer
162 console_command {show annotate}
163 console_command {show complaints}
164 console_command {show confirm}
165 console_command {show height}
166 console_command {show language}
167 console_command {show print demangle}
168 console_command {show remotebaud}
169 console_command {show remotebreak}
170 console_command {show remotecache}
171 console_command {show remotedebug}
172 console_command {show remotedevice}
173 console_command {show remotelogbase}
174 console_command {help quit}
175 console_command {help si}
176 # this doesn't seem to work reliably: event generate $text <Up>
177 # this doesn't seem to work reliably: event generate $text <Up>
178 $console test _previous
179 $console test _previous
186 # Test: console-history-1.3
187 # Desc: Exercise the up-history functionality
188 gdbtk_test console-history-1.3 {up history four times} {
189 # Add some commands into the command buffer
190 console_command {show annotate}
191 console_command {show complaints}
192 console_command {show confirm}
193 console_command {show height}
194 console_command {show language}
195 console_command {show print demangle}
196 console_command {show remotebaud}
197 console_command {show remotebreak}
198 console_command {show remotecache}
199 console_command {show remotedebug}
200 console_command {show remotedevice}
201 console_command {show remotelogbase}
202 console_command {help quit}
203 console_command {help si}
205 for {set i 0} {$i < 4} {incr i} {
206 # this doesn't seem to work reliably: event generate $text <Up>
207 $console test _previous
210 } {(gdb) show remotedevice}
215 # Test: console-history-1.4
216 # Desc: Exercise the up-history functionality
217 gdbtk_test console-history-1.4 {up fourteen times} {
218 # Add some commands into the command buffer
219 console_command {show annotate}
220 console_command {show complaints}
221 console_command {show confirm}
222 console_command {show height}
223 console_command {show language}
224 console_command {show print demangle}
225 console_command {show remotebaud}
226 console_command {show remotebreak}
227 console_command {show remotecache}
228 console_command {show remotedebug}
229 console_command {show remotedevice}
230 console_command {show remotelogbase}
231 console_command {help quit}
232 console_command {help si}
233 for {set i 0} {$i < 14} {incr i} {
234 # this doesn't seem to work reliably: event generate $text <Up>
235 $console test _previous
238 } {(gdb) show annotate}
243 # Test: console-history-1.5
244 # Desc: Exercise the up-history search functionality
245 gdbtk_test console-history-1.5 {up search} {
246 # Add some commands into the command buffer
247 console_command {show height}
248 console_command {show annotate}
249 console_command {show complaints}
250 console_command {print main}
251 console_command {show remotelogbase}
252 console_command {help quit}
253 console_command {help si}
255 $text insert end "sh"
256 # this doesn't seem to work reliably: event generate $text <Shift-Up>
257 # this doesn't seem to work reliably: event generate $text <Shift-Up>
258 # this doesn't seem to work reliably: event generate $text <Shift-Up>
259 $console test _search_history
260 $console test _search_history
261 $console test _search_history
263 } {(gdb) show annotate}
266 # Test: console-history-1.6
267 # Desc: Exercise the down-history search functionality
268 gdbtk_test console-history-1.6 {down search} {
269 # this doesn't seem to work reliably: event generate $text <Shift-Down>
270 # this doesn't seem to work reliably: event generate $text <Shift-Down>
271 $console test _rsearch_history
272 $console test _rsearch_history
274 } {(gdb) show remotelogbase}
276 # Test: console-history-1.7
277 # Desc: Down-history search to bottom
278 # We go back down until the original partialcommand is displayed
279 gdbtk_test console-history-1.7 {down search to bottom} {
280 # this doesn't seem to work reliably: event generate $text <Shift-Down>
281 # this doesn't seem to work reliably: event generate $text <Shift-Down>
282 $console test _rsearch_history
283 $console test _rsearch_history
287 # Test: console-history-1.8
288 # Desc: Up-history search to top
289 # We go up until there are no matches
290 gdbtk_test console-history-1.8 {up search to top} {
291 for {set i 0} {$i < 100} {incr i} {
292 # this doesn't seem to work reliably: event generate $text <Shift-Up>
293 $console test _search_history
296 } {(gdb) show annotate}
302 # Test: console-history-2.1
303 # Desc: Exercise the down-history functionality
304 gdbtk_test console-history-2.1 {down once} {
305 # Add some commands into the command buffer
306 console_command {show annotate}
307 console_command {show complaints}
308 console_command {show confirm}
309 console_command {show height}
310 console_command {show language}
311 console_command {show print demangle}
312 console_command {show remotebaud}
313 console_command {show remotebreak}
314 console_command {show remotecache}
315 console_command {show remotedebug}
316 console_command {show remotedevice}
317 console_command {show remotelogbase}
318 console_command {help quit}
319 console_command {help si}
321 for {set i 0} {$i < 14} {incr i} {
322 # this doesn't seem to work reliably: event generate $text <Up>
323 $console test _previous
325 # this doesn't seem to work reliably: event generate $text <Down>
328 } {(gdb) show complaints}
333 # Test: console-history-2.2
334 # Desc: Exercise the down-history functionality
335 gdbtk_test console-history-2.2 {down twice} {
336 # Add some commands into the command buffer
337 console_command {show annotate}
338 console_command {show complaints}
339 console_command {show confirm}
340 console_command {show height}
341 console_command {show language}
342 console_command {show print demangle}
343 console_command {show remotebaud}
344 console_command {show remotebreak}
345 console_command {show remotecache}
346 console_command {show remotedebug}
347 console_command {show remotedevice}
348 console_command {show remotelogbase}
349 console_command {help quit}
350 console_command {help si}
352 for {set i 0} {$i < 14} {incr i} {
353 # this doesn't seem to work reliably: event generate $text <Up>
354 $console test _previous
357 # this doesn't seem to work reliably: event generate $text <Down>
358 # this doesn't seem to work reliably: event generate $text <Down>
362 } {(gdb) show confirm}
367 # Test: console-history-2.3
368 # Desc: Exercise the down-history functionality
369 gdbtk_test console-history-2.3 {down four times} {
370 # Add some commands into the command buffer
371 console_command {show annotate}
372 console_command {show complaints}
373 console_command {show confirm}
374 console_command {show height}
375 console_command {show language}
376 console_command {show print demangle}
377 console_command {show remotebaud}
378 console_command {show remotebreak}
379 console_command {show remotecache}
380 console_command {show remotedebug}
381 console_command {show remotedevice}
382 console_command {show remotelogbase}
383 console_command {help quit}
384 console_command {help si}
386 for {set i 0} {$i < 14} {incr i} {
387 # this doesn't seem to work reliably: event generate $text <Up>
388 $console test _previous
391 for {set i 0} {$i < 4} {incr i} {
392 # this doesn't seem to work reliably: event generate $text <Down>
396 } {(gdb) show language}
401 # Test: console-history-2.4
402 # Desc: Exercise the down-history functionality
403 gdbtk_test console-history-2.4 {down infinitely} {
404 # Add some commands into the command buffer
405 console_command {show annotate}
406 console_command {show complaints}
407 console_command {show confirm}
408 console_command {show height}
409 console_command {show language}
410 console_command {show print demangle}
411 console_command {show remotebaud}
412 console_command {show remotebreak}
413 console_command {show remotecache}
414 console_command {show remotedebug}
415 console_command {show remotedevice}
416 console_command {show remotelogbase}
417 console_command {help quit}
418 console_command {help si}
419 for {set i 0} {$i < 14} {incr i} {
420 # this doesn't seem to work reliably: event generate $text <Up>
421 $console test _previous
424 for {set i 0} {$i < 20} {incr i} {
425 # this doesn't seem to work reliably: event generate $text <Down>
435 # gdb - gdbtk Interface Tests
438 # Test: console-interface-1.1
439 # Desc: Verify that a "file" command in the console window causes
440 # gdb to invoke the pre-/post-add-symbol hooks
442 gdbtk_test console-interface-1.1 {file command goes through hooks} {
443 global TEST1_RESULT TEST2_RESULT
445 # This is really ugly, but its the only way to do this...
446 rename gdbtk_tcl_pre_add_symbol pre_add
447 rename gdbtk_tcl_post_add_symbol post_add
449 proc gdbtk_tcl_pre_add_symbol {file} {
452 set TEST1_RESULT $file
455 proc gdbtk_tcl_post_add_symbol {} {
462 # load a file and make sure we went through the pre/post_add_symbol hooks
465 set file [file join $objdir simple]
466 console_command "file $file"
467 if {$TEST1_RESULT != $file} {
468 set result "did not go through gdbtk_tcl_pre_add_symbol ($TEST1_RESULT)"
469 } elseif {$TEST2_RESULT != "ok"} {
470 set result "did not go through gdbtk_tcl_post_add_symbol"
479 rename gdbtk_tcl_pre_add_symbol {}
480 rename gdbtk_tcl_post_add_symbol {}
481 rename pre_add gdbtk_tcl_pre_add_symbol
482 rename post_add gdbtk_tcl_post_add_symbol