+proc_with_prefix test_set_unset_env {} {
+ global binfile
+
+ clean_restart $binfile
+
+ # First test with no TEST_GDB_VAR.
+ with_test_prefix "test1" {
+ if ![run_and_count_vars] {
+ return
+ }
+ test_num_test_vars 0 "no TEST_GDB vars"
+ }
+
+ # Second test with one TEST_GDB_VAR.
+ with_test_prefix "test2" {
+ gdb_test_no_output "set env TEST_GDB_VAR1 test1" \
+ "set TEST_GDB_VAR1"
+
+ if ![run_and_count_vars] {
+ return
+ }
+ test_num_test_vars 1 "one TEST_GDB var"
+ }
+
+ # Third test with two TEST_GDB_VAR.
+ with_test_prefix "test3" {
+ gdb_test_no_output "set env TEST_GDB_VAR2 test2" \
+ "set TEST_GDB_VAR2"
+
+ if ![run_and_count_vars] {
+ return
+ }
+
+ test_num_test_vars 2 "two TEST_GDB var"
+ }
+
+ # Fourth test with one TEST_GDB_VAR left, after one was removed
+ # with unset command.
+ with_test_prefix "test4" {
+ gdb_test_no_output "unset env TEST_GDB_VAR1" \
+ "unset TEST_GDB_VAR1"
+
+ if ![run_and_count_vars] {
+ return
+ }
+
+ test_num_test_vars 1 "one TEST_GDB var, after unset"
+ }
+}