1 # Copyright 2021-2024 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This test assumes host == build.
17 require {!is_remote host}
19 # GDB reads some environment variables on startup, make sure it behaves
20 # correctly if these variables are defined but empty.
22 set all_env_vars { HOME XDG_CACHE_HOME LOCALAPPDATA XDG_CONFIG_HOME }
24 # Record the initial value of the index-cache directory.
26 set index_cache_directory ""
27 gdb_test_multiple "show index-cache directory" "" {
28 -re -wrap "The directory of the index cache is \"(.*)\"\\." {
29 set index_cache_directory $expect_out(1,string)
30 set index_cache_directory [string_to_regexp $index_cache_directory]
35 foreach_with_prefix env_var_name $all_env_vars {
36 # Restore the original state of the environment variable.
37 save_vars env($env_var_name) {
38 set env($env_var_name) {}
41 # Verify that the empty environment variable didn't affect the
42 # index-cache directory setting, that we still see the initial value.
43 # "HOME" is different, because if that one is unset, GDB isn't even
44 # able to compute the default location. In that case, we expect it to
46 if { $env_var_name == "HOME" } {
47 gdb_test "show index-cache directory" \
48 "The directory of the index cache is \"\"\\."
50 gdb_test "show index-cache directory" \
51 "The directory of the index cache is \"$index_cache_directory\"\\."
56 # Try the same, but with all the env vars set to an empty value at the same
58 with_test_prefix "all env vars" {
60 foreach env_var_name $all_env_vars {
61 lappend save_vars_arg env($env_var_name)
64 # Restore the original state of all the environment variables.
65 save_vars $save_vars_arg {
66 foreach env_var_name $all_env_vars {
67 set env($env_var_name) {}
72 gdb_test "show index-cache directory" \
73 "The directory of the index cache is \"\"\\."