2018-01-01 05:43:02 +01:00
|
|
|
# Copyright 1997-2018 Free Software Foundation, Inc.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# 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
|
2007-08-23 20:14:19 +02:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-04-16 03:35:26 +02:00
|
|
|
# (at your option) any later version.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
1999-04-16 03:35:26 +02:00
|
|
|
# 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.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
1999-04-16 03:35:26 +02:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 20:14:19 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_start
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2017-03-31 19:24:36 +02:00
|
|
|
proc test_set_show_env_var { name value test_name } {
|
|
|
|
gdb_test_no_output "set environment $name $value" "$test_name"
|
|
|
|
gdb_test "show environment $name" "$name = $value" \
|
|
|
|
"confirm $test_name"
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
2017-03-31 19:24:36 +02:00
|
|
|
proc test_set_show_env_var_equal { name value test_name } {
|
|
|
|
gdb_test_no_output "set environment $name = $value" "$test_name"
|
|
|
|
gdb_test "show environment $name" "$name = $value" \
|
|
|
|
"confirm $test_name"
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Verify that we can show all currently-set environment variables.
|
2017-03-31 19:24:36 +02:00
|
|
|
# It's hard to do this verification since we can't really compare each
|
|
|
|
# entry with the current environment. So we just check to see if
|
|
|
|
# there is anything that looks like an environment variable being
|
|
|
|
# printed.
|
|
|
|
gdb_test "show environment" "(\[A-Za-z_\]+=.*)+" \
|
|
|
|
"show environment works"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that we can unset a specific environment variable.
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test_no_output "unset environment EDITOR" "unset environment variable"
|
|
|
|
|
|
|
|
gdb_test "show environment EDITOR" "Environment variable \"EDITOR\" not defined\." \
|
|
|
|
"confirm unset environment variable worked"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that we can unset all environment variables.
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test "unset environment" "" "unset all environment variables" \
|
|
|
|
"Delete all environment variables. .y or n. $" \
|
|
|
|
"y"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2017-08-15 19:49:18 +02:00
|
|
|
gdb_test_no_output "show environment" \
|
|
|
|
"all environment variables have been unset"
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
# Verify that we can set a specific environment variable.
|
2017-03-31 19:24:36 +02:00
|
|
|
test_set_show_env_var "EDITOR" "emacs" "set environment variable"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that GDB responds gracefully to a request to set environment,
|
|
|
|
# with no variable name.
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test "set environment" "Argument required \\\(environment variable and value\\\)\." \
|
|
|
|
"set environment without arguments"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# I'm not sure just what GDB has in mind in explicitly checking
|
|
|
|
# for this variant, but since GDB handles it, test it.
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test "set environment =" "Argument required \\\(environment variable to set\\\)\." \
|
|
|
|
"set environment without variable name"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Setting an environment variable without a value sets it to a NULL
|
|
|
|
# value.
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test "set environment EDITOR" "Setting environment variable \"EDITOR\" to null value\." \
|
|
|
|
"set environment variable to null value"
|
|
|
|
gdb_test "show environment EDITOR" "EDITOR = " "show null environment variable"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that GDB responds gracefully to an attempt to show a
|
|
|
|
# non-existent environment variable. (We hope this variable is
|
|
|
|
# undefined!)
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \
|
|
|
|
"Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined\." \
|
|
|
|
"show non-existent environment variable"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that GDB can set an environment variable hitherto undefined.
|
2017-03-31 19:24:36 +02:00
|
|
|
test_set_show_env_var "FOOBARBAZGRUNGESPAZBALL" "t" \
|
|
|
|
"set environment variable previously undefined"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that GDB can also set an environment variable using the "="
|
|
|
|
# syntax.
|
2017-03-31 19:24:36 +02:00
|
|
|
test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "y" \
|
|
|
|
"set environment variable using = syntax"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that GDB can set an environment variable to a value that has
|
|
|
|
# an embedded (trailing, in this case) equals.
|
2017-03-31 19:24:36 +02:00
|
|
|
test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "t=" \
|
|
|
|
"set environment variable with trailing equals"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# 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).
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test_no_output "set environment FOOBARBAZGRUNGESPAZBALL = foo" \
|
|
|
|
"set environment variable with trailing whitespace"
|
|
|
|
gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \
|
|
|
|
"FOOBARBAZGRUNGESPAZBALL = foo" \
|
|
|
|
"confirm set environment variable with trailing whitespace"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Verify that GDB can manipulate the distinguished PATH variable.
|
2017-03-31 19:24:36 +02:00
|
|
|
gdb_test "path /tmp/FOOBARBAZGRUNGESPAZBALL" \
|
|
|
|
"Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*" \
|
|
|
|
"set path works properly"
|
|
|
|
gdb_test "show paths" \
|
|
|
|
"Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*" \
|
|
|
|
"show paths works properly"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
return 0
|