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