]>
Commit | Line | Data |
---|---|---|
c98fe0c1 JI |
1 | # Copyright (C) 1998 Cygnus Solutions |
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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Keith Seitz (keiths@cygnus.com) | |
21 | ||
22 | # Read in the standard defs file | |
23 | ||
24 | if {![gdbtk_read_defs]} { | |
25 | break | |
26 | } | |
27 | ||
28 | global objdir test_ran | |
29 | global console text | |
30 | set console [ManagedWin::open Console] | |
31 | set text [$console get_text] | |
32 | ||
33 | ##### ##### | |
34 | # # | |
35 | # Helper functions for this module # | |
36 | # # | |
37 | ##### ##### | |
38 | ||
39 | # console_command -- | |
40 | # Invoke STRING as a command in the console window and | |
41 | # return the result | |
42 | proc console_command {string} { | |
43 | global console text | |
44 | ||
45 | # Save current position | |
46 | set line [lindex [split [$text index cmdmark] .] 0] | |
47 | incr line 1 | |
48 | ||
49 | # Insert and invoke command | |
50 | $text insert end $string | |
51 | $console invoke | |
52 | update | |
53 | ||
54 | # Get the result | |
55 | set end [lindex [split [$text index cmdmark] .] 0] | |
56 | incr end -1 | |
57 | return [$text get $line.0 [list $end.0 lineend]] | |
58 | } | |
59 | ||
60 | # get_cmd_line -- | |
61 | # Return the command line | |
62 | proc get_cmd_line {} { | |
63 | global text | |
64 | ||
65 | update | |
66 | set index [$text index cmdmark] | |
67 | return [$text get [list $index linestart] [list $index lineend]] | |
68 | } | |
69 | ||
70 | # clear_command_line -- | |
71 | # Clear the command line | |
72 | proc clear_command_line {} { | |
73 | global text | |
74 | $text delete {cmdmark + 1 char} insert | |
75 | } | |
76 | ||
77 | ##### ##### | |
78 | # # | |
79 | # CONSOLE TESTS # | |
80 | # # | |
81 | ##### ##### | |
82 | ||
83 | # | |
84 | # Miscellaneous tests | |
85 | # | |
86 | ||
87 | # Test: console-misc-1 | |
88 | # Desc: Change console prompt | |
89 | gdbtk_test console-misc-1 {change console prompt} { | |
90 | # Insert the "set prompt" command into the text widget | |
91 | console_command {set prompt (test) } | |
92 | ||
93 | $text get {cmdmark linestart} {cmdmark lineend} | |
94 | } {(test) } | |
95 | if {$test_ran} { | |
96 | console_command {set prompt (gdb) } | |
97 | } | |
98 | ||
99 | # | |
100 | # Paste tests | |
101 | # | |
102 | ||
103 | # Test: console-paste-1 | |
104 | # Desc: Paste the X selection into console window | |
105 | gdbtk_test console-paste-1 {paste X text} { | |
106 | # This is cheesy, but it works... Create a text widget | |
107 | # which holds the current selection... | |
108 | text .test_text | |
109 | .test_text insert end "this is some pasted text" | |
110 | .test_text tag add sel 1.0 {1.0 lineend} | |
111 | ||
112 | event generate $text <<Paste>> | |
113 | get_cmd_line | |
114 | } {(gdb) this is some pasted text} | |
115 | if {$test_ran} { | |
116 | destroy .test_text | |
117 | clear_command_line | |
118 | } | |
119 | ||
120 | # | |
121 | # Test for errors | |
122 | # | |
123 | ||
124 | # Test: console-error-1 | |
125 | # Desc: Check if console window reports internal gdb errors | |
126 | gdbtk_test console-error-1 {invoke unknown command} { | |
127 | console_command {this_command_doesn't_exist} | |
128 | } {Error: Undefined command: "this". Try "help". | |
129 | } | |
130 | ||
131 | # | |
132 | # History tests | |
133 | # | |
134 | ||
135 | # Test: console-history-1.1 | |
136 | # Desc: Exercise the up-history functionality | |
137 | gdbtk_test console-history-1.1 {up history once} { | |
138 | # Add some commands into the command buffer | |
139 | console_command {show annotate} | |
140 | console_command {show complaints} | |
141 | console_command {show confirm} | |
142 | console_command {show height} | |
143 | console_command {show language} | |
144 | console_command {show print demangle} | |
145 | console_command {show remotebaud} | |
146 | console_command {show remotebreak} | |
147 | console_command {show remotecache} | |
148 | console_command {show remotedebug} | |
149 | console_command {show remotedevice} | |
150 | console_command {show remotelogbase} | |
151 | console_command {help quit} | |
152 | console_command {help si} | |
153 | event generate $text <Up> | |
154 | get_cmd_line | |
155 | } {(gdb) help si} | |
156 | if {$test_ran} { | |
157 | clear_command_line | |
158 | } | |
159 | ||
160 | # Test: console-history-1.2 | |
161 | # Desc: Exercise the up-history functionality | |
162 | gdbtk_test console-history-1.2 {up history twice} { | |
163 | # Add some commands into the command buffer | |
164 | console_command {show annotate} | |
165 | console_command {show complaints} | |
166 | console_command {show confirm} | |
167 | console_command {show height} | |
168 | console_command {show language} | |
169 | console_command {show print demangle} | |
170 | console_command {show remotebaud} | |
171 | console_command {show remotebreak} | |
172 | console_command {show remotecache} | |
173 | console_command {show remotedebug} | |
174 | console_command {show remotedevice} | |
175 | console_command {show remotelogbase} | |
176 | console_command {help quit} | |
177 | console_command {help si} | |
178 | event generate $text <Up> | |
179 | event generate $text <Up> | |
180 | get_cmd_line | |
181 | } {(gdb) help quit} | |
182 | if {$test_ran} { | |
183 | clear_command_line | |
184 | } | |
185 | ||
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} | |
204 | ||
205 | for {set i 0} {$i < 4} {incr i} { | |
206 | event generate $text <Up> | |
207 | } | |
208 | get_cmd_line | |
209 | } {(gdb) show remotedevice} | |
210 | if {$test_ran} { | |
211 | clear_command_line | |
212 | } | |
213 | ||
214 | # Test: console-history-1.4 | |
215 | # Desc: Exercise the up-history functionality | |
216 | gdbtk_test console-history-1.4 {up fourteen times} { | |
217 | # Add some commands into the command buffer | |
218 | console_command {show annotate} | |
219 | console_command {show complaints} | |
220 | console_command {show confirm} | |
221 | console_command {show height} | |
222 | console_command {show language} | |
223 | console_command {show print demangle} | |
224 | console_command {show remotebaud} | |
225 | console_command {show remotebreak} | |
226 | console_command {show remotecache} | |
227 | console_command {show remotedebug} | |
228 | console_command {show remotedevice} | |
229 | console_command {show remotelogbase} | |
230 | console_command {help quit} | |
231 | console_command {help si} | |
232 | for {set i 0} {$i < 14} {incr i} { | |
233 | event generate $text <Up> | |
234 | } | |
235 | get_cmd_line | |
236 | } {(gdb) show annotate} | |
237 | if {$test_ran} { | |
238 | clear_command_line | |
239 | } | |
240 | ||
241 | # Test: console-history-2.1 | |
242 | # Desc: Exercise the down-history functionality | |
243 | gdbtk_test console-history-2.1 {down once} { | |
244 | # Add some commands into the command buffer | |
245 | console_command {show annotate} | |
246 | console_command {show complaints} | |
247 | console_command {show confirm} | |
248 | console_command {show height} | |
249 | console_command {show language} | |
250 | console_command {show print demangle} | |
251 | console_command {show remotebaud} | |
252 | console_command {show remotebreak} | |
253 | console_command {show remotecache} | |
254 | console_command {show remotedebug} | |
255 | console_command {show remotedevice} | |
256 | console_command {show remotelogbase} | |
257 | console_command {help quit} | |
258 | console_command {help si} | |
259 | ||
260 | for {set i 0} {$i < 14} {incr i} { | |
261 | event generate $text <Up> | |
262 | } | |
263 | event generate $text <Down> | |
264 | get_cmd_line | |
265 | } {(gdb) show complaints} | |
266 | if {$test_ran} { | |
267 | clear_command_line | |
268 | } | |
269 | ||
270 | # Test: console-history-2.2 | |
271 | # Desc: Exercise the down-history functionality | |
272 | gdbtk_test console-history-2.2 {down twice} { | |
273 | # Add some commands into the command buffer | |
274 | console_command {show annotate} | |
275 | console_command {show complaints} | |
276 | console_command {show confirm} | |
277 | console_command {show height} | |
278 | console_command {show language} | |
279 | console_command {show print demangle} | |
280 | console_command {show remotebaud} | |
281 | console_command {show remotebreak} | |
282 | console_command {show remotecache} | |
283 | console_command {show remotedebug} | |
284 | console_command {show remotedevice} | |
285 | console_command {show remotelogbase} | |
286 | console_command {help quit} | |
287 | console_command {help si} | |
288 | ||
289 | for {set i 0} {$i < 14} {incr i} { | |
290 | event generate $text <Up> | |
291 | } | |
292 | ||
293 | event generate $text <Down> | |
294 | event generate $text <Down> | |
295 | get_cmd_line | |
296 | } {(gdb) show confirm} | |
297 | if {$test_ran} { | |
298 | clear_command_line | |
299 | } | |
300 | ||
301 | # Test: console-history-2.3 | |
302 | # Desc: Exercise the down-history functionality | |
303 | gdbtk_test console-history-2.3 {down four times} { | |
304 | # Add some commands into the command buffer | |
305 | console_command {show annotate} | |
306 | console_command {show complaints} | |
307 | console_command {show confirm} | |
308 | console_command {show height} | |
309 | console_command {show language} | |
310 | console_command {show print demangle} | |
311 | console_command {show remotebaud} | |
312 | console_command {show remotebreak} | |
313 | console_command {show remotecache} | |
314 | console_command {show remotedebug} | |
315 | console_command {show remotedevice} | |
316 | console_command {show remotelogbase} | |
317 | console_command {help quit} | |
318 | console_command {help si} | |
319 | ||
320 | for {set i 0} {$i < 14} {incr i} { | |
321 | event generate $text <Up> | |
322 | } | |
323 | ||
324 | for {set i 0} {$i < 4} {incr i} { | |
325 | event generate $text <Down> | |
326 | } | |
327 | get_cmd_line | |
328 | } {(gdb) show language} | |
329 | if {$test_ran} { | |
330 | clear_command_line | |
331 | } | |
332 | ||
333 | # Test: console-history-2.4 | |
334 | # Desc: Exercise the down-history functionality | |
335 | gdbtk_test console-history-2.4 {down infinitely} { | |
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} | |
351 | for {set i 0} {$i < 14} {incr i} { | |
352 | event generate $text <Up> | |
353 | } | |
354 | ||
355 | for {set i 0} {$i < 20} {incr i} { | |
356 | event generate $text <Down> | |
357 | } | |
358 | get_cmd_line | |
359 | } {(gdb) } | |
360 | if {$test_ran} { | |
361 | clear_command_line | |
362 | } | |
363 | ||
364 | # | |
365 | # gdb - gdbtk Interface Tests | |
366 | # | |
367 | ||
368 | # Test: console-interface-1.1 | |
369 | # Desc: Verify that a "file" command in the console window causes | |
370 | # gdb to invoke the pre-/post-add-symbol hooks | |
371 | set file_loaded 0 | |
372 | gdbtk_test console-interface-1.1 {file command goes through hooks} { | |
373 | global TEST1_RESULT TEST2_RESULT | |
374 | ||
375 | # This is really ugly, but its the only way to do this... | |
376 | rename gdbtk_tcl_pre_add_symbol pre_add | |
377 | rename gdbtk_tcl_post_add_symbol post_add | |
378 | ||
379 | proc gdbtk_tcl_pre_add_symbol {file} { | |
380 | global TEST1_RESULT | |
381 | ||
382 | set TEST1_RESULT $file | |
383 | pre_add $file | |
384 | } | |
385 | proc gdbtk_tcl_post_add_symbol {} { | |
386 | global TEST2_RESULT | |
387 | ||
388 | set TEST2_RESULT ok | |
389 | post_add | |
390 | } | |
391 | ||
392 | # load a file and make sure we went through the pre/post_add_symbol hooks | |
393 | set TEST1_RESULT {} | |
394 | set TEST2_RESULT {} | |
395 | set file [file join $objdir simple] | |
396 | console_command "file $file" | |
397 | if {$TEST1_RESULT != $file} { | |
398 | set result "did not go through gdbtk_tcl_pre_add_symbol ($TEST1_RESULT)" | |
399 | } elseif {$TEST2_RESULT != "ok"} { | |
400 | set result "did not go through gdbtk_tcl_post_add_symbol" | |
401 | } else { | |
402 | set result {} | |
403 | set file_loaded 1 | |
404 | } | |
405 | ||
406 | set result | |
407 | } {} | |
408 | if {$test_ran} { | |
409 | rename gdbtk_tcl_pre_add_symbol {} | |
410 | rename gdbtk_tcl_post_add_symbol {} | |
411 | rename pre_add gdbtk_tcl_pre_add_symbol | |
412 | rename post_add gdbtk_tcl_post_add_symbol | |
413 | } | |
414 | ||
415 | # | |
416 | # Exit | |
417 | # | |
418 | gdbtk_test_done |