1 # Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009
2 # Free Software Foundation, Inc.
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 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # test basic Machine interface (MI) operations
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.
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.
29 load_lib mi-support.exp
33 if [mi_gdb_start separate-inferior-tty] {
38 set srcfile ${testfile}.c
39 set binfile ${objdir}/${subdir}/${testfile}
40 set escapedobjdir [string_to_regexp ${objdir}]
41 set envirodir [string_to_regexp ${objdir}/${subdir}]
43 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
44 untested mi-basics.exp
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.
51 # mi_delete_breakpoints
52 # mi_gdb_reinitialize_dir $srcdir/$subdir
53 # mi_gdb_load ${binfile}
55 # Test if the MI interpreter has been configured
57 proc test_mi_interpreter_selection {} {
61 # All this test expects is to get the prompt back
62 # with no syntax error message
63 send_gdb "-gdb-version\n"
65 -re "GNU gdb .*\r\n$mi_gdb_prompt$" \
66 { pass "acceptance of MI operations"
68 -re ".*\r\n$mi_gdb_prompt$" \
69 { fail "acceptance of MI operations"
70 note "Skipping all other MI tests." }
71 -re "Undefined command.*$gdb_prompt $" \
72 { fail "acceptance of MI operations"
73 note "Skipping all other MI tests." }
74 -re ".*$gdb_prompt $" \
75 { fail "acceptance of MI operations"
76 note "Skipping all other MI tests." }
77 timeout { fail "acceptance of MI operations (timeout)"
78 note "Skipping all other MI tests." }
83 proc test_exec_and_symbol_mi_operatons {} {
87 # Load symbols and specify executable on a single operation
89 # -file-exec-and-symbols
91 # Can't use mi_gdb_test as if this doesn't work,
92 # we must give up on the whole test file
93 send_gdb "-file-exec-and-symbols ${binfile}\n"
95 -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" \
96 { pass "file-exec-and-symbols operation" }
97 timeout { fail "file-exec-and-symbols operation (timeout)"
98 note "Skipping all other MI tests."
102 # The following is not used by mi-support.exp, but we test here so
103 # we get done with loading a program basics.
105 # Do it again, but now load symbols and specify executable with
106 # two separate operations
112 # FIXME: file-clear is not implemented yet.
113 # mi_gdb_test "-file-clear" \
115 # "file-clear operation"
117 mi_gdb_test "-file-exec-file ${binfile}" \
119 "file-exec-file operation"
121 mi_gdb_test "-file-symbol-file ${binfile}" \
123 "file-symbol-file operation"
125 # FIXME: if we cannot load we have to skip all other tests.
128 proc test_breakpoints_deletion {} {
132 # Clear all breakpoints and list to confirm
134 # -break-delete (all)
137 # The all parameter is actually no parameter.
138 mi_gdb_test "200-break-delete" \
140 "break-delete (all) operation"
142 mi_gdb_test "201-break-list" \
143 ".*\\\^done,BreakpointTable=\\\{.*,body=\\\[\\\]\\\}" \
144 "all breakpoints removed"
147 proc test_dir_specification {} {
153 # Add to the search directories, display, then reset back to default
155 # -environment-directory arg
156 # -environment-directory
157 # -environment-directory -r
159 mi_gdb_test "202-environment-directory ${objdir}/${subdir}" \
160 "202\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
161 "environment-directory arg operation"
163 mi_gdb_test "203-environment-directory" \
164 "203\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
165 "environment-directory empty-string operation"
167 mi_gdb_test "204-environment-directory -r" \
168 "204\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \
169 "environment-directory operation"
172 proc test_cwd_specification {} {
178 # Change the working directory, then print the current working directory
180 # -environment-cd ${objdir}
183 mi_gdb_test "205-environment-cd ${objdir}" \
185 "environment-cd arg operation"
187 mi_gdb_test "206-environment-pwd" \
188 "206\\\^done,cwd=\"${escapedobjdir}\"" \
189 "environment-pwd operation"
192 proc test_path_specification {} {
200 # Add to the path, display, then reset
203 # -environment-path dir1 dir2
204 # -environment-path -r dir
205 # -environment-path -r
207 send_gdb "-environment-path\n"
209 -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" {
210 set orig_path $expect_out(1,string);
213 perror "-environment-path (timeout)" ;
218 set orig_path [string_to_regexp ${orig_path}]
219 set pathdir [string_to_regexp ${objdir}/${subdir}]
221 mi_gdb_test "207-environment-path" \
222 "207\\\^done,path=\"$orig_path\"" \
223 "environment-path no-args operation"
225 mi_gdb_test "208-environment-path $objdir ${objdir}/${subdir}" \
226 "208\\\^done,path=\"$escapedobjdir.${envirodir}.$orig_path\"" \
227 "environment-path dir1 dir2 operation"
229 mi_gdb_test "209-environment-path -r $objdir" \
230 "209\\\^done,path=\"$escapedobjdir.$orig_path\"" \
231 "environment-path -r dir operation"
233 mi_gdb_test "210-environment-path -r" \
234 "210\\\^done,path=\"$orig_path\"" \
235 "environment-path -r operation"
239 proc test_setshow_inferior_tty {} {
241 global mi_inferior_tty_name
243 # Test that the commands,
246 # are setting/getting the same data in GDB.
248 mi_gdb_test "301-inferior-tty-show" \
249 "301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
250 "initial tty is mi_inferior_tty_name"
252 mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
254 "set tty to /dev/pts/1"
256 mi_gdb_test "303-inferior-tty-show" \
257 "303\\\^done,inferior_tty_terminal=\"/dev/pts/1\"" \
258 "tty was set correctly"
260 mi_gdb_test "304-inferior-tty-set" \
262 "set tty to the empty string"
264 mi_gdb_test "305-inferior-tty-show" \
266 "make sure tty is empty"
268 mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
270 "set tty to mi_inferior_tty_name (the way it was)"
272 mi_gdb_test "307-inferior-tty-show" \
273 "307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
274 "verify tty is correct"
277 if [test_mi_interpreter_selection] {
278 test_exec_and_symbol_mi_operatons
279 test_breakpoints_deletion
280 test_dir_specification
281 test_cwd_specification
282 test_path_specification
283 test_setshow_inferior_tty