mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-21 18:39:34 +08:00
Make environ.exp run on all platforms (and create info-program.exp)
This has been on my TODO list for a while. There's a really old bug about this (PR testsuite/8595), and there was no reason for environ.exp to be specific for hppa* targets. So this patch removes this constraint, modernizes the testcase, and cleans up some things. Most of the tests remained, and some were rewritten (especially the one that checks if "show environment" works, which is something kind of hard to do). As a bonus, I'm adding a separated info-program.exp file containing all the tests related to "info program" that were present on environ.exp. Tested locally, everything still passes. gdb/testsuite/ChangeLog: 2017-04-28 Sergio Durigan Junior <sergiodj@redhat.com> PR testsuite/8595 * gdb.base/environ.exp: Make test available in all architectures. Move bits related to "info program" testing to gdb.base/info-program.exp. Rewrite tests to use the two new procedures mentione below. (test_set_show_env_var) New procedure. (test_set_show_env_var_equal): Likewise. * gdb.base/info-program.exp: New file.
This commit is contained in:
@ -1,3 +1,14 @@
|
|||||||
|
2017-04-28 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
|
PR testsuite/8595
|
||||||
|
* gdb.base/environ.exp: Make test available in all architectures.
|
||||||
|
Move bits related to "info program" testing to
|
||||||
|
gdb.base/info-program.exp. Rewrite tests to use the two new
|
||||||
|
procedures mentione below.
|
||||||
|
(test_set_show_env_var) New procedure.
|
||||||
|
(test_set_show_env_var_equal): Likewise.
|
||||||
|
* gdb.base/info-program.exp: New file.
|
||||||
|
|
||||||
2017-04-27 Keith Seitz <keiths@redhat.com>
|
2017-04-27 Keith Seitz <keiths@redhat.com>
|
||||||
|
|
||||||
* gdb.cp/oranking.cc (test15): New function.
|
* gdb.cp/oranking.cc (test15): New function.
|
||||||
|
@ -13,297 +13,95 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#
|
gdb_start
|
||||||
# test running programs
|
|
||||||
#
|
|
||||||
|
|
||||||
# This test exists solely to exercise the "environment" commands for
|
proc test_set_show_env_var { name value test_name } {
|
||||||
# code-coverage on HP-UX.
|
gdb_test_no_output "set environment $name $value" "$test_name"
|
||||||
#
|
gdb_test "show environment $name" "$name = $value" \
|
||||||
if ![istarget "hppa*-*-hpux*"] then {
|
"confirm $test_name"
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
standard_testfile break.c break1.c
|
proc test_set_show_env_var_equal { name value test_name } {
|
||||||
|
gdb_test_no_output "set environment $name = $value" "$test_name"
|
||||||
if {[prepare_for_testing "failed to prepare" $testfile \
|
gdb_test "show environment $name" "$name = $value" \
|
||||||
[list $srcfile $srcfile2] {debug nowarnings}]} {
|
"confirm $test_name"
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
if ![runto_main] then { fail "environment command tests suppressed" }
|
|
||||||
|
|
||||||
# (No, this is not really related to the environment commands. But it's
|
|
||||||
# a convenient place to verify that this command works.)
|
|
||||||
#
|
|
||||||
send_gdb "info program\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*Using the running image of child process \[0-9\]*.\r\nProgram stopped at 0x\[0-9a-fA-F\]*.\r\nIt stopped at breakpoint 1..*$gdb_prompt $"\
|
|
||||||
{pass "info program"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "info program"}
|
|
||||||
timeout {fail "(timeout) info program"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# We don't really care where this step lands, so long as it gets
|
|
||||||
# the inferior pushed off the breakpoint it's currently on...
|
|
||||||
#
|
|
||||||
send_gdb "next\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*$gdb_prompt $"\
|
|
||||||
{pass "step before info program"}
|
|
||||||
timeout {fail "(timeout) step before info program"}
|
|
||||||
}
|
|
||||||
send_gdb "info program\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*Using the running image of child process \[0-9\]*.\r\nProgram stopped at 0x\[0-9a-fA-F\]*.\r\nIt stopped after being stepped..*$gdb_prompt $"\
|
|
||||||
{pass "info program after step"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "info program after step"}
|
|
||||||
timeout {fail "(timeout) info program after step"}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ![runto_main] then { fail "environment command tests suppressed" }
|
|
||||||
|
|
||||||
send_gdb "delete\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*y or n. $"\
|
|
||||||
{send_gdb "y\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*$gdb_prompt $"\
|
|
||||||
{pass "delete breakpoint before info program"}
|
|
||||||
timeout {fail "(timeout) delete breakpoint before info program"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "delete breakpoint before info program"}
|
|
||||||
timeout {fail "(timeout) delete breakpoint before info program"}
|
|
||||||
}
|
|
||||||
send_gdb "info program\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*Using the running image of child process \[0-9\]*.\r\nProgram stopped at 0x\[0-9a-fA-F\]*.\r\nIt stopped at a breakpoint that has since been deleted..*$gdb_prompt $"\
|
|
||||||
{pass "info program after deleted breakpoint"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "info program after deleted breakpoint"}
|
|
||||||
timeout {fail "(timeout) info program after deleted breakpoint"}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Verify that we can show all currently-set environment variables.
|
# Verify that we can show all currently-set environment variables.
|
||||||
# (It's a bit hacky, but nonetheless probably safe to check for at
|
# It's hard to do this verification since we can't really compare each
|
||||||
# least the SHELL variable.)
|
# entry with the current environment. So we just check to see if
|
||||||
#
|
# there is anything that looks like an environment variable being
|
||||||
# need to increase timeout because of very long output
|
# printed.
|
||||||
set oldtimeout $timeout
|
gdb_test "show environment" "(\[A-Za-z_\]+=.*)+" \
|
||||||
set timeout [expr "$timeout + 300"]
|
"show environment works"
|
||||||
|
|
||||||
send_gdb "show environment\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*SHELL=(\[a-zA-Z0-9\]*).*$gdb_prompt $"\
|
|
||||||
{pass "show environment"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "show environment"}
|
|
||||||
timeout {fail "(timeout) show environment"}
|
|
||||||
}
|
|
||||||
set timeout $oldtimeout
|
|
||||||
|
|
||||||
# Verify that we can unset a specific environment variable.
|
# Verify that we can unset a specific environment variable.
|
||||||
#
|
gdb_test_no_output "unset environment EDITOR" "unset environment variable"
|
||||||
send_gdb "unset environment EDITOR\n"
|
|
||||||
gdb_expect {
|
gdb_test "show environment EDITOR" "Environment variable \"EDITOR\" not defined\." \
|
||||||
-re "$gdb_prompt $"\
|
"confirm unset environment variable worked"
|
||||||
{pass "issue unset environment"}
|
|
||||||
timeout {fail "(timeout) issue unset environment"}
|
|
||||||
}
|
|
||||||
send_gdb "show environment EDITOR\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Environment variable \"EDITOR\" not defined.\r\n$gdb_prompt $"\
|
|
||||||
{pass "unset environment"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "unset environment"}
|
|
||||||
timeout {fail "(timeout) unset environment"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that we can unset all environment variables.
|
# Verify that we can unset all environment variables.
|
||||||
#
|
gdb_test "unset environment" "" "unset all environment variables" \
|
||||||
send_gdb "unset environment\n"
|
"Delete all environment variables. .y or n. $" \
|
||||||
gdb_expect {
|
"y"
|
||||||
-re "Delete all environment variables.*y or n. $"\
|
|
||||||
{send_gdb "y\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{pass "unset entire environment"}
|
|
||||||
timeout {fail "(timeout) unset entire environment"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "unset entire environment"}
|
|
||||||
timeout {fail "(timeout) unset entire environment"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that we can set a specific environment variable.
|
# Verify that we can set a specific environment variable.
|
||||||
#
|
test_set_show_env_var "EDITOR" "emacs" "set environment variable"
|
||||||
send_gdb "set environment EDITOR emacs\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{pass "issue set environment"}
|
|
||||||
timeout {fail "(timeout) issue set environment"}
|
|
||||||
}
|
|
||||||
send_gdb "show environment EDITOR\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "EDITOR = emacs\r\n$gdb_prompt $"\
|
|
||||||
{pass "set environment"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment"}
|
|
||||||
timeout {fail "(timeout) set environment"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that GDB responds gracefully to a request to set environment,
|
# Verify that GDB responds gracefully to a request to set environment,
|
||||||
# with no variable name.
|
# with no variable name.
|
||||||
#
|
gdb_test "set environment" "Argument required \\\(environment variable and value\\\)\." \
|
||||||
send_gdb "set environment\n"
|
"set environment without arguments"
|
||||||
gdb_expect {
|
|
||||||
-re "Argument required .environment variable and value..*$gdb_prompt $"\
|
|
||||||
{pass "set environment without variable disallowed"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment without variable disallowed"}
|
|
||||||
timeout {fail "(timeout) set environment without variable disallowed"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# I'm not sure just what GDB has in mind in explicitly checking
|
# I'm not sure just what GDB has in mind in explicitly checking
|
||||||
# for this variant, but since GDB handles it, test it.
|
# for this variant, but since GDB handles it, test it.
|
||||||
#
|
gdb_test "set environment =" "Argument required \\\(environment variable to set\\\)\." \
|
||||||
send_gdb "set environment =\n"
|
"set environment without variable name"
|
||||||
gdb_expect {
|
|
||||||
-re "Argument required .environment variable to set..*$gdb_prompt $"\
|
|
||||||
{pass "set environment equals without variable disallowed"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment equals without variable disallowed"}
|
|
||||||
timeout {fail "(timeout) set environment equals without variable disallowed"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Setting an environment variable without a value sets it to a NULL
|
# Setting an environment variable without a value sets it to a NULL
|
||||||
# value.
|
# value.
|
||||||
#
|
gdb_test "set environment EDITOR" "Setting environment variable \"EDITOR\" to null value\." \
|
||||||
send_gdb "set environment EDITOR\n"
|
"set environment variable to null value"
|
||||||
gdb_expect {
|
gdb_test "show environment EDITOR" "EDITOR = " "show null environment variable"
|
||||||
-re "Setting environment variable \"EDITOR\" to null value..*$gdb_prompt $"\
|
|
||||||
{pass "issue set environment without variable value"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "issue set environment without variable value"}
|
|
||||||
timeout {fail "(timeout) issue set environment without variable value"}
|
|
||||||
}
|
|
||||||
send_gdb "show environment EDITOR\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "EDITOR = \r\n$gdb_prompt $"\
|
|
||||||
{pass "set environment without variable value"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment without variable value"}
|
|
||||||
timeout {fail "(timeout) set environment without variable value"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that GDB responds gracefully to an attempt to show a
|
# Verify that GDB responds gracefully to an attempt to show a
|
||||||
# non-existent environment variable. (We hope this variable is
|
# non-existent environment variable. (We hope this variable is
|
||||||
# undefined!)
|
# undefined!)
|
||||||
#
|
gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \
|
||||||
send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
|
"Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined\." \
|
||||||
gdb_expect {
|
"show non-existent environment variable"
|
||||||
-re "Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined..*$gdb_prompt $"\
|
|
||||||
{pass "show non-existent environment variable disallowed"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "show non-existent environment variable disallowed"}
|
|
||||||
timeout {fail "(timeout) show non-existent environment variable disallowed"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that GDB can set an environment variable hitherto undefined.
|
# Verify that GDB can set an environment variable hitherto undefined.
|
||||||
#
|
test_set_show_env_var "FOOBARBAZGRUNGESPAZBALL" "t" \
|
||||||
send_gdb "set environment FOOBARBAZGRUNGESPAZBALL t\n"
|
"set environment variable previously undefined"
|
||||||
gdb_expect {
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{pass "issue set environment for previously undefined variable"}
|
|
||||||
timeout {fail "(timeout) issue set environment for previously undefined variable"}
|
|
||||||
}
|
|
||||||
send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "FOOBARBAZGRUNGESPAZBALL = t\r\n$gdb_prompt $"\
|
|
||||||
{pass "set environment for previously undefined variable"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment for previously undefined variable"}
|
|
||||||
timeout {fail "(timeout) set environment for previously undefined variable"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that GDB can also set an environment variable using the "="
|
# Verify that GDB can also set an environment variable using the "="
|
||||||
# syntax.
|
# syntax.
|
||||||
#
|
test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "y" \
|
||||||
send_gdb "set environment FOOBARBAZGRUNGESPAZBALL = t\n"
|
"set environment variable using = syntax"
|
||||||
gdb_expect {
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{pass "issue set environment with equals"}
|
|
||||||
timeout {fail "(timeout) issue set environment with equals"}
|
|
||||||
}
|
|
||||||
send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "FOOBARBAZGRUNGESPAZBALL = t\r\n$gdb_prompt $"\
|
|
||||||
{pass "set environment with equals"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment with equals"}
|
|
||||||
timeout {fail "(timeout) set environment with equals"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that GDB can set an environment variable to a value that has
|
# Verify that GDB can set an environment variable to a value that has
|
||||||
# an embedded (trailing, in this case) equals.
|
# an embedded (trailing, in this case) equals.
|
||||||
#
|
test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "t=" \
|
||||||
send_gdb "set environment FOOBARBAZGRUNGESPAZBALL t=\n"
|
"set environment variable with trailing equals"
|
||||||
gdb_expect {
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{pass "issue set environment with trailing equals"}
|
|
||||||
timeout {fail "(timeout) issue set environment with trailing equals"}
|
|
||||||
}
|
|
||||||
send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "FOOBARBAZGRUNGESPAZBALL = t=\r\n$gdb_prompt $"\
|
|
||||||
{pass "set environment with trailing equals"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment with trailing equals"}
|
|
||||||
timeout {fail "(timeout) set environment with trailing equals"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that GDB can set an environment variable to a value preceded
|
# Verify that GDB can set an environment variable to a value preceded
|
||||||
# by whitespace, and that such whitespace is ignored (not included
|
# by whitespace, and that such whitespace is ignored (not included
|
||||||
# in the set value).
|
# in the set value).
|
||||||
#
|
gdb_test_no_output "set environment FOOBARBAZGRUNGESPAZBALL = foo" \
|
||||||
send_gdb "set environment FOOBARBAZGRUNGESPAZBALL = foo\n"
|
"set environment variable with trailing whitespace"
|
||||||
gdb_expect {
|
gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \
|
||||||
-re "$gdb_prompt $"\
|
"FOOBARBAZGRUNGESPAZBALL = foo" \
|
||||||
{pass "issue set environment with preceding whitespace"}
|
"confirm set environment variable with trailing whitespace"
|
||||||
timeout {fail "(timeout) issue set environment with preceding whitespace"}
|
|
||||||
}
|
|
||||||
send_gdb "show environment FOOBARBAZGRUNGESPAZBALL\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "FOOBARBAZGRUNGESPAZBALL = foo\r\n$gdb_prompt $"\
|
|
||||||
{pass "set environment with preceding whitespace"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "set environment with preceding whitespace"}
|
|
||||||
timeout {fail "(timeout) set environment with preceding whitespace"}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify that GDB can manipulate the distinguished PATH variable.
|
# Verify that GDB can manipulate the distinguished PATH variable.
|
||||||
#
|
gdb_test "path /tmp/FOOBARBAZGRUNGESPAZBALL" \
|
||||||
send_gdb "path /tmp/FOOBARBAZGRUNGESPAZBALL\n"
|
"Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*" \
|
||||||
gdb_expect {
|
"set path works properly"
|
||||||
-re ".*Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
|
gdb_test "show paths" \
|
||||||
{pass "issue path"}
|
"Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*" \
|
||||||
-re "$gdb_prompt $"\
|
"show paths works properly"
|
||||||
{fail "issue path"}
|
|
||||||
timeout {fail "(timeout) issue path"}
|
|
||||||
}
|
|
||||||
send_gdb "show paths\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
|
|
||||||
{pass "show paths"}
|
|
||||||
-re "$gdb_prompt $"\
|
|
||||||
{fail "show paths"}
|
|
||||||
timeout {fail "(timeout) show paths"}
|
|
||||||
}
|
|
||||||
|
|
||||||
gdb_exit
|
gdb_exit
|
||||||
return 0
|
return 0
|
||||||
|
45
gdb/testsuite/gdb.base/info-program.exp
Normal file
45
gdb/testsuite/gdb.base/info-program.exp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright 1997-2017 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/>.
|
||||||
|
|
||||||
|
standard_testfile normal.c
|
||||||
|
|
||||||
|
if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
if { ![runto_main] } {
|
||||||
|
fail "can't run to main"
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
gdb_test "info program" "Program stopped at $hex\.\r\nIt stopped at breakpoint $decimal\.\r\nType \"info stack\" or \"info registers\" for more information\." \
|
||||||
|
"info program after run to main"
|
||||||
|
|
||||||
|
# We don't really care where this step lands, so long as it gets
|
||||||
|
# the inferior pushed off the breakpoint it's currently on...
|
||||||
|
gdb_test "next" "$decimal\t.*" "step before info program"
|
||||||
|
|
||||||
|
gdb_test "info program" "Program stopped at $hex\.\r\nIt stopped after being stepped\.\r\nType \"info stack\" or \"info registers\" for more information\." \
|
||||||
|
"info program after next"
|
||||||
|
|
||||||
|
if { ![runto_main] } then {
|
||||||
|
fail "can't restart program"
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_breakpoints
|
||||||
|
|
||||||
|
gdb_test "info program" "Program stopped at $hex\.\r\nIt stopped at a breakpoint that has since been deleted\.\r\nType \"info stack\" or \"info registers\" for more information\." \
|
||||||
|
"info program after deleting all breakpoints"
|
Reference in New Issue
Block a user