2016-01-01 05:33:14 +01:00
|
|
|
# Copyright 2011-2016 Free Software Foundation, Inc.
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
# 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 file was written by Pierre Muller <muller@ics.u-strasbg.fr>
|
|
|
|
#
|
|
|
|
# Check if environment variables are correctly passed to inferiors
|
|
|
|
#
|
|
|
|
|
2011-11-30 09:25:17 +01:00
|
|
|
# There's no support for passing environment variables in the remote protocol.
|
|
|
|
if { [is_remote target] } {
|
|
|
|
return 0
|
|
|
|
}
|
2011-10-05 16:23:37 +02:00
|
|
|
|
test suite update - gdb.base/[t-z]
Convert files gdb.base/[t-z]*.exp to use standard_output_file et al.
* gdb.base/testenv.exp, gdb.base/tui-layout.exp,
gdb.base/twice.exp, gdb.base/type-opaque.exp, gdb.base/unload.exp,
gdb.base/unwindonsignal.exp, gdb.base/valgrind-db-attach.exp,
gdb.base/valgrind-infcall.exp, gdb.base/value-double-free.exp,
gdb.base/varargs.exp, gdb.base/watch-cond-infcall.exp,
gdb.base/watch-cond.exp, gdb.base/watch-non-mem.exp,
gdb.base/watch-read.exp, gdb.base/watch-vfork.exp,
gdb.base/watch_thread_num.exp, gdb.base/watchpoint-cond-gone.exp,
gdb.base/watchpoint-delete.exp, gdb.base/watchpoint-hw.exp,
gdb.base/watchpoint-solib.exp, gdb.base/watchpoint.exp,
gdb.base/watchpoints.exp, gdb.base/wchar.exp, gdb.base/whatis.exp:
Use standard_testfile, standard_output_file, prepare_for_testing,
clean_restart.
2013-06-27 21:00:47 +02:00
|
|
|
standard_testfile .c
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
# Compile binary
|
|
|
|
# and start with a fresh gdb
|
|
|
|
|
2016-12-23 17:52:18 +01:00
|
|
|
if { [prepare_for_testing "failed to prepare" ${binfile} ${srcfile}] } {
|
2011-10-05 16:23:37 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
# make sure $pc is sane, in case we're talking to a board.
|
|
|
|
if { ![runto_main] } {
|
2013-06-07 19:31:09 +02:00
|
|
|
gdb_suppress_tests
|
2011-10-05 16:23:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
set bp_line [gdb_get_line_number "set breakpoint here"]
|
|
|
|
gdb_breakpoint $bp_line
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test gdb set/unset environment commands.
|
|
|
|
# Executable lists and counts all environment variables
|
|
|
|
# starting with TEST_GDB.
|
|
|
|
|
|
|
|
|
|
|
|
# First test with no TEST_GDB_VAR
|
|
|
|
gdb_test "continue" \
|
|
|
|
".*Program found 0 variables starting with TEST_GDB.*" \
|
2016-12-01 21:44:38 +01:00
|
|
|
"test no TEST_GDB var"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
gdb_test_no_output "set env TEST_GDB_VAR1 test1" \
|
2016-12-01 21:45:32 +01:00
|
|
|
"set TEST_GDB_VAR1"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
runto_main
|
|
|
|
gdb_breakpoint $bp_line
|
|
|
|
|
|
|
|
# Second test with one TEST_GDB_VAR
|
|
|
|
gdb_test "continue" \
|
|
|
|
".*Program found 1 variables starting with TEST_GDB.*" \
|
2016-12-01 21:44:38 +01:00
|
|
|
"test with one TEST_GDB var"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
gdb_test_no_output "set env TEST_GDB_VAR2 test2" \
|
2016-12-01 21:45:32 +01:00
|
|
|
"set TEST_GDB_VAR2"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
runto_main
|
|
|
|
gdb_breakpoint $bp_line
|
|
|
|
|
|
|
|
# Third test with two TEST_GDB_VAR
|
|
|
|
gdb_test "continue" \
|
|
|
|
".*Program found 2 variables starting with TEST_GDB.*" \
|
2016-12-01 21:44:38 +01:00
|
|
|
"test with two TEST_GDB var"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
gdb_test_no_output "unset env TEST_GDB_VAR1" \
|
2016-12-01 21:45:32 +01:00
|
|
|
"unset TEST_GDB_VAR1"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
runto_main
|
|
|
|
gdb_breakpoint $bp_line
|
|
|
|
|
|
|
|
# Fourth test with one TEST_GDB_VAR left, after one was removed
|
|
|
|
# with unset command.
|
|
|
|
gdb_test "continue" \
|
|
|
|
".*Program found 1 variables starting with TEST_GDB.*" \
|
2016-12-01 21:44:38 +01:00
|
|
|
"test with one TEST_GDB var, after unset"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
|
|
|
set env(TEST_GDB_GLOBAL) "Global environment value"
|
|
|
|
|
|
|
|
clean_restart $binfile
|
|
|
|
|
|
|
|
# make sure $pc is sane, in case we're talking to a board.
|
|
|
|
if { ![runto_main] } {
|
2013-06-07 19:31:09 +02:00
|
|
|
gdb_suppress_tests
|
2011-10-05 16:23:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
set bp_line [gdb_get_line_number "set breakpoint here"]
|
|
|
|
gdb_breakpoint $bp_line
|
|
|
|
|
2016-12-01 21:41:23 +01:00
|
|
|
gdb_test "show env" ".*TEST_GDB_GLOBAL=.*" "test passing TEST_GDB_GLOBAL to GDB"
|
2011-10-05 16:23:37 +02:00
|
|
|
# First test with only inherited TEST_GDB_GLOBAL
|
|
|
|
gdb_test "continue" \
|
|
|
|
".*TEST_GDB_GLOBAL=Global environment value.*Program found 1 variables starting with TEST_GDB.*" \
|
2016-12-01 21:44:38 +01:00
|
|
|
"test with TEST_GDB_GLOBAL"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
gdb_test_no_output "unset env TEST_GDB_GLOBAL" \
|
2016-12-01 21:45:32 +01:00
|
|
|
"unset TEST_GDB_GLOBAL"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
runto_main
|
|
|
|
gdb_breakpoint $bp_line
|
|
|
|
|
|
|
|
# Second test with one TEST_GDB_VAR
|
|
|
|
gdb_test "continue" \
|
|
|
|
".*Program found 0 variables starting with TEST_GDB.*" \
|
2016-12-01 21:44:38 +01:00
|
|
|
"test with TEST_GDB_GLOBAL unset"
|
2011-10-05 16:23:37 +02:00
|
|
|
|
|
|
|
gdb_exit
|
2011-11-30 09:25:17 +01:00
|
|
|
|
|
|
|
# Clear environment in case we're doing multiple runs
|
|
|
|
unset env(TEST_GDB_GLOBAL)
|
|
|
|
|