Fix more help tests

Vladimir Prus
2006-11-10T16:48:06Z

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

This patch fixes the remaining failures from my "help" changes. OK?

- Volodya

* gdb.base/completion.exp: Fix completion tests for
'info' and 'info '.
* gdb.base/help.ex (help_test_raw, test_class_help)
(test_prefix_command_help): Move...
* lib/gdb.exp: Here.
* gdb.base/main.exp: Adjust.
* gdb.cp/maint.exp: Adjust.
* gdb.trace/tracecmd.exp: Use test_help_class.

[-- Attachment #2: help.diff --]
[-- Type: text/x-diff, Size: 15990 bytes --]

Index: gdb.base/completion.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/completion.exp,v
retrieving revision 1.24
diff -u -r1.24 completion.exp
--- gdb.base/completion.exp 10 Aug 2006 05:27:20 -0000 1.24
+++ gdb.base/completion.exp 10 Nov 2006 16:20:36 -0000
@@ -313,7 +313,7 @@
-re "^info $"\
{ send_gdb "\n"
gdb_expect {
- -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info address.*info watchpoints.*\r\n\r\nType \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
+ -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands.*$gdb_prompt $"\
{ pass "complete 'info'"}
-re ".*$gdb_prompt $" { fail "complete 'info'"}
timeout {fail "(timeout) complete 'info'"}
@@ -329,7 +329,7 @@
-re "^info \\\x07$"\
{ send_gdb "\n"
gdb_expect {
- -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info address.*Type \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
+ -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*$gdb_prompt $"\
{ pass "complete 'info '"}
-re ".*$gdb_prompt $" { fail "complete 'info '"}
timeout {fail "(timeout) complete 'info '"}
Index: gdb.base/help.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/help.exp,v
retrieving revision 1.23
diff -u -r1.23 help.exp
--- gdb.base/help.exp 9 Nov 2006 19:22:11 -0000 1.23
+++ gdb.base/help.exp 10 Nov 2006 16:20:36 -0000
@@ -30,65 +30,6 @@

gdb_start

-# Test the output of GDB_COMMAND matches the pattern obtained
-# by concatenating all elements of EXPECTED_LINES. This makes
-# it possible to split otherwise very long string into pieces.
-# If third argument is not empty, it's used as the name of the
-# test to be printed on pass/fail.
-proc help_test_raw { gdb_command expected_lines args } {
- set message $gdb_command
- if [llength $args]>0 then {
- set message [lindex $args 0]
- }
- set expected_output [join $expected_lines ""]
- gdb_test "${gdb_command}" "${expected_output}" $message
-}
-
-# Test the output of "help COMMNAD_CLASS". EXPECTED_INITIAL_LINES
-# are regular expressions that should match the beginning of output,
-# before the list of commands in that class. The presence of
-# command list and standard epilogue will be tested automatically.
-proc test_class_help { command_class expected_initial_lines } {
- set l_stock_body {
- "List of commands\:.*\[\r\n\]+"
- "Type \"help\" followed by command name for full documentation\.\[\r\n\]+"
- "Type \"apropos word\" to search for commands related to \"word\"\.[\r\n\]+"
- "Command name abbreviations are allowed if unambiguous\."
- }
- set l_entire_body [concat $expected_initial_lines $l_stock_body]
- help_test_raw "help ${command_class}" $l_entire_body
-}
-
-# COMMAND_LIST should have either one element -- command to test, or
-# two elements -- abbreviated command to test, and full command the first
-# element is abbreviation of.
-# The command must be a prefix command. EXPECTED_INITIAL_LINES
-# are regular expressions that should match the beginning of output,
-# before the list of subcommands. The presence of
-# subcommand list and standard epilogue will be tested automatically.
-proc test_prefix_command_help { command_list expected_initial_lines args } {
- set command [lindex $command_list 0]
- if {[llength $command_list]>1} {
- set full_command [lindex $command_list 1]
- } else {
- set full_command $command
- }
- # Use 'list' and not just {} because we want variables to
- # be expanded in this list.
- set l_stock_body [list\
- "List of $full_command subcommands\:.*\[\r\n\]+"\
- "Type \"help $full_command\" followed by $full_command subcommand name for full documentation\.\[\r\n\]+"\
- "Type \"apropos word\" to search for commands related to \"word\"\.\[\r\n\]+"\
- "Command name abbreviations are allowed if unambiguous\."]
- set l_entire_body [concat $expected_initial_lines $l_stock_body]
- if {[llength $args]>0} {
- help_test_raw "help ${command}" $l_entire_body [lindex $args 0]
- } else {
- help_test_raw "help ${command}" $l_entire_body
- }
-}
-
-
# force the height of the debugger to be pretty large so no pagers getused
gdb_test "set height 400" "" "test set height"

Index: gdb.base/maint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/maint.exp,v
retrieving revision 1.27
diff -u -r1.27 maint.exp
--- gdb.base/maint.exp 12 Oct 2006 19:03:22 -0000 1.27
+++ gdb.base/maint.exp 10 Nov 2006 16:20:36 -0000
@@ -679,21 +679,16 @@
timeout { fail "(timeout) help maint info" }
}

-send_gdb "help maint print\n"
-gdb_expect {
- -re "Maintenance command for printing GDB internal state\\.\[\r\n\]+List of maintenance print subcommands:\[\r\n\]+maintenance print architecture -- Print the internal architecture configuration.*maintenance print msymbols -- Print dump of current minimal symbol definitions.*maintenance print objfiles -- Print dump of current object file definitions.*maintenance print psymbols -- Print dump of current partial symbol definitions.*maintenance print statistics -- Print statistics about internal gdb state.*maintenance print symbols -- Print dump of current symbol definitions.*maintenance print type -- Print a type chain for a given symbol.*Type .help maintenance print. followed by maintenance print subcommand name for full documentation\\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
- { pass "help maint print" }
- -re ".*$gdb_prompt $" { fail "help maint print" }
- timeout { fail "(timeout) help maint print" }
- }
+test_prefix_command_help {"maint print" "maintenance print"} {
+ "Maintenance command for printing GDB internal state\\.\[\r\n\]+"
+}

-send_gdb "help maint\n"
-gdb_expect {
- -re "Commands for use by GDB maintainers\\.\[\r\n\]+Includes commands to dump specific internal GDB structures in\[\r\n\]+a human readable form, to cause GDB to deliberately dump core,\[\r\n\]+to test internal functions such as the C\\+\\+/ObjC demangler, etc\\..*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
- { pass "help maint" }
- -re ".*$gdb_prompt $" { fail "help maint" }
- timeout { fail "(timeout) help maint" }
- }
+test_prefix_command_help {"maint" "maintenance"} {
+ "Commands for use by GDB maintainers\\.\[\r\n\]+"
+ "Includes commands to dump specific internal GDB structures in\[\r\n\]+"
+ "a human readable form, to cause GDB to deliberately dump core,\[\r\n\]+"
+ "to test internal functions such as the C\\+\\+/ObjC demangler, etc\\.\[\r\n\]+"
+}

#set oldtimeout $timeout
#set timeout [expr $timeout + 300]
Index: gdb.cp/maint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/maint.exp,v
retrieving revision 1.4
diff -u -r1.4 maint.exp
--- gdb.cp/maint.exp 20 Jan 2006 23:08:48 -0000 1.4
+++ gdb.cp/maint.exp 10 Nov 2006 16:20:36 -0000
@@ -29,13 +29,17 @@
set first_component_help "Print the first class/namespace component of NAME"
set namespace_help "Print the list of possible C\\+\\+ namespaces"

- set multiple_help_body "List of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- ${first_component_help}\r\nmaintenance cplus namespace -- ${namespace_help}\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
+ 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 help_maint_cp "C\\+\\+ maintenance commands.\r\n\r\n${multiple_help_body}"
+ set multiple_help_body "List of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- ${first_component_help}\r\nmaintenance cplus namespace -- ${namespace_help}\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."

- gdb_test "help maintenance cplus" "${help_maint_cp}"
- gdb_test "help maint cp" "${help_maint_cp}"
- gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\n${multiple_help_body}"
+ gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\n.*"

gdb_test "help maint cp first_component" "${first_component_help}."
gdb_test "help maint cp namespace" "${namespace_help}."
Index: gdb.trace/tracecmd.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.trace/tracecmd.exp,v
retrieving revision 1.4
diff -u -r1.4 tracecmd.exp
--- gdb.trace/tracecmd.exp 10 Aug 2006 05:27:22 -0000 1.4
+++ gdb.trace/tracecmd.exp 10 Nov 2006 16:20:37 -0000
@@ -66,109 +66,9 @@
#

set helpcnt 0;
-send_gdb "help tracepoints\n"
-gdb_expect {
- -re "Tracing of program execution without stopping the program." {
- incr helpcnt;
- exp_continue
- }
- -re "actions -- Specify the actions to be taken at a tracepoint" {
- incr helpcnt;
- exp_continue
- }
- -re "collect -- Specify one or more data items to be collected" {
- incr helpcnt;
- exp_continue
- }
- -re "delete tracepoints -- Delete specified tracepoints" {
- incr helpcnt;
- exp_continue
- }
- -re "end -- Ends a list of.*actions" {
- incr helpcnt;
- exp_continue
- }
- -re "info tracepoints -- Status of tracepoints" {
- incr helpcnt;
- exp_continue
- }
- -re "passcount -- Set the passcount for a tracepoint" {
- incr helpcnt;
- exp_continue
- }
- -re "save-tracepoints -- Save current tracepoint definitions" {
- incr helpcnt;
- exp_continue
- }
- -re "tdump -- Print everything collected at the current tracepoint" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind -- Select a trace frame" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind end -- Synonym for 'none'" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind line -- Select a trace frame by line number" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind none -- De-select any trace frame and resume 'live' debugging" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind outside -- Select a trace frame whose PC is outside" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind pc -- Select a trace frame by PC" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind range -- Select a trace frame whose PC is in the given" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind start -- Select the first trace frame in the trace buffer" {
- incr helpcnt;
- exp_continue
- }
- -re "tfind tracepoint -- Select a trace frame by tracepoint number" {
- incr helpcnt;
- exp_continue
- }
- -re "trace -- Set a tracepoint at a specified line or function or addr" {
- incr helpcnt;
- exp_continue
- }
- -re "tstart -- Start trace data collection" {
- incr helpcnt;
- exp_continue
- }
- -re "tstatus -- Display the status of the current trace data collection" {
- incr helpcnt;
- exp_continue
- }
- -re "tstop -- Stop trace data collection" {
- incr helpcnt;
- exp_continue
- }
- -re "while-stepping -- Specify single-stepping behavior at a tracepoint" {
- incr helpcnt;
- exp_continue
- }
- -re ".*$gdb_prompt $" {
- if { $helpcnt == 21 } {
- pass "1.0: help tracepoints"
- } else {
- warning "$helpcnt";
- fail "1.0: help tracepoints"
- }
- }
-}
+test_class_help "tracepoints" {
+ "Tracing of program execution without stopping the program\.[\r\n\]+"
+} "1.0: help tracepoints"

#
# test trace command:
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.71
diff -u -r1.71 gdb.exp
--- lib/gdb.exp 17 Oct 2006 20:17:45 -0000 1.71
+++ lib/gdb.exp 10 Nov 2006 16:20:37 -0000
@@ -2409,3 +2409,61 @@
return 0
}

+# Test the output of GDB_COMMAND matches the pattern obtained
+# by concatenating all elements of EXPECTED_LINES. This makes
+# it possible to split otherwise very long string into pieces.
+# If third argument is not empty, it's used as the name of the
+# test to be printed on pass/fail.
+proc help_test_raw { gdb_command expected_lines args } {
+ set message $gdb_command
+ if [llength $args]>0 then {
+ set message [lindex $args 0]
+ }
+ set expected_output [join $expected_lines ""]
+ gdb_test "${gdb_command}" "${expected_output}" $message
+}
+
+# Test the output of "help COMMNAD_CLASS". EXPECTED_INITIAL_LINES
+# are regular expressions that should match the beginning of output,
+# before the list of commands in that class. The presence of
+# command list and standard epilogue will be tested automatically.
+proc test_class_help { command_class expected_initial_lines args } {
+ set l_stock_body {
+ "List of commands\:.*\[\r\n\]+"
+ "Type \"help\" followed by command name for full documentation\.\[\r\n\]+"
+ "Type \"apropos word\" to search for commands related to \"word\"\.[\r\n\]+"
+ "Command name abbreviations are allowed if unambiguous\."
+ }
+ set l_entire_body [concat $expected_initial_lines $l_stock_body]
+
+ eval [list help_test_raw "help ${command_class}" $l_entire_body] $args
+}
+
+# COMMAND_LIST should have either one element -- command to test, or
+# two elements -- abbreviated command to test, and full command the first
+# element is abbreviation of.
+# The command must be a prefix command. EXPECTED_INITIAL_LINES
+# are regular expressions that should match the beginning of output,
+# before the list of subcommands. The presence of
+# subcommand list and standard epilogue will be tested automatically.
+proc test_prefix_command_help { command_list expected_initial_lines args } {
+ set command [lindex $command_list 0]
+ if {[llength $command_list]>1} {
+ set full_command [lindex $command_list 1]
+ } else {
+ set full_command $command
+ }
+ # Use 'list' and not just {} because we want variables to
+ # be expanded in this list.
+ set l_stock_body [list\
+ "List of $full_command subcommands\:.*\[\r\n\]+"\
+ "Type \"help $full_command\" followed by $full_command subcommand name for full documentation\.\[\r\n\]+"\
+ "Type \"apropos word\" to search for commands related to \"word\"\.\[\r\n\]+"\
+ "Command name abbreviations are allowed if unambiguous\."]
+ set l_entire_body [concat $expected_initial_lines $l_stock_body]
+ if {[llength $args]>0} {
+ help_test_raw "help ${command}" $l_entire_body [lindex $args 0]
+ } else {
+ help_test_raw "help ${command}" $l_entire_body
+ }
+}