blob: c46eb1c7cbb3d044bf1751456b846e98f1593378 [file] [log] [blame]
# Copyright 1997-2021 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/>. */
gdb_start
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"
}
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"
}
# Verify that we can show all currently-set environment variables.
# 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"
# Verify that we can unset a specific environment variable.
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"
# Verify that we can unset all environment variables.
gdb_test "unset environment" "" "unset all environment variables" \
"Delete all environment variables. .y or n. $" \
"y"
gdb_test_no_output "show environment" \
"all environment variables have been unset"
# Verify that we can set a specific environment variable.
test_set_show_env_var "EDITOR" "emacs" "set environment variable"
# Verify that GDB responds gracefully to a request to set environment,
# with no variable name.
gdb_test "set environment" "Argument required \\\(environment variable and value\\\)\." \
"set environment without arguments"
# I'm not sure just what GDB has in mind in explicitly checking
# for this variant, but since GDB handles it, test it.
gdb_test "set environment =" "Argument required \\\(environment variable to set\\\)\." \
"set environment without variable name"
# Setting an environment variable without a value sets it to a NULL
# value.
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"
# Verify that GDB responds gracefully to an attempt to show a
# non-existent environment variable. (We hope this variable is
# undefined!)
gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \
"Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined\." \
"show non-existent environment variable"
# Verify that GDB can set an environment variable hitherto undefined.
test_set_show_env_var "FOOBARBAZGRUNGESPAZBALL" "t" \
"set environment variable previously undefined"
# Verify that GDB can also set an environment variable using the "="
# syntax.
test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "y" \
"set environment variable using = syntax"
# Verify that GDB can set an environment variable to a value that has
# an embedded (trailing, in this case) equals.
test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "t=" \
"set environment variable 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).
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"
# Verify that GDB can manipulate the distinguished PATH variable.
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"
gdb_exit
return 0