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