1 # Copyright 1997, 1998, 1999 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 2 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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 # Please email any bugs, comments, and/or additions to this file to:
28 # test running programs
33 # This test exists solely to exercise the "environment" commands for
34 # code-coverage on HP-UX.
36 if ![istarget "hppa*-*-hpux*"] then {
41 set srcfile ${testfile}.c
42 set binfile ${objdir}/${subdir}/${testfile}
45 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
46 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
51 gdb_reinitialize_dir $srcdir/$subdir
54 if ![runto_main] then { fail "environment command tests suppressed" }
56 # (No, this is not really related to the environment commands. But it's
57 # a convenient place to verify that this command works.)
59 send_gdb "info program\n"
61 -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 $"\
65 timeout {fail "(timeout) info program"}
68 # We don't really care where this step lands, so long as it gets
69 # the inferior pushed off the breakpoint it's currently on...
73 -re ".*$gdb_prompt $"\
74 {pass "step before info program"}
75 timeout {fail "(timeout) step before info program"}
77 send_gdb "info program\n"
79 -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 $"\
80 {pass "info program after step"}
82 {fail "info program after step"}
83 timeout {fail "(timeout) info program after step"}
86 if ![runto_main] then { fail "environment command tests suppressed" }
93 -re ".*$gdb_prompt $"\
94 {pass "delete breakpoint before info program"}
95 timeout {fail "(timeout) delete breakpoint before info program"}
99 {fail "delete breakpoint before info program"}
100 timeout {fail "(timeout) delete breakpoint before info program"}
102 send_gdb "info program\n"
104 -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 $"\
105 {pass "info program after deleted breakpoint"}
107 {fail "info program after deleted breakpoint"}
108 timeout {fail "(timeout) info program after deleted breakpoint"}
111 # Verify that we can show all currently-set environment variables.
112 # (It's a bit hacky, but nonetheless probably safe to check for at
113 # least the SHELL variable.)
115 # need to increase timeout because of very long output
116 set oldtimeout $timeout
117 set timeout [expr "$timeout + 300"]
119 send_gdb "show environment\n"
121 -re ".*SHELL=(\[a-zA-Z0-9\]*).*$gdb_prompt $"\
122 {pass "show environment"}
124 {fail "show environment"}
125 timeout {fail "(timeout) show environment"}
127 set timeout $oldtimeout
129 # Verify that we can unset a specific environment variable.
131 send_gdb "unset environment EDITOR\n"
134 {pass "issue unset environment"}
135 timeout {fail "(timeout) issue unset environment"}
137 send_gdb "show environment EDITOR\n"
139 -re "Environment variable \"EDITOR\" not defined.\r\n$gdb_prompt $"\
140 {pass "unset environment"}
142 {fail "unset environment"}
143 timeout {fail "(timeout) unset environment"}
146 # Verify that we can unset all environment variables.
148 send_gdb "unset environment\n"
150 -re "Delete all environment variables.*y or n. $"\
154 {pass "unset entire environment"}
155 timeout {fail "(timeout) unset entire environment"}
159 {fail "unset entire environment"}
160 timeout {fail "(timeout) unset entire environment"}
163 # Verify that we can set a specific environment variable.
165 send_gdb "set environment EDITOR emacs\n"
168 {pass "issue set environment"}
169 timeout {fail "(timeout) issue set environment"}
171 send_gdb "show environment EDITOR\n"
173 -re "EDITOR = emacs\r\n$gdb_prompt $"\
174 {pass "set environment"}
176 {fail "set environment"}
177 timeout {fail "(timeout) set environment"}
180 # Verify that GDB responds gracefully to a request to set environment,
181 # with no variable name.
183 send_gdb "set environment\n"
185 -re "Argument required .environment variable and value..*$gdb_prompt $"\
186 {pass "set environment without variable disallowed"}
188 {fail "set environment without variable disallowed"}
189 timeout {fail "(timeout) set environment without variable disallowed"}
192 # I'm not sure just what GDB has in mind in explicitly checking
193 # for this variant, but since GDB handles it, test it.
195 send_gdb "set environment =\n"
197 -re "Argument required .environment variable to set..*$gdb_prompt $"\
198 {pass "set environment equals without variable disallowed"}
200 {fail "set environment equals without variable disallowed"}
201 timeout {fail "(timeout) set environment equals without variable disallowed"}
204 # Setting an environment variable without a value sets it to a NULL
207 send_gdb "set environment EDITOR\n"
209 -re "Setting environment variable \"EDITOR\" to null value..*$gdb_prompt $"\
210 {pass "issue set environment without variable value"}
212 {fail "issue set environment without variable value"}
213 timeout {fail "(timeout) issue set environment without variable value"}
215 send_gdb "show environment EDITOR\n"
217 -re "EDITOR = \r\n$gdb_prompt $"\
218 {pass "set environment without variable value"}
220 {fail "set environment without variable value"}
221 timeout {fail "(timeout) set environment without variable value"}
224 # Verify that GDB responds gracefully to an attempt to show a
225 # non-existent environment variable. (We hope this variable is
228 send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
230 -re "Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined..*$gdb_prompt $"\
231 {pass "show non-existent environment variable disallowed"}
233 {fail "show non-existent environment variable disallowed"}
234 timeout {fail "(timeout) show non-existent environment variable disallowed"}
237 # Verify that GDB can set an environment variable hitherto undefined.
239 send_gdb "set environment FOOBARBAZGRUNGESPAZBALL t\n"
242 {pass "issue set environment for previously undefined variable"}
243 timeout {fail "(timeout) issue set environment for previously undefined variable"}
245 send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
247 -re "FOOBARBAZGRUNGESPAZBALL = t\r\n$gdb_prompt $"\
248 {pass "set environment for previously undefined variable"}
250 {fail "set environment for previously undefined variable"}
251 timeout {fail "(timeout) set environment for previously undefined variable"}
254 # Verify that GDB can also set an environment variable using the "="
257 send_gdb "set environment FOOBARBAZGRUNGESPAZBALL = t\n"
260 {pass "issue set environment with equals"}
261 timeout {fail "(timeout) issue set environment with equals"}
263 send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
265 -re "FOOBARBAZGRUNGESPAZBALL = t\r\n$gdb_prompt $"\
266 {pass "set environment with equals"}
268 {fail "set environment with equals"}
269 timeout {fail "(timeout) set environment with equals"}
272 # Verify that GDB can set an environment variable to a value that has
273 # an embedded (trailing, in this case) equals.
275 send_gdb "set environment FOOBARBAZGRUNGESPAZBALL t=\n"
278 {pass "issue set environment with trailing equals"}
279 timeout {fail "(timeout) issue set environment with trailing equals"}
281 send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
283 -re "FOOBARBAZGRUNGESPAZBALL = t=\r\n$gdb_prompt $"\
284 {pass "set environment with trailing equals"}
286 {fail "set environment with trailing equals"}
287 timeout {fail "(timeout) set environment with trailing equals"}
290 # Verify that GDB can set an environment variable to a value preceded
291 # by whitespace, and that such whitespace is ignored (not included
294 send_gdb "set environment FOOBARBAZGRUNGESPAZBALL = foo\n"
297 {pass "issue set environment with preceding whitespace"}
298 timeout {fail "(timeout) issue set environment with preceding whitespace"}
300 send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
302 -re "FOOBARBAZGRUNGESPAZBALL = foo\r\n$gdb_prompt $"\
303 {pass "set environment with preceding whitespace"}
305 {fail "set environment with preceding whitespace"}
306 timeout {fail "(timeout) set environment with preceding whitespace"}
309 # Verify that GDB can manipulate the distinguished PATH variable.
311 send_gdb "path /tmp/FOOBARBAZGRUNGESPAZBALL\n"
313 -re ".*Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
317 timeout {fail "(timeout) issue path"}
319 send_gdb "show paths\n"
321 -re "Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
325 timeout {fail "(timeout) show paths"}