[gdb/testsuite] Run read1 timeout tests with with_read1_timeout_factor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / info-macros.exp
CommitLineData
42a4f53d 1# Copyright 2011-2019 Free Software Foundation, Inc.
9b158ba0 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 3 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, see <http://www.gnu.org/licenses/>.
15
f8b41b00 16standard_testfile .c
682c7f7b 17
a587b477
DE
18# Fission doesn't support macros yet. Bug 15954.
19if [using_fission] {
5b362f04 20 untested "fission does not support macros yet"
a587b477
DE
21 return -1
22}
23
4c93b1db 24get_compiler_info
682c7f7b 25if ![test_compiler_info gcc*] {
5b362f04 26 untested "no compiler info"
9b158ba0 27 return -1
28}
29
78466714
AA
30# Don't use "debug" here. Otherwise "-g" would be appended to the gcc
31# command line, possibly overriding "-g3" (depending on gcc version).
32set options "additional_flags=-g3"
682c7f7b 33
5b362f04 34if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $options] } {
9b158ba0 35 return -1
36}
37
38if ![runto_main] {
5b362f04 39 untested "could not run to main"
9b158ba0 40 return -1
41}
42
71eba9c2 43# Test various error messages.
44gdb_test "info macro -- -all" \
45 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
46 "info macro -- -all"
47gdb_test "info macro -- -all" \
48 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \
49 "info macro -- -all"
50
51gdb_test "info macro -all --" \
52 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
53 "info macro -all --"
54
55gdb_test "info macro -all --" \
56 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
57 "info macro -all --"
58
59gdb_test "info macro -all --" \
60 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
61 "info macro -all --"
62
63gdb_test "info macro --" \
64 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
65 "info macro --"
66
67gdb_test "info macro -- " \
68 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
69 "'info macro -- '"
70gdb_test "info macro -- " \
71 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \
72 "'info macro -- '"
73
74gdb_test "info macro -invalid-option" \
75 "Unrecognized option.*Try \"help info macro\"\." \
76 "info macro -invalid-option 1"
77
78gdb_test "info macro -invalid-option" \
79 "Unrecognized option.*Try \"help info macro\"\." \
80 "info macro -invalid-option"
81
82gdb_test "info macro -invalid-option FOO" \
83 "Unrecognized option.*Try \"help info macro\"\." \
84 "info macro -invalid-option FOO"
85gdb_test "info macro -invalid-option FOO" \
86 "Unrecognized option.*Try \"help info macro\"\." \
87 "info macro -invalid-option FOO"
88
89# Single macro lookups.
90gdb_test "info macro -- FOO" \
91 ".*#define FOO \"hello\"" \
92 "info macro -- FOO"
93
94gdb_test "info macro -- FOO" \
95 ".*#define FOO \"hello\"" \
96 "info macro -- FOO"
97
98gdb_test "info macro -- FOO" \
99 ".*#define FOO \"hello\"" \
100 "info macro -- FOO"
101
102gdb_test "info macro FOO" \
103 ".*#define FOO \"hello\"" \
104 "info macro FOO"
105
106gdb_test "info macro FOO" \
107 ".*#define FOO \"hello\"" \
108 "info macro FOO"
109
110# Multiple macro lookups.
111set test "info macro -a FOO"
9b158ba0 112set r1 ".*#define FOO \"hello\""
113set r2 ".*#define FOO \" \""
114set r3 ".*#define FOO \"world\""
115set r4 ".*#define FOO\\(a\\) foo = a"
116set testname "$test 1"
117gdb_test "$test" "$r1$r2$r3$r4" "$testname"
118
71eba9c2 119set test "info macro -a -- FOO"
120set testname "$test 1"
121gdb_test "$test" "$r1$r2$r3$r4" "$testname"
122
123set test "info macro -all -- FOO"
124set testname "$test 1"
125gdb_test "$test" "$r1$r2$r3$r4" "$testname"
126
127set test "info macro -a -- FOO"
128set testname "$test"
129gdb_test "$test" "$r1$r2$r3$r4" "$testname"
130
131set test "info macro -a -- FOO"
132set testname "$test"
133gdb_test "$test" "$r1$r2$r3$r4" "$testname"
9b158ba0 134
d86bd7cb
TV
135proc gdb_test_multiple_with_read1_timeout_factor { factor command message \
136 user_code } {
137 with_read1_timeout_factor $factor {
138 uplevel [list gdb_test_multiple $command $message $user_code]
139 }
140}
141
9b158ba0 142set test "info macros"
143set r1 ".*#define FOO \"hello\""
144set r2 ".*#define ONE"
145set r3 ".*\r\n$gdb_prompt"
146set testname "$test 2"
d86bd7cb 147gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 148 -re "$r1$r2$r3" {
149 pass $testname
150 }
151 -re ".*#define TWO.*\r\n$gdb_prompt" {
152 fail $testname
153 }
154 -re ".*#define THREE.*\r\n$gdb_prompt" {
155 fail $testname
156 }
157 -re ".*#define FOUR.*\r\n$gdb_prompt" {
158 fail $testname
159 }
160}
161gdb_test "next" ".*" ""
162
163set r1 ".*#define FOO \" \""
164set r2 ".*#define ONE"
165set r3 ".*#define TWO"
166set r4 ".*\r\n$gdb_prompt"
71eba9c2 167set testname "$test 3"
d86bd7cb 168gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 169 -re ".*#define THREE.*\r\n$gdb_prompt" {
170 fail $testname
171 }
172 -re ".*#define FOUR.*\r\n$gdb_prompt" {
173 fail $testname
174 }
175 -re "$r1$r2$r3$r4" {
176 pass $testname
177 }
178}
179gdb_test "next" ".*" ""
180
181# in alpabetical order...
182set r1 ".*#define FOO \"world\""
183set r2 ".*#define ONE"
184set r3 ".*#define THREE"
185set r4 ".*#define TWO"
186set r5 ".*\r\n$gdb_prompt"
187set testname "$test 4"
d86bd7cb 188gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 189 -re ".*#define FOUR.*\r\n$gdb_prompt" {
190 fail $testname
191 }
192 -re "$r1$r2$r3$r4$r5" {
193 pass $testname
194 }
195}
196# same as above with a linespec.
197set test "info macros *\$pc"
d86bd7cb 198gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
9b158ba0 199 -re ".*#define FOUR.*\r\n$gdb_prompt" {
200 fail $test
201 }
202 -re "$r1$r2$r3$r4$r5" {
203 pass $test
204 }
205}
206gdb_test "next" ".*" ""
207
208set r1 ".*#define FOO \" \""
209set r2 ".*#define ONE"
210set r3 ".*#define TWO."
211set r4 ".*\r\n$gdb_prompt"
9b158ba0 212set test "info macros"
71eba9c2 213set testname "$test 5"
d86bd7cb 214gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test {
9b158ba0 215 -re ".*#define THREE.*\r\n$gdb_prompt" {
216 fail $testname
217 }
218 -re ".*#define FOUR.*\r\n$gdb_prompt" {
219 fail $testname
220 }
221 -re "$r1$r2$r3$r4" {
222 pass $testname
223 }
224}
225gdb_test "next" ".*" ""
226gdb_test "next" ".*" ""
227
228set r1 ".*#define DEF_MACROS"
229set r2 ".*\r\n$gdb_prompt"
230set testname "$test 6"
d86bd7cb 231gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 232 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
233 fail $testname
234 }
235 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
236 fail $testname
237 }
238 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
239 fail $testname
240 }
241 -re ".*#define FOO\\(a\\) foo = a.*" {
242 fail $testname
243 }
244 -re ".*#define ONE.*\r\n$gdb_prompt" {
245 fail $testname
246 }
247 -re ".*#define TWO.*\r\n$gdb_prompt" {
248 fail $testname
249 }
250 -re ".*#define THREE.*\r\n$gdb_prompt" {
251 fail $testname
252 }
253 -re ".*#define FOUR.*\r\n$gdb_prompt" {
254 fail $testname
255 }
256 -re "$r1$r2" {
257 pass $testname
258 }
259}
260
261gdb_test "next" ".*" ""
262set r1 ".*#define DEF_MACROS"
263set r2 ".*#define FOO\\(a\\) foo = a"
264set r3 ".*#define FOUR"
265set r4 ".*\r\n$gdb_prompt"
266set testname "$test 7"
d86bd7cb 267gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
9b158ba0 268 -re ".*#define FOO \" \".*\r\n$gdb_prompt" {
269 fail $testname
270 }
271 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" {
272 fail $testname
273 }
274 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" {
275 fail $testname
276 }
277 -re ".*#define ONE.*\r\n$gdb_prompt" {
278 fail $testname
279 }
280 -re ".*#define TWO.*\r\n$gdb_prompt" {
281 fail $testname
282 }
283 -re ".*#define THREE.*\r\n$gdb_prompt" {
284 fail $testname
285 }
286 -re "$r1$r2$r3$r4" {
287 pass $testname
288 }
289}
290
291set test "info macros info-macros.c:42"
292
293set r1 ".*define DEF_MACROS"
294set r2 ".*define ONE"
295# info macros on the line where the #define or #include is
296# fails to find the macro defined (though it works on the next line.)
297setup_kfail "gdb/NNNN" *-*-*
298gdb_test "$test" "$r1$r2" "$test"
This page took 0.96883 seconds and 4 git commands to generate.