1 # Copyright 1999-2003, 2005, 2007-2012 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # test basic Machine interface (MI) operations
19 # Verify that, using the MI, we can load a program and do
20 # other basic things that are used by all test files through mi_gdb_exit,
21 # mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and
22 # mi_gdb_load, so we can safely use those.
24 # The goal is not to test gdb functionality, which is done by other tests,
25 # but the command syntax and correct output response to MI operations.
28 load_lib mi-support.exp
32 if [mi_gdb_start separate-inferior-tty] {
36 standard_testfile basics.c
37 set escapedobjdir [string_to_regexp ${objdir}]
38 set envirodir [string_to_regexp ${objdir}/${subdir}]
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
41 untested mi-basics.exp
45 # In this file we want to test if the operations needed by the following
46 # procedures work, so it makes no sense using them here.
48 # mi_delete_breakpoints
49 # mi_gdb_reinitialize_dir $srcdir/$subdir
50 # mi_gdb_load ${binfile}
52 # Test if the MI interpreter has been configured
54 proc test_mi_interpreter_selection {} {
58 # All this test expects is to get the prompt back
59 # with no syntax error message
60 if ![mi_gdb_test "-gdb-version" "~\"GNU gdb.*" "acceptance of MI operations"] {
64 note "Skipping all other MI tests."
68 proc test_exec_and_symbol_mi_operatons {} {
72 # Load symbols and specify executable on a single operation
74 # -file-exec-and-symbols
76 if [mi_gdb_test "-file-exec-and-symbols ${binfile}" "\\\^done" \
77 "file-exec-and-symbols operation"] {
78 note "Skipping all other MI tests."
82 # The following is not used by mi-support.exp, but we test here so
83 # we get done with loading a program basics.
85 # Do it again, but now load symbols and specify executable with
86 # two separate operations
92 # FIXME: file-clear is not implemented yet.
93 # mi_gdb_test "-file-clear" \
95 # "file-clear operation"
97 mi_gdb_test "-file-exec-file ${binfile}" \
99 "file-exec-file operation"
101 mi_gdb_test "-file-symbol-file ${binfile}" \
103 "file-symbol-file operation"
105 # We need to return != 0.
109 proc test_breakpoints_deletion {} {
113 # Clear all breakpoints and list to confirm
115 # -break-delete (all)
118 # The all parameter is actually no parameter.
119 mi_gdb_test "200-break-delete" \
121 "break-delete (all) operation"
123 mi_gdb_test "201-break-list" \
124 ".*\\\^done,BreakpointTable=\\\{.*,body=\\\[\\\]\\\}" \
125 "all breakpoints removed"
128 proc test_dir_specification {} {
134 # Add to the search directories, display, then reset back to default
136 # -environment-directory arg
137 # -environment-directory
138 # -environment-directory -r
140 mi_gdb_test "202-environment-directory ${objdir}/${subdir}" \
141 "202\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
142 "environment-directory arg operation"
144 mi_gdb_test "203-environment-directory" \
145 "203\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
146 "environment-directory empty-string operation"
148 mi_gdb_test "204-environment-directory -r" \
149 "204\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \
150 "environment-directory operation"
153 proc test_cwd_specification {} {
159 # Change the working directory, then print the current working directory
161 # -environment-cd ${objdir}
164 mi_gdb_test "205-environment-cd ${objdir}" \
166 "environment-cd arg operation"
168 # The canonical name of the working directory may differ on a
169 # remote host from that on the build system.
170 if ![is_remote host] {
171 mi_gdb_test "206-environment-pwd" \
172 "206\\\^done,cwd=\"${escapedobjdir}\"" \
173 "environment-pwd operation"
177 proc test_path_specification {} {
186 # Add to the path, display, then reset
189 # -environment-path dir1 dir2
190 # -environment-path -r dir
191 # -environment-path -r
193 mi_gdb_test "-environment-path" "\\\^done,path=\"(.*)\"" "environment-path"
194 set orig_path $expect_out(3,string)
196 set orig_path [string_to_regexp ${orig_path}]
197 set pathdir [string_to_regexp ${objdir}/${subdir}]
199 mi_gdb_test "207-environment-path" \
200 "207\\\^done,path=\"$orig_path\"" \
201 "environment-path no-args operation"
203 mi_gdb_test "208-environment-path $objdir ${objdir}/${subdir}" \
204 "208\\\^done,path=\"$escapedobjdir.${envirodir}.$orig_path\"" \
205 "environment-path dir1 dir2 operation"
207 mi_gdb_test "209-environment-path -r $objdir" \
208 "209\\\^done,path=\"$escapedobjdir.$orig_path\"" \
209 "environment-path -r dir operation"
211 mi_gdb_test "210-environment-path -r" \
212 "210\\\^done,path=\"$orig_path\"" \
213 "environment-path -r operation"
217 proc test_setshow_inferior_tty {} {
219 global mi_inferior_tty_name
221 # Test that the commands,
224 # are setting/getting the same data in GDB.
226 mi_gdb_test "301-inferior-tty-show" \
227 "301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
228 "initial tty is mi_inferior_tty_name"
230 mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
232 "set tty to /dev/pts/1"
234 mi_gdb_test "303-inferior-tty-show" \
235 "303\\\^done,inferior_tty_terminal=\"/dev/pts/1\"" \
236 "tty was set correctly"
238 mi_gdb_test "304-inferior-tty-set" \
240 "set tty to the empty string"
242 mi_gdb_test "305-inferior-tty-show" \
244 "make sure tty is empty"
246 mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
248 "set tty to mi_inferior_tty_name (the way it was)"
250 mi_gdb_test "307-inferior-tty-show" \
251 "307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
252 "verify tty is correct"
255 if { [test_mi_interpreter_selection]
256 && [test_exec_and_symbol_mi_operatons] } {
257 test_breakpoints_deletion
258 test_dir_specification
259 test_cwd_specification
260 test_path_specification
261 test_setshow_inferior_tty