Commit | Line | Data |
---|---|---|
7b6bb8da JB |
1 | # Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, |
2 | # 2011 Free Software Foundation, Inc. | |
2fcf52f0 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 |
2fcf52f0 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
2fcf52f0 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 | # |
2fcf52f0 | 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/>. |
2fcf52f0 | 16 | |
2fcf52f0 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 | |
30 | set MIFLAGS "-i=mi2" | |
31 | ||
32 | gdb_exit | |
33 | if [mi_gdb_start] { | |
34 | continue | |
35 | } | |
36 | ||
37 | set testfile "basics" | |
38 | set srcfile ${testfile}.c | |
3788363d | 39 | set binfile ${objdir}/${subdir}/mi2-basics |
32fabe09 | 40 | set escapedobjdir [string_to_regexp ${objdir}] |
18ef391a | 41 | set envirodir [string_to_regexp ${objdir}/${subdir}] |
32fabe09 | 42 | |
2fcf52f0 | 43 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { |
b60f0898 JB |
44 | untested mi2-basics.exp |
45 | return -1 | |
2fcf52f0 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 | |
e55595ca MP |
63 | if ![mi_gdb_test "-gdb-version" "~\"GNU gdb.*" "acceptance of MI operations"] { |
64 | return 1 | |
65 | } | |
66 | ||
ec9f1212 | 67 | note "Skipping all other MI tests." |
2fcf52f0 AC |
68 | return 0 |
69 | } | |
70 | ||
71 | proc test_exec_and_symbol_mi_operatons {} { | |
72 | global mi_gdb_prompt | |
73 | global binfile | |
74 | ||
75 | # Load symbols and specify executable on a single operation | |
76 | # Tests: | |
77 | # -file-exec-and-symbols | |
78 | ||
e55595ca MP |
79 | if [mi_gdb_test "-file-exec-and-symbols ${binfile}" "\\\^done" \ |
80 | "file-exec-and-symbols operation"] { | |
81 | note "Skipping all other MI tests." | |
82 | return 0 | |
83 | } | |
2fcf52f0 AC |
84 | |
85 | # The following is not used by mi-support.exp, but we test here so | |
86 | # we get done with loading a program basics. | |
87 | ||
88 | # Do it again, but now load symbols and specify executable with | |
89 | # two separate operations | |
90 | # Tests: | |
91 | # -file-clear | |
92 | # -file-exec-file | |
93 | # -file-symbol-file | |
94 | ||
95 | # FIXME: file-clear is not implemented yet. | |
96 | # mi_gdb_test "-file-clear" \ | |
97 | # "\\\^done" \ | |
98 | # "file-clear operation" | |
99 | ||
100 | mi_gdb_test "-file-exec-file ${binfile}" \ | |
101 | "\\\^done" \ | |
102 | "file-exec-file operation" | |
103 | ||
104 | mi_gdb_test "-file-symbol-file ${binfile}" \ | |
105 | "\\\^done" \ | |
106 | "file-symbol-file operation" | |
107 | ||
e55595ca MP |
108 | # We need to return != 0. |
109 | return 1 | |
2fcf52f0 AC |
110 | } |
111 | ||
112 | proc test_breakpoints_deletion {} { | |
113 | global mi_gdb_prompt | |
114 | global srcfile | |
115 | ||
116 | # Clear all breakpoints and list to confirm | |
117 | # Tests: | |
118 | # -break-delete (all) | |
119 | # -break-list | |
120 | ||
121 | # The all parameter is actually no parameter. | |
122 | mi_gdb_test "200-break-delete" \ | |
39fb8e9e | 123 | "200\\\^done" \ |
2fcf52f0 AC |
124 | "break-delete (all) operation" |
125 | ||
126 | mi_gdb_test "201-break-list" \ | |
127 | ".*\\\^done,BreakpointTable=\\\{.*,body=\\\[\\\]\\\}" \ | |
128 | "all breakpoints removed" | |
129 | } | |
130 | ||
131 | proc test_dir_specification {} { | |
132 | global mi_gdb_prompt | |
18ef391a | 133 | global objdir |
2fcf52f0 | 134 | global subdir |
18ef391a | 135 | global envirodir |
2fcf52f0 AC |
136 | |
137 | # Add to the search directories, display, then reset back to default | |
138 | # Tests: | |
139 | # -environment-directory arg | |
140 | # -environment-directory | |
141 | # -environment-directory -r | |
142 | ||
18ef391a | 143 | mi_gdb_test "202-environment-directory ${objdir}/${subdir}" \ |
540b8a30 | 144 | "202\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ |
2fcf52f0 AC |
145 | "environment-directory arg operation" |
146 | ||
147 | mi_gdb_test "203-environment-directory" \ | |
540b8a30 | 148 | "203\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ |
2fcf52f0 AC |
149 | "environment-directory empty-string operation" |
150 | ||
151 | mi_gdb_test "204-environment-directory -r" \ | |
39fb8e9e | 152 | "204\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \ |
2fcf52f0 AC |
153 | "environment-directory operation" |
154 | ||
155 | #exp_internal 0 | |
156 | } | |
157 | ||
158 | proc test_cwd_specification {} { | |
159 | global mi_gdb_prompt | |
160 | global objdir | |
161 | global subdir | |
32fabe09 | 162 | global escapedobjdir |
2fcf52f0 AC |
163 | |
164 | # Change the working directory, then print the current working directory | |
165 | # Tests: | |
166 | # -environment-cd ${objdir} | |
167 | # -environment-pwd | |
168 | ||
169 | mi_gdb_test "205-environment-cd ${objdir}" \ | |
39fb8e9e | 170 | "205\\\^done" \ |
2fcf52f0 AC |
171 | "environment-cd arg operation" |
172 | ||
07ab73a0 JM |
173 | # The canonical name of the working directory may differ on a |
174 | # remote host from that on the build system. | |
175 | if ![is_remote host] { | |
176 | mi_gdb_test "206-environment-pwd" \ | |
39fb8e9e | 177 | "206\\\^done,cwd=\"${escapedobjdir}\"" \ |
2fcf52f0 | 178 | "environment-pwd operation" |
07ab73a0 | 179 | } |
2fcf52f0 AC |
180 | } |
181 | ||
182 | proc test_path_specification {} { | |
183 | global mi_gdb_prompt | |
184 | global orig_path | |
185 | global objdir | |
18ef391a | 186 | global subdir |
32fabe09 | 187 | global escapedobjdir |
18ef391a | 188 | global envirodir |
e55595ca | 189 | global expect_out |
2fcf52f0 AC |
190 | |
191 | # Add to the path, display, then reset | |
192 | # Tests: | |
193 | # -environment-path | |
194 | # -environment-path dir1 dir2 | |
195 | # -environment-path -r dir | |
196 | # -environment-path -r | |
197 | ||
e55595ca MP |
198 | mi_gdb_test "-environment-path" "\\\^done,path=\"(.*)\"" "-environment-path" |
199 | set orig_path $expect_out(3,string) | |
2fcf52f0 | 200 | |
041bf30d | 201 | set orig_path [string_to_regexp ${orig_path}] |
18ef391a | 202 | set pathdir [string_to_regexp ${objdir}/${subdir}] |
041bf30d | 203 | |
2fcf52f0 | 204 | mi_gdb_test "207-environment-path" \ |
39fb8e9e | 205 | "207\\\^done,path=\"$orig_path\"" \ |
2fcf52f0 AC |
206 | "environment-path no-args operation" |
207 | ||
18ef391a NR |
208 | mi_gdb_test "208-environment-path $objdir ${objdir}/${subdir}" \ |
209 | "208\\\^done,path=\"$escapedobjdir.${envirodir}.$orig_path\"" \ | |
2fcf52f0 AC |
210 | "environment-path dir1 dir2 operation" |
211 | ||
212 | mi_gdb_test "209-environment-path -r $objdir" \ | |
39fb8e9e | 213 | "209\\\^done,path=\"$escapedobjdir.$orig_path\"" \ |
2fcf52f0 AC |
214 | "environment-path -r dir operation" |
215 | ||
216 | mi_gdb_test "210-environment-path -r" \ | |
39fb8e9e | 217 | "210\\\^done,path=\"$orig_path\"" \ |
2fcf52f0 AC |
218 | "environment-path -r operation" |
219 | ||
2fcf52f0 AC |
220 | } |
221 | ||
e55595ca MP |
222 | if { [test_mi_interpreter_selection] |
223 | && [test_exec_and_symbol_mi_operatons] } { | |
2fcf52f0 AC |
224 | test_breakpoints_deletion |
225 | test_dir_specification | |
226 | test_cwd_specification | |
227 | test_path_specification | |
228 | } | |
229 | ||
230 | mi_gdb_exit | |
231 | return 0 |