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 }
25 [string_to_regexp {The directory of the index cache is "}]
27 [string_to_regexp {".}]
29 # Show the initial value of the index-cache directory.
31 gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post
33 foreach_with_prefix env_var_name $all_env_vars {
34 # Restore the original state of the environment variable.
35 save_vars env($env_var_name) {
36 set env($env_var_name) {}
39 gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post
43 # Try the same, but with all the env vars set to an empty value at the same
45 with_test_prefix "all env vars" {
47 foreach env_var_name $all_env_vars {
48 lappend save_vars_arg env($env_var_name)
51 # Restore the original state of all the environment variables.
52 save_vars $save_vars_arg {
53 foreach env_var_name $all_env_vars {
54 set env($env_var_name) {}
59 gdb_test "show index-cache directory" $re_pre$re_post