]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/environ.exp
Fix more cases of improper test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / environ.exp
CommitLineData
618f726f 1# Copyright 1997-2016 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 15
c906108c
SS
16#
17# test running programs
18#
c906108c
SS
19
20# This test exists solely to exercise the "environment" commands for
21# code-coverage on HP-UX.
22#
23if ![istarget "hppa*-*-hpux*"] then {
24 return
25}
26
289f9037 27standard_testfile break.c break1.c
c906108c 28
5b362f04 29if {[prepare_for_testing "failed to prepare" $testfile \
289f9037 30 [list $srcfile $srcfile2] {debug nowarnings}]} {
b60f0898 31 return -1
eb4bbda8
MC
32}
33
c906108c
SS
34if ![runto_main] then { fail "environment command tests suppressed" }
35
36# (No, this is not really related to the environment commands. But it's
37# a convenient place to verify that this command works.)
38#
39send_gdb "info program\n"
40gdb_expect {
41 -re ".*Using the running image of child process \[0-9\]*.\r\nProgram stopped at 0x\[0-9a-fA-F\]*.\r\nIt stopped at breakpoint 1..*$gdb_prompt $"\
42 {pass "info program"}
43 -re "$gdb_prompt $"\
44 {fail "info program"}
45 timeout {fail "(timeout) info program"}
46}
47
48# We don't really care where this step lands, so long as it gets
49# the inferior pushed off the breakpoint it's currently on...
50#
51send_gdb "next\n"
52gdb_expect {
53 -re ".*$gdb_prompt $"\
54 {pass "step before info program"}
55 timeout {fail "(timeout) step before info program"}
56}
57send_gdb "info program\n"
58gdb_expect {
59 -re ".*Using the running image of child process \[0-9\]*.\r\nProgram stopped at 0x\[0-9a-fA-F\]*.\r\nIt stopped after being stepped..*$gdb_prompt $"\
60 {pass "info program after step"}
61 -re "$gdb_prompt $"\
62 {fail "info program after step"}
63 timeout {fail "(timeout) info program after step"}
64}
65
66if ![runto_main] then { fail "environment command tests suppressed" }
67
68send_gdb "delete\n"
69gdb_expect {
70 -re ".*y or n. $"\
71 {send_gdb "y\n"
72 gdb_expect {
73 -re ".*$gdb_prompt $"\
74 {pass "delete breakpoint before info program"}
75 timeout {fail "(timeout) delete breakpoint before info program"}
76 }
77 }
78 -re "$gdb_prompt $"\
79 {fail "delete breakpoint before info program"}
80 timeout {fail "(timeout) delete breakpoint before info program"}
81}
82send_gdb "info program\n"
83gdb_expect {
84 -re ".*Using the running image of child process \[0-9\]*.\r\nProgram stopped at 0x\[0-9a-fA-F\]*.\r\nIt stopped at a breakpoint that has since been deleted..*$gdb_prompt $"\
85 {pass "info program after deleted breakpoint"}
86 -re "$gdb_prompt $"\
87 {fail "info program after deleted breakpoint"}
88 timeout {fail "(timeout) info program after deleted breakpoint"}
89}
90
91# Verify that we can show all currently-set environment variables.
92# (It's a bit hacky, but nonetheless probably safe to check for at
93# least the SHELL variable.)
94#
95# need to increase timeout because of very long output
96set oldtimeout $timeout
97set timeout [expr "$timeout + 300"]
98
99send_gdb "show environment\n"
100gdb_expect {
101 -re ".*SHELL=(\[a-zA-Z0-9\]*).*$gdb_prompt $"\
102 {pass "show environment"}
103 -re "$gdb_prompt $"\
104 {fail "show environment"}
105 timeout {fail "(timeout) show environment"}
106}
107set timeout $oldtimeout
108
109# Verify that we can unset a specific environment variable.
110#
111send_gdb "unset environment EDITOR\n"
112gdb_expect {
113 -re "$gdb_prompt $"\
114 {pass "issue unset environment"}
115 timeout {fail "(timeout) issue unset environment"}
116}
117send_gdb "show environment EDITOR\n"
118gdb_expect {
119 -re "Environment variable \"EDITOR\" not defined.\r\n$gdb_prompt $"\
120 {pass "unset environment"}
121 -re "$gdb_prompt $"\
122 {fail "unset environment"}
123 timeout {fail "(timeout) unset environment"}
124}
125
126# Verify that we can unset all environment variables.
127#
128send_gdb "unset environment\n"
129gdb_expect {
130 -re "Delete all environment variables.*y or n. $"\
131 {send_gdb "y\n"
132 gdb_expect {
133 -re "$gdb_prompt $"\
134 {pass "unset entire environment"}
135 timeout {fail "(timeout) unset entire environment"}
136 }
137 }
138 -re "$gdb_prompt $"\
139 {fail "unset entire environment"}
140 timeout {fail "(timeout) unset entire environment"}
141}
142
143# Verify that we can set a specific environment variable.
144#
145send_gdb "set environment EDITOR emacs\n"
146gdb_expect {
147 -re "$gdb_prompt $"\
148 {pass "issue set environment"}
149 timeout {fail "(timeout) issue set environment"}
150}
151send_gdb "show environment EDITOR\n"
152gdb_expect {
153 -re "EDITOR = emacs\r\n$gdb_prompt $"\
154 {pass "set environment"}
155 -re "$gdb_prompt $"\
156 {fail "set environment"}
157 timeout {fail "(timeout) set environment"}
158}
159
160# Verify that GDB responds gracefully to a request to set environment,
161# with no variable name.
162#
163send_gdb "set environment\n"
164gdb_expect {
165 -re "Argument required .environment variable and value..*$gdb_prompt $"\
166 {pass "set environment without variable disallowed"}
167 -re "$gdb_prompt $"\
168 {fail "set environment without variable disallowed"}
169 timeout {fail "(timeout) set environment without variable disallowed"}
170}
171
172# I'm not sure just what GDB has in mind in explicitly checking
173# for this variant, but since GDB handles it, test it.
174#
175send_gdb "set environment =\n"
176gdb_expect {
177 -re "Argument required .environment variable to set..*$gdb_prompt $"\
178 {pass "set environment equals without variable disallowed"}
179 -re "$gdb_prompt $"\
180 {fail "set environment equals without variable disallowed"}
181 timeout {fail "(timeout) set environment equals without variable disallowed"}
182}
183
184# Setting an environment variable without a value sets it to a NULL
185# value.
186#
187send_gdb "set environment EDITOR\n"
188gdb_expect {
189 -re "Setting environment variable \"EDITOR\" to null value..*$gdb_prompt $"\
190 {pass "issue set environment without variable value"}
191 -re "$gdb_prompt $"\
192 {fail "issue set environment without variable value"}
193 timeout {fail "(timeout) issue set environment without variable value"}
194}
195send_gdb "show environment EDITOR\n"
196gdb_expect {
197 -re "EDITOR = \r\n$gdb_prompt $"\
198 {pass "set environment without variable value"}
199 -re "$gdb_prompt $"\
200 {fail "set environment without variable value"}
201 timeout {fail "(timeout) set environment without variable value"}
202}
203
204# Verify that GDB responds gracefully to an attempt to show a
205# non-existent environment variable. (We hope this variable is
206# undefined!)
207#
208send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
209gdb_expect {
210 -re "Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined..*$gdb_prompt $"\
211 {pass "show non-existent environment variable disallowed"}
212 -re "$gdb_prompt $"\
213 {fail "show non-existent environment variable disallowed"}
214 timeout {fail "(timeout) show non-existent environment variable disallowed"}
215}
216
217# Verify that GDB can set an environment variable hitherto undefined.
218#
219send_gdb "set environment FOOBARBAZGRUNGESPAZBALL t\n"
220gdb_expect {
221 -re "$gdb_prompt $"\
222 {pass "issue set environment for previously undefined variable"}
223 timeout {fail "(timeout) issue set environment for previously undefined variable"}
224}
225send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
226gdb_expect {
227 -re "FOOBARBAZGRUNGESPAZBALL = t\r\n$gdb_prompt $"\
228 {pass "set environment for previously undefined variable"}
229 -re "$gdb_prompt $"\
230 {fail "set environment for previously undefined variable"}
231 timeout {fail "(timeout) set environment for previously undefined variable"}
232}
233
234# Verify that GDB can also set an environment variable using the "="
235# syntax.
236#
237send_gdb "set environment FOOBARBAZGRUNGESPAZBALL = t\n"
238gdb_expect {
239 -re "$gdb_prompt $"\
240 {pass "issue set environment with equals"}
241 timeout {fail "(timeout) issue set environment with equals"}
242}
243send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
244gdb_expect {
245 -re "FOOBARBAZGRUNGESPAZBALL = t\r\n$gdb_prompt $"\
246 {pass "set environment with equals"}
247 -re "$gdb_prompt $"\
248 {fail "set environment with equals"}
249 timeout {fail "(timeout) set environment with equals"}
250}
251
252# Verify that GDB can set an environment variable to a value that has
253# an embedded (trailing, in this case) equals.
254#
255send_gdb "set environment FOOBARBAZGRUNGESPAZBALL t=\n"
256gdb_expect {
257 -re "$gdb_prompt $"\
258 {pass "issue set environment with trailing equals"}
259 timeout {fail "(timeout) issue set environment with trailing equals"}
260}
261send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
262gdb_expect {
263 -re "FOOBARBAZGRUNGESPAZBALL = t=\r\n$gdb_prompt $"\
264 {pass "set environment with trailing equals"}
265 -re "$gdb_prompt $"\
266 {fail "set environment with trailing equals"}
267 timeout {fail "(timeout) set environment with trailing equals"}
268}
269
270# Verify that GDB can set an environment variable to a value preceded
271# by whitespace, and that such whitespace is ignored (not included
272# in the set value).
273#
274send_gdb "set environment FOOBARBAZGRUNGESPAZBALL = foo\n"
275gdb_expect {
276 -re "$gdb_prompt $"\
277 {pass "issue set environment with preceding whitespace"}
278 timeout {fail "(timeout) issue set environment with preceding whitespace"}
279}
280send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
281gdb_expect {
282 -re "FOOBARBAZGRUNGESPAZBALL = foo\r\n$gdb_prompt $"\
283 {pass "set environment with preceding whitespace"}
284 -re "$gdb_prompt $"\
285 {fail "set environment with preceding whitespace"}
286 timeout {fail "(timeout) set environment with preceding whitespace"}
287}
288
289# Verify that GDB can manipulate the distinguished PATH variable.
290#
291send_gdb "path /tmp/FOOBARBAZGRUNGESPAZBALL\n"
292gdb_expect {
293 -re ".*Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
294 {pass "issue path"}
295 -re "$gdb_prompt $"\
296 {fail "issue path"}
297 timeout {fail "(timeout) issue path"}
298}
299send_gdb "show paths\n"
300gdb_expect {
301 -re "Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
302 {pass "show paths"}
303 -re "$gdb_prompt $"\
304 {fail "show paths"}
305 timeout {fail "(timeout) show paths"}
306}
307
308gdb_exit
309return 0