help.exp revision 1.6
1#   Copyright 1988-2016 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16# This file was written by Rob Savoye. (rob@cygnus.com)
17
18# Test basic help functionality.
19# This is not intended to test the help text of every command,
20# or even more than a few commands - too much of a maintenance burden.
21
22gdb_start
23
24# disable pagination
25gdb_test_no_output "set height 0" "disable pagination"
26
27# Test all the help classes.
28test_class_help "aliases" {"Aliases of other commands\.\[\r\n\]+"}
29test_class_help "breakpoints" {
30    "Making program stop at certain points\.\[\r\n\]+"
31}
32test_class_help "data" {"Examining data\.\[\r\n\]+"}
33test_class_help "files" {"Specifying and examining files\.\[\r\n\]+"}
34test_class_help "internals" {
35    "Maintenance commands\.\[\r\n\]+"
36    "Some gdb commands are provided just for use by gdb maintainers\.\[\r\n\]+"
37    "These commands are subject to frequent change, and may not be as\[\r\n\]+"
38    "well documented as user commands\.\[\r\n\]+"
39}
40test_class_help "obscure" {"Obscure features\.\[\r\n\]+"}
41test_class_help "running" {"Running the program\.\[\r\n\]+"}
42test_class_help "stack" {
43    "Examining the stack\..*\[\r\n\]+"
44    "When the program being debugged stops, gdb selects the innermost frame\.\[\r\n\]+"
45    "The commands below can be used to select other frames by number or address\.\[\r\n\]+"
46}
47test_class_help "status" {
48    "Status inquiries\.\[\r\n\]+"
49}
50test_class_help "support" {"Support facilities\.\[\r\n\]+"}
51test_class_help "tracepoints" {
52    "Tracing of program execution without stopping the program\.\[\r\n\]+"
53}
54test_class_help "user-defined" {
55    "User-defined commands\.\[\r\n\]+"
56    "The commands in this class are those defined by the user\.\[\r\n\]+"
57    "Use the \"define\" command to define a command\.\[\r\n\]+"
58}
59
60# Test help of an abbreviated command.  "break" is picked at random.
61set help_breakpoint_text "Set breakpoint at specified location\..*"
62# test help breakpoint "b" abbreviation
63gdb_test "help b" $help_breakpoint_text "help breakpoint \"b\" abbreviation"
64# test help breakpoint "br" abbreviation
65gdb_test "help br" $help_breakpoint_text "help breakpoint \"br\" abbreviation"
66# test help breakpoint "bre" abbreviation
67gdb_test "help bre" $help_breakpoint_text "help breakpoint \"bre\" abbreviation"
68# test help breakpoint "brea" abbreviation
69gdb_test "help brea" $help_breakpoint_text "help breakpoint \"brea\" abbreviation"
70# test help breakpoint "break" abbreviation
71gdb_test "help break" $help_breakpoint_text "help breakpoint \"break\" abbreviation"
72
73# Test help of an aliased command.  "bt" is picked at random.
74set help_backtrace_text "Print backtrace of all stack frames, or innermost COUNT frames\..*"
75# test help backtrace "bt" abbreviation
76gdb_test "help bt" $help_backtrace_text "help backtrace \"bt\" abbreviation"
77# test help backtrace
78gdb_test "help backtrace" $help_backtrace_text "help backtrace"
79
80# test help commands
81gdb_test "help commands" "Set commands to be executed when a breakpoint is hit\.\[\r\n\]+Give breakpoint number as argument after \"commands\"\.\[\r\n\]+With no argument, the targeted breakpoint is the last one set\.\[\r\n\]+The commands themselves follow starting on the next line\.\[\r\n\]+Type a line containing \"end\" to indicate the end of them\.\[\r\n\]+Give \"silent\" as the first line to make the breakpoint silent;\[\r\n\]+then no output is printed when it is hit, except what the commands print\." "help commands"
82
83# Test a prefix command.  "delete" is picked at random.
84# test help delete "d" abbreviation
85set expected_help_delete {
86    "Delete some breakpoints or auto-display expressions\.\[\r\n\]+"
87    "Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+"
88    "To delete all breakpoints, give no argument\.\[\r\n\]+"
89    "Also a prefix command for deletion of other GDB objects\.\[\r\n\]+"
90    "The \"unset\" command is also an alias for \"delete\"\.\[\r\n\]+"
91}
92test_prefix_command_help {"d" "delete"} $expected_help_delete "help delete \"d\" abbreviation"
93# test help delete
94test_prefix_command_help "delete" $expected_help_delete
95
96# Make sure help for help itself is present.
97# test help help "h" abbreviation
98gdb_test "help h" "Print list of commands\." "help help \"h\" abbreviation"
99# test help help
100gdb_test "help help" "Print list of commands\." "help help"
101
102# The startup banner refers to "show copying" and "show warranty",
103# might as well test for them.
104# test help info copying
105gdb_test "help show copying" "Conditions for redistributing copies of GDB\." \
106    "help show copying"
107# test help info warranty
108gdb_test "help show warranty" "Various kinds of warranty you do not have\." \
109    "help show warranty"
110
111# Test a few other random "help show" commands.
112# test help show commands
113gdb_test "help show commands" "Show the history of commands you typed\.\[\r\n\]+You can supply a command number to start with, or a `\[+\]' to start after\[\r\n\]+the previous command number shown\." "help show commands"
114# test help show confirm
115gdb_test "help show confirm" "Show whether to confirm potentially dangerous operations\." "help show confirm"
116
117# test help info bogus-gdb-command
118gdb_test "help info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\"\.  Try \"help info\"\." "help info bogus-gdb-command"
119# test help gotcha
120gdb_test "help gotcha" "Undefined command: \"gotcha\"\.  Try \"help\"\." "help gotcha"
121
122# test apropos regex
123gdb_test "apropos \\\(print\[\^ bsiedf\\\".-\]\\\)" "handle -- Specify how to handle signals"
124# test apropos >1 word string
125gdb_test "apropos handle signal" "handle -- Specify how to handle signals"
126# test apropos apropos
127gdb_test "apropos apropos" "apropos -- Search for commands matching a REGEXP.*"
128