]>
Commit | Line | Data |
---|---|---|
6aba47ca DJ |
1 | # Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007 |
2 | # Free Software Foundation, Inc. | |
fb40c209 AC |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # bug-gdb@prep.ai.mit.edu | |
20 | ||
21 | # | |
22 | # test basic Machine interface (MI) operations | |
23 | # | |
24 | # Verify that, using the MI, we can load a program and do | |
25 | # other basic things that are used by all test files through mi_gdb_exit, | |
26 | # mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and | |
27 | # mi_gdb_load, so we can safely use those. | |
28 | # | |
29 | # The goal is not to test gdb functionality, which is done by other tests, | |
30 | # but the command syntax and correct output response to MI operations. | |
31 | # | |
32 | ||
33 | load_lib mi-support.exp | |
b30bf9ee | 34 | set MIFLAGS "-i=mi" |
fb40c209 AC |
35 | |
36 | gdb_exit | |
ecd3fd0f | 37 | if [mi_gdb_start separate-inferior-tty] { |
fb40c209 AC |
38 | continue |
39 | } | |
40 | ||
41 | set testfile "basics" | |
42 | set srcfile ${testfile}.c | |
43 | set binfile ${objdir}/${subdir}/${testfile} | |
e0f353ce EZ |
44 | set escapedobjdir [string_to_regexp ${objdir}] |
45 | set escapedsrcdir [string_to_regexp ${srcdir}] | |
46 | ||
fb40c209 | 47 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { |
b60f0898 JB |
48 | untested mi-basics.exp |
49 | return -1 | |
fb40c209 AC |
50 | } |
51 | ||
52 | # In this file we want to test if the operations needed by the following | |
53 | # procedures work, so it makes no sense using them here. | |
54 | ||
55 | # mi_delete_breakpoints | |
56 | # mi_gdb_reinitialize_dir $srcdir/$subdir | |
57 | # mi_gdb_load ${binfile} | |
58 | ||
59 | # Test if the MI interpreter has been configured | |
60 | ||
61 | proc test_mi_interpreter_selection {} { | |
62 | global mi_gdb_prompt | |
63 | global gdb_prompt | |
64 | ||
65 | # All this test expects is to get the prompt back | |
66 | # with no syntax error message | |
67 | send_gdb "-gdb-version\n" | |
68 | gdb_expect { | |
69 | -re "GNU gdb .*\r\n$mi_gdb_prompt$" \ | |
70 | { pass "acceptance of MI operations" | |
71 | return 1} | |
72 | -re ".*\r\n$mi_gdb_prompt$" \ | |
73 | { fail "acceptance of MI operations" | |
74 | note "Skipping all other MI tests." } | |
75 | -re "Undefined command.*$gdb_prompt $" \ | |
76 | { fail "acceptance of MI operations" | |
77 | note "Skipping all other MI tests." } | |
78 | -re ".*$gdb_prompt $" \ | |
79 | { fail "acceptance of MI operations" | |
80 | note "Skipping all other MI tests." } | |
81 | timeout { fail "acceptance of MI operations (timeout)" | |
82 | note "Skipping all other MI tests." } | |
83 | } | |
84 | return 0 | |
85 | } | |
86 | ||
87 | proc test_exec_and_symbol_mi_operatons {} { | |
88 | global mi_gdb_prompt | |
89 | global binfile | |
90 | ||
91 | # Load symbols and specify executable on a single operation | |
92 | # Tests: | |
93 | # -file-exec-and-symbols | |
94 | ||
95 | # Can't use mi_gdb_test as if this doesn't work, | |
96 | # we must give up on the whole test file | |
97 | send_gdb "-file-exec-and-symbols ${binfile}\n" | |
98 | gdb_expect { | |
99 | -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" \ | |
100 | { pass "file-exec-and-symbols operation" } | |
101 | timeout { fail "file-exec-and-symbols operation (timeout)" | |
102 | note "Skipping all other MI tests." | |
103 | return 0} | |
104 | } | |
105 | ||
106 | # The following is not used by mi-support.exp, but we test here so | |
107 | # we get done with loading a program basics. | |
108 | ||
109 | # Do it again, but now load symbols and specify executable with | |
110 | # two separate operations | |
111 | # Tests: | |
112 | # -file-clear | |
113 | # -file-exec-file | |
114 | # -file-symbol-file | |
115 | ||
116 | # FIXME: file-clear is not implemented yet. | |
2231a1e8 EZ |
117 | # mi_gdb_test "-file-clear" \ |
118 | # "\\\^done" \ | |
119 | # "file-clear operation" | |
fb40c209 AC |
120 | |
121 | mi_gdb_test "-file-exec-file ${binfile}" \ | |
122 | "\\\^done" \ | |
123 | "file-exec-file operation" | |
124 | ||
125 | mi_gdb_test "-file-symbol-file ${binfile}" \ | |
126 | "\\\^done" \ | |
127 | "file-symbol-file operation" | |
128 | ||
129 | # FIXME: if we cannot load we have to skip all other tests. | |
130 | } | |
131 | ||
132 | proc test_breakpoints_deletion {} { | |
133 | global mi_gdb_prompt | |
134 | global srcfile | |
135 | ||
136 | # Clear all breakpoints and list to confirm | |
137 | # Tests: | |
138 | # -break-delete (all) | |
139 | # -break-list | |
140 | ||
141 | # The all parameter is actually no parameter. | |
142 | mi_gdb_test "200-break-delete" \ | |
39fb8e9e | 143 | "200\\\^done" \ |
fb40c209 AC |
144 | "break-delete (all) operation" |
145 | ||
146 | mi_gdb_test "201-break-list" \ | |
cff22675 | 147 | ".*\\\^done,BreakpointTable=\\\{.*,body=\\\[\\\]\\\}" \ |
fb40c209 AC |
148 | "all breakpoints removed" |
149 | } | |
150 | ||
151 | proc test_dir_specification {} { | |
152 | global mi_gdb_prompt | |
153 | global srcdir | |
154 | global subdir | |
155 | ||
93ce5efb | 156 | # Add to the search directories, display, then reset back to default |
fb40c209 | 157 | # Tests: |
fb40c209 | 158 | # -environment-directory arg |
93ce5efb JJ |
159 | # -environment-directory |
160 | # -environment-directory -r | |
fb40c209 | 161 | |
e0f353ce EZ |
162 | set envirodir [string_to_regexp ${srcdir}/${subdir}] |
163 | ||
93ce5efb | 164 | mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \ |
540b8a30 | 165 | "202\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ |
93ce5efb JJ |
166 | "environment-directory arg operation" |
167 | ||
168 | mi_gdb_test "203-environment-directory" \ | |
540b8a30 | 169 | "203\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ |
93ce5efb JJ |
170 | "environment-directory empty-string operation" |
171 | ||
172 | mi_gdb_test "204-environment-directory -r" \ | |
39fb8e9e | 173 | "204\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \ |
fb40c209 | 174 | "environment-directory operation" |
fb40c209 AC |
175 | } |
176 | ||
93ce5efb JJ |
177 | proc test_cwd_specification {} { |
178 | global mi_gdb_prompt | |
179 | global objdir | |
e0f353ce | 180 | global escapedobjdir |
93ce5efb JJ |
181 | global subdir |
182 | ||
183 | # Change the working directory, then print the current working directory | |
184 | # Tests: | |
185 | # -environment-cd ${objdir} | |
186 | # -environment-pwd | |
187 | ||
188 | mi_gdb_test "205-environment-cd ${objdir}" \ | |
39fb8e9e | 189 | "205\\\^done" \ |
93ce5efb JJ |
190 | "environment-cd arg operation" |
191 | ||
192 | mi_gdb_test "206-environment-pwd" \ | |
39fb8e9e | 193 | "206\\\^done,cwd=\"${escapedobjdir}\"" \ |
93ce5efb JJ |
194 | "environment-pwd operation" |
195 | } | |
196 | ||
197 | proc test_path_specification {} { | |
198 | global mi_gdb_prompt | |
199 | global orig_path | |
200 | global objdir | |
201 | global srcdir | |
e0f353ce EZ |
202 | global escapedobjdir |
203 | global escapedsrcdir | |
93ce5efb JJ |
204 | |
205 | # Add to the path, display, then reset | |
206 | # Tests: | |
207 | # -environment-path | |
208 | # -environment-path dir1 dir2 | |
209 | # -environment-path -r dir | |
210 | # -environment-path -r | |
211 | ||
93ce5efb JJ |
212 | send_gdb "-environment-path\n" |
213 | gdb_expect 20 { | |
214 | -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" { | |
215 | set orig_path $expect_out(1,string); | |
216 | } | |
217 | timeout { | |
218 | perror "-environment-path (timeout)" ; | |
219 | return | |
220 | } | |
221 | } | |
222 | ||
041bf30d VP |
223 | set orig_path [string_to_regexp ${orig_path}] |
224 | ||
93ce5efb | 225 | mi_gdb_test "207-environment-path" \ |
39fb8e9e | 226 | "207\\\^done,path=\"$orig_path\"" \ |
93ce5efb JJ |
227 | "environment-path no-args operation" |
228 | ||
229 | mi_gdb_test "208-environment-path $srcdir $objdir" \ | |
540b8a30 | 230 | "208\\\^done,path=\"$escapedsrcdir.$escapedobjdir.$orig_path\"" \ |
93ce5efb JJ |
231 | "environment-path dir1 dir2 operation" |
232 | ||
233 | mi_gdb_test "209-environment-path -r $objdir" \ | |
39fb8e9e | 234 | "209\\\^done,path=\"$escapedobjdir.$orig_path\"" \ |
93ce5efb JJ |
235 | "environment-path -r dir operation" |
236 | ||
237 | mi_gdb_test "210-environment-path -r" \ | |
39fb8e9e | 238 | "210\\\^done,path=\"$orig_path\"" \ |
93ce5efb JJ |
239 | "environment-path -r operation" |
240 | ||
93ce5efb JJ |
241 | } |
242 | ||
3cb3b8df BR |
243 | proc test_setshow_inferior_tty {} { |
244 | global mi_gdb_prompt | |
ecd3fd0f | 245 | global mi_inferior_tty_name |
3cb3b8df BR |
246 | |
247 | # Test that the commands, | |
248 | # -inferior-tty-set | |
249 | # -inferior-tty-show | |
250 | # are setting/getting the same data in GDB. | |
251 | ||
252 | mi_gdb_test "301-inferior-tty-show" \ | |
ecd3fd0f BR |
253 | "301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \ |
254 | "initial tty is mi_inferior_tty_name" | |
3cb3b8df BR |
255 | |
256 | mi_gdb_test "302-inferior-tty-set /dev/pts/1" \ | |
257 | "302\\\^done" \ | |
258 | "set tty to /dev/pts/1" | |
259 | ||
260 | mi_gdb_test "303-inferior-tty-show" \ | |
261 | "303\\\^done,inferior_tty_terminal=\"/dev/pts/1\"" \ | |
262 | "tty was set correctly" | |
263 | ||
264 | mi_gdb_test "304-inferior-tty-set" \ | |
265 | "304\\\^done" \ | |
266 | "set tty to the empty string" | |
267 | ||
268 | mi_gdb_test "305-inferior-tty-show" \ | |
269 | "305\\\^done" \ | |
ecd3fd0f BR |
270 | "make sure tty is empty" |
271 | ||
272 | mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \ | |
273 | "306\\\^done" \ | |
274 | "set tty to mi_inferior_tty_name (the way it was)" | |
275 | ||
276 | mi_gdb_test "307-inferior-tty-show" \ | |
277 | "307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \ | |
278 | "verify tty is correct" | |
3cb3b8df BR |
279 | } |
280 | ||
fb40c209 AC |
281 | if [test_mi_interpreter_selection] { |
282 | test_exec_and_symbol_mi_operatons | |
283 | test_breakpoints_deletion | |
284 | test_dir_specification | |
93ce5efb JJ |
285 | test_cwd_specification |
286 | test_path_specification | |
3cb3b8df | 287 | test_setshow_inferior_tty |
fb40c209 AC |
288 | } |
289 | ||
290 | mi_gdb_exit | |
291 | return 0 |