Commit | Line | Data |
---|---|---|
61baf725 | 1 | # Copyright 1997-2017 Free Software Foundation, Inc. |
c906108c SS |
2 | |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 15 | |
45ce1b47 | 16 | gdb_start |
c906108c | 17 | |
45ce1b47 SDJ |
18 | proc test_set_show_env_var { name value test_name } { |
19 | gdb_test_no_output "set environment $name $value" "$test_name" | |
20 | gdb_test "show environment $name" "$name = $value" \ | |
21 | "confirm $test_name" | |
c906108c | 22 | } |
c906108c | 23 | |
45ce1b47 SDJ |
24 | proc test_set_show_env_var_equal { name value test_name } { |
25 | gdb_test_no_output "set environment $name = $value" "$test_name" | |
26 | gdb_test "show environment $name" "$name = $value" \ | |
27 | "confirm $test_name" | |
c906108c SS |
28 | } |
29 | ||
30 | # Verify that we can show all currently-set environment variables. | |
45ce1b47 SDJ |
31 | # It's hard to do this verification since we can't really compare each |
32 | # entry with the current environment. So we just check to see if | |
33 | # there is anything that looks like an environment variable being | |
34 | # printed. | |
35 | gdb_test "show environment" "(\[A-Za-z_\]+=.*)+" \ | |
36 | "show environment works" | |
c906108c SS |
37 | |
38 | # Verify that we can unset a specific environment variable. | |
45ce1b47 SDJ |
39 | gdb_test_no_output "unset environment EDITOR" "unset environment variable" |
40 | ||
41 | gdb_test "show environment EDITOR" "Environment variable \"EDITOR\" not defined\." \ | |
42 | "confirm unset environment variable worked" | |
c906108c SS |
43 | |
44 | # Verify that we can unset all environment variables. | |
45ce1b47 SDJ |
45 | gdb_test "unset environment" "" "unset all environment variables" \ |
46 | "Delete all environment variables. .y or n. $" \ | |
47 | "y" | |
c906108c SS |
48 | |
49 | # Verify that we can set a specific environment variable. | |
45ce1b47 | 50 | test_set_show_env_var "EDITOR" "emacs" "set environment variable" |
c906108c SS |
51 | |
52 | # Verify that GDB responds gracefully to a request to set environment, | |
53 | # with no variable name. | |
45ce1b47 SDJ |
54 | gdb_test "set environment" "Argument required \\\(environment variable and value\\\)\." \ |
55 | "set environment without arguments" | |
c906108c SS |
56 | |
57 | # I'm not sure just what GDB has in mind in explicitly checking | |
58 | # for this variant, but since GDB handles it, test it. | |
45ce1b47 SDJ |
59 | gdb_test "set environment =" "Argument required \\\(environment variable to set\\\)\." \ |
60 | "set environment without variable name" | |
c906108c SS |
61 | |
62 | # Setting an environment variable without a value sets it to a NULL | |
63 | # value. | |
45ce1b47 SDJ |
64 | gdb_test "set environment EDITOR" "Setting environment variable \"EDITOR\" to null value\." \ |
65 | "set environment variable to null value" | |
66 | gdb_test "show environment EDITOR" "EDITOR = " "show null environment variable" | |
c906108c SS |
67 | |
68 | # Verify that GDB responds gracefully to an attempt to show a | |
69 | # non-existent environment variable. (We hope this variable is | |
70 | # undefined!) | |
45ce1b47 SDJ |
71 | gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \ |
72 | "Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined\." \ | |
73 | "show non-existent environment variable" | |
c906108c SS |
74 | |
75 | # Verify that GDB can set an environment variable hitherto undefined. | |
45ce1b47 SDJ |
76 | test_set_show_env_var "FOOBARBAZGRUNGESPAZBALL" "t" \ |
77 | "set environment variable previously undefined" | |
c906108c SS |
78 | |
79 | # Verify that GDB can also set an environment variable using the "=" | |
80 | # syntax. | |
45ce1b47 SDJ |
81 | test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "y" \ |
82 | "set environment variable using = syntax" | |
c906108c SS |
83 | |
84 | # Verify that GDB can set an environment variable to a value that has | |
85 | # an embedded (trailing, in this case) equals. | |
45ce1b47 SDJ |
86 | test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "t=" \ |
87 | "set environment variable with trailing equals" | |
c906108c SS |
88 | |
89 | # Verify that GDB can set an environment variable to a value preceded | |
90 | # by whitespace, and that such whitespace is ignored (not included | |
91 | # in the set value). | |
45ce1b47 SDJ |
92 | gdb_test_no_output "set environment FOOBARBAZGRUNGESPAZBALL = foo" \ |
93 | "set environment variable with trailing whitespace" | |
94 | gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \ | |
95 | "FOOBARBAZGRUNGESPAZBALL = foo" \ | |
96 | "confirm set environment variable with trailing whitespace" | |
c906108c SS |
97 | |
98 | # Verify that GDB can manipulate the distinguished PATH variable. | |
45ce1b47 SDJ |
99 | gdb_test "path /tmp/FOOBARBAZGRUNGESPAZBALL" \ |
100 | "Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*" \ | |
101 | "set path works properly" | |
102 | gdb_test "show paths" \ | |
103 | "Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*" \ | |
104 | "show paths works properly" | |
c906108c SS |
105 | |
106 | gdb_exit | |
107 | return 0 |