mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
baecbb3dc8
I wanted to remove the duplicate test name from gdb.cp/maint.exp. In this test we run some checks against different operator names. For one operator we test with a variable number of spaces. However, we were accidentally testing the one space version twice, and the zero space version not at all, leading to a duplicate test name. I could have just changed the duplicate one space version into the missing zero space version, but I thought it would be neater to wrap multiple tests in a loop, and check all operators with either zero, one, or two spaces. These tests are super quick so take almost no extra time, and this gives marginally more test coverage. gdb/testsuite/ChangeLog: * gdb.cp/maint.exp (test_first_component): Run more tests with a variable number of spaces, this removes the duplicate testing of 'operator ->' which existed before.
122 lines
4.1 KiB
Plaintext
122 lines
4.1 KiB
Plaintext
# Copyright 2003-2021 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 file tests C++-specific maintenance commands and help on those.
|
|
|
|
# Currently, no source file is used.
|
|
|
|
# Test the help messages.
|
|
|
|
proc test_help {} {
|
|
set first_component_help "Print the first class/namespace component of NAME"
|
|
set namespace_help "Deprecated placeholder for removed functionality."
|
|
|
|
test_prefix_command_help {"maintenance cplus"} {
|
|
"C\\+\\+ maintenance commands\.\[\r\n\]+"
|
|
}
|
|
|
|
test_prefix_command_help {"maint cp" "maintenance cplus"} {
|
|
"C\\+\\+ maintenance commands.\r\n\r\n"
|
|
}
|
|
|
|
set multiple_help_body "List of maintenance cplus subcommands:.*Command name abbreviations are allowed if unambiguous."
|
|
|
|
gdb_test "maint cp" $multiple_help_body
|
|
|
|
gdb_test "help maint cp first_component" "${first_component_help}."
|
|
gdb_test "help maint cp namespace" "${namespace_help}."
|
|
}
|
|
|
|
# This is used when NAME should contain only a single component. Be
|
|
# careful to make sure that parentheses get escaped properly.
|
|
proc test_single_component {name} {
|
|
set matchname [string_to_regexp "$name"]
|
|
gdb_test "maint cp first_component $name" "$matchname"
|
|
}
|
|
|
|
# This is used when NAME is invalid.
|
|
proc test_invalid_name {name} {
|
|
set matchname [string_to_regexp "$name"]
|
|
gdb_test "maint cp first_component $name" \
|
|
"During symbol reading: unexpected demangled name '$matchname'\r\n$matchname"
|
|
}
|
|
|
|
proc test_first_component {} {
|
|
# The function in question might complain; make sure that we see
|
|
# all complaints.
|
|
|
|
gdb_test_no_output "set complaints 1000"
|
|
|
|
test_single_component "foo"
|
|
|
|
foreach spc [list "" " " " "] {
|
|
test_single_component "operator${spc}<<"
|
|
test_single_component "operator${spc}>>"
|
|
test_single_component "operator${spc}->"
|
|
test_single_component "operator${spc}()"
|
|
test_single_component "operator${spc}>"
|
|
test_single_component "operator${spc}<"
|
|
|
|
test_single_component "foo${spc}()"
|
|
test_single_component "foo${spc}(int)"
|
|
test_single_component "foo${spc}(X::Y)"
|
|
test_single_component "foo${spc}(X::Y, A::B)"
|
|
test_single_component "foo${spc}(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)"
|
|
test_single_component "operator>${spc}(X::Y)"
|
|
}
|
|
|
|
# Operator names can show up in weird places.
|
|
|
|
test_single_component "int operator<< <char>()"
|
|
test_single_component "T<Cooperator>"
|
|
|
|
# NOTE: carlton/2003-04-23: I've only seen the first of these
|
|
# produced by the demangler, but I'm including two more just to be
|
|
# on the safe side.
|
|
test_single_component "int foo<&(operator<<(C, C))>()"
|
|
test_single_component "int foo<&operator<<(C, C)>()"
|
|
test_single_component "int foo<operator<<(C, C)>()"
|
|
|
|
gdb_test "maint cp first_component foo::bar" "foo"
|
|
gdb_test "maint cp first_component foo::bar::baz" "foo"
|
|
gdb_test "maint cp first_component C<A>::bar" "C<A>"
|
|
gdb_test "maint cp first_component C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >::bar" "C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >"
|
|
|
|
# Make sure we behave appropriately on invalid input.
|
|
|
|
# NOTE: carlton/2003-06-25: As of today, the demangler can in fact
|
|
# produce examples like the third case below: there really should
|
|
# be a space between the two <'s. See PR gdb/1245.
|
|
|
|
test_invalid_name "foo<"
|
|
test_invalid_name "foo("
|
|
test_invalid_name "bool operator<<char>"
|
|
}
|
|
|
|
proc test_namespace {} {
|
|
gdb_test "maint cp namespace" "The `maint namespace' command was removed."
|
|
}
|
|
|
|
gdb_exit
|
|
gdb_start
|
|
|
|
test_help
|
|
test_first_component
|
|
test_namespace
|
|
|
|
gdb_exit
|
|
return 0
|