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