File: empty-host-env-vars.exp

package info (click to toggle)
gdb-doc 16.3-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 244,264 kB
  • sloc: ansic: 2,134,731; asm: 375,582; exp: 206,875; cpp: 73,639; makefile: 70,232; sh: 26,038; python: 13,697; yacc: 11,341; ada: 7,358; xml: 6,098; perl: 5,077; pascal: 3,389; tcl: 2,986; f90: 2,764; lisp: 1,984; cs: 879; lex: 738; sed: 228; awk: 181; objc: 137; fortran: 57
file content (61 lines) | stat: -rw-r--r-- 1,948 bytes parent folder | download | duplicates (6)
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
# Copyright 2021-2024 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/>.

# This test assumes host == build.
require {!is_remote host}

# GDB reads some environment variables on startup, make sure it behaves
# correctly if these variables are defined but empty.

set all_env_vars { HOME XDG_CACHE_HOME LOCALAPPDATA XDG_CONFIG_HOME }

set re_pre \
    [string_to_regexp {The directory of the index cache is "}]
set re_post \
    [string_to_regexp {".}]

# Show the initial value of the index-cache directory.
clean_restart
gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post

foreach_with_prefix env_var_name $all_env_vars {
    # Restore the original state of the environment variable.
    save_vars env($env_var_name) {
	set env($env_var_name) {}
	clean_restart

	gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post
    }
}

# Try the same, but with all the env vars set to an empty value at the same
# time.
with_test_prefix "all env vars" {
    set save_vars_arg {}
    foreach env_var_name $all_env_vars {
	lappend save_vars_arg env($env_var_name)
    }

    # Restore the original state of all the environment variables.
    save_vars $save_vars_arg {
	foreach env_var_name $all_env_vars {
	    set env($env_var_name) {}
	}

	clean_restart

	gdb_test "show index-cache directory" $re_pre$re_post
    }
}