Add tests for new alias default-args related commands and arguments.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 23 Jun 2019 21:13:57 +0000 (23:13 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 22 Jun 2020 19:15:14 +0000 (21:15 +0200)
Test the new default-args behaviour and completion for the alias command.
Note that gdb.base/default-args.exp is somewhat copied from
with.exp (the test of the with command), while default-exp.c
is a plain copy of with.c.

gdb/testsuite/ChangeLog
2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/default-args.exp: New test.
* gdb.base/default-args.c: New file.
* gdb.base/alias.exp: Update expected error msg for alias foo=bar.
* gdb.base/default.exp: Update to new help text.
* gdb.base/help.exp: Likewise.
* gdb.base/page.exp: Likewise.
* gdb.base/style.exp: Likewise.
* gdb.guile/guile.exp: Likewise.
* gdb.python/python.exp: Likewise.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/alias.exp
gdb/testsuite/gdb.base/default-args.c [new file with mode: 0644]
gdb/testsuite/gdb.base/default-args.exp [new file with mode: 0644]
gdb/testsuite/gdb.base/default.exp
gdb/testsuite/gdb.base/help.exp
gdb/testsuite/gdb.base/page.exp
gdb/testsuite/gdb.base/style.exp
gdb/testsuite/gdb.guile/guile.exp
gdb/testsuite/gdb.python/python.exp

index 1d3c764de05476b4bcd38c9ca21c7a8861650704..d6c43e65f068dc4a804b6364087495aaf49f09f8 100644 (file)
@@ -1,3 +1,15 @@
+2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+       * gdb.base/default-args.exp: New test.
+       * gdb.base/default-args.c: New file.
+       * gdb.base/alias.exp: Update expected error msg for alias foo=bar.
+       * gdb.base/default.exp: Update to new help text.
+       * gdb.base/help.exp: Likewise.
+       * gdb.base/page.exp: Likewise.
+       * gdb.base/style.exp: Likewise.
+       * gdb.guile/guile.exp: Likewise.
+       * gdb.python/python.exp: Likewise.
+
 2020-06-22  Sandra Loosemore  <sandra@codesourcery.com>
 
        * gdb.base/source-dir.exp (test_truncated_comp_dir): Skip on
index 6993d426484a5166370e7c7eb2aa2cce8f1e3e64..03c440dfd7b7ae9ca6cb70774fb608f216a4d5c8 100644 (file)
@@ -56,7 +56,7 @@ test_abbrev_alias set6 "alias -a -- set6 = set" 46
 test_abbrev_alias -a "alias -a -- -a = set" 47
 
 gdb_test "alias set2=set" "already exists: set2"
-gdb_test "alias foo=bar" "Invalid command to alias to: bar"
+gdb_test "alias foo=bar" "Undefined command: \"bar\".  Try \"help\"."
 
 gdb_test_no_output "alias spe = set p elem"
 gdb_test_no_output "spe 50"
diff --git a/gdb/testsuite/gdb.base/default-args.c b/gdb/testsuite/gdb.base/default-args.c
new file mode 100644 (file)
index 0000000..23f159f
--- /dev/null
@@ -0,0 +1,39 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2019-2020 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/>.  */
+
+struct S
+{
+  int a;
+  int b;
+  int c;
+};
+
+struct S g_s = {1, 2, 3};
+
+static void
+inc (void)
+{
+  g_s.a++;;
+}
+
+int
+main (void)
+{
+  inc ();
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/default-args.exp b/gdb/testsuite/gdb.base/default-args.exp
new file mode 100644 (file)
index 0000000..9cb3ef8
--- /dev/null
@@ -0,0 +1,123 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2019 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/>.
+
+# Test the "default-args" arguments and completion of alias command.
+
+load_lib completion-support.exp
+
+standard_testfile .c
+
+if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
+    return -1
+}
+
+clean_restart $binfile
+
+# Basic/core tests using user-visible commands.
+with_test_prefix "basics" {
+    # Define an alias to pretty print something.
+    gdb_test "print g_s" " = {a = 1, b = 2, c = 3}" "simple print"
+    gdb_test_no_output "alias PP = print -pretty --" "alias PP"
+    gdb_test "help PP" "print, PP, inspect, p\r\n  alias PP = print -pretty --\r\n.*"
+    gdb_test "PP g_s" \
+       [multi_line  \
+            " = {" \
+            "  a = 1," \
+            "  b = 2," \
+            "  c = 3" \
+            "}"]
+
+    # Define an alias of frame apply all with some default args.
+    gdb_test_no_output "alias frame apply tout = frame apply all -past-entry -past-main" \
+       "alias frame apply tout"
+    gdb_test "help frame apply tout" \
+       "frame apply all, frame apply tout\r\n  alias frame apply tout = frame apply all -past-entry -past-main\r\n.*"
+
+    # Show all aliases.
+    gdb_test "help aliases" \
+       [multi_line  \
+            "User-defined aliases of other commands." \
+            "" \
+            "List of commands:" \
+            "" \
+            "PP -- Print value of expression EXP." \
+            "  alias PP = print -pretty --" \
+            "frame apply tout -- Apply a command to all frames." \
+            "  alias frame apply tout = frame apply all -past-entry -past-main" \
+            ".*" ] \
+       "help aliases"
+}
+
+# Check errors.
+with_test_prefix "errors" {
+    # Try an unknown root setting.
+    gdb_test "alias wrong = xxxx yyyy -someoption" \
+       "Undefined command: \"xxxx\".  Try \"help\"\\."
+
+    # Try ambiguous command.
+    gdb_test "alias wrong = a" \
+       "Ambiguous command \"a\":.*" "ambiguous a"
+    gdb_test "alias wrong = frame a" \
+       "Ambiguous frame command \"a\":.*" "ambiguous frame a"
+}
+
+
+# Check completion.
+with_test_prefix "completion" {
+    test_gdb_complete_unique \
+       "alias set pri" \
+       "alias set print"
+
+    test_gdb_complete_unique \
+       "alias set print items = set pri" \
+       "alias set print items = set print"
+
+    test_gdb_complete_unique \
+       "alias set print items = set print ele" \
+       "alias set print items = set print elements"
+
+   test_gdb_complete_unique \
+       "alias btfu = backt" \
+       "alias btfu = backtrace"
+
+   test_gdb_complete_unique \
+       "alias btfu = backtrace -fu" \
+       "alias btfu = backtrace -full"
+
+   test_gdb_complete_unique \
+       "alias btfu = backtrace -full -past-e" \
+       "alias btfu = backtrace -full -past-entry"
+
+    gdb_test_no_output "alias btfu = backtrace -full -past-entry" \
+       "alias btfu"
+
+}
+
+# Check alias of alias.
+with_test_prefix "alias_of_alias" {
+    # Verify we can alias an alias that has no default args.
+    # We allow an alias of an alias, to be backward compatible with
+    # GDB 9.1 .
+    gdb_test_no_output "alias aaa = backtrace"
+    gdb_test_no_output "alias bbb = backtrace"
+
+    # Verify that we cannot define an alias of an alias that has default args.
+    gdb_test_no_output "alias ccc = backtrace -full"
+    gdb_test "alias ddd = ccc" \
+       "Cannot define an alias of an alias that has default args"
+
+}
index c34bb9a92a956cf25739141f220c4c897b2b46e8..ac1a0f5b6e6a13866399b1bfdb1bb322363d90bb 100644 (file)
@@ -247,9 +247,9 @@ gdb_test_multiple "generate-core-file" "generate-core-file" {
 }
 
 #test help "h" abbreviation
-gdb_test "h" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- Aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "help \"h\" abbreviation"
+gdb_test "h" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-defined aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "help \"h\" abbreviation"
 #test help
-gdb_test "help" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- Aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
+gdb_test "help" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-defined aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
 #test handle
 gdb_test "handle" "Argument required .signal to handle.*"
 #test info "i" abbreviation 
index 8ed0be45dbc3a62f3decf06a5c823bb000382b95..0b6893cf79aef0a05d608d3227774c94f472fe52 100644 (file)
@@ -25,7 +25,7 @@ gdb_start
 gdb_test_no_output "set height 0" "disable pagination"
 
 # Test all the help classes.
-test_class_help "aliases" {"Aliases of other commands\.\[\r\n\]+"}
+test_class_help "aliases" {"User-defined aliases of other commands\.\[\r\n\]+"}
 test_class_help "breakpoints" {
     "Making program stop at certain points\.\[\r\n\]+"
 }
index c34c886c6449c78a2121f1c77d1d1c0c76b8ee62..59368458855228cf9d17899599fc76bc86fa81bb 100644 (file)
@@ -23,7 +23,7 @@ gdb_test "show pagination" "State of pagination is off.*" "pagination is off"
 gdb_test_sequence "help" "unpaged help" {
     "List of classes of commands:"
     ""
-    "aliases -- Aliases of other commands"
+    "aliases -- User-defined aliases of other commands"
     "breakpoints -- Making program stop at certain points"
     "data -- Examining data"
     "files -- Specifying and examining files"
@@ -50,7 +50,7 @@ gdb_expect_list "paged help" \
        ".*$pagination_prompt" {
     "List of classes of commands:"
     ""
-    "aliases -- Aliases of other commands"
+    "aliases -- User-defined aliases of other commands"
     "breakpoints -- Making program stop at certain points"
     "data -- Examining data"
     "files -- Specifying and examining files"
index 129f1746a39f676816d9c35fac6c4aa8aca4c89a..bfd26144fa4e66d53b3dde96efcdd5aa32e6525e 100644 (file)
@@ -120,7 +120,7 @@ save_vars { env(TERM) } {
        [multi_line \
             "List of classes of commands:" \
             "" \
-            "${aliases_expr} -- Aliases of other commands\." \
+            "${aliases_expr} -- User-defined aliases of other commands\." \
             "${breakpoints_expr} -- Making program stop at certain points\." \
             ".*" \
            ] \
@@ -132,11 +132,13 @@ save_vars { env(TERM) } {
     gdb_test "apropos -v cut for 'thre" \
        [multi_line \
             "" \
-            "${taas_expr} --.*" \
+            "${taas_expr}" \
+            "Apply a command to all .*" \
             "Usage:.*" \
             "short${cut_for_thre_expr}ad apply.*" \
             "" \
-            "${tfaas_expr} --.*" \
+            "${tfaas_expr}" \
+            "Apply a command to all .*" \
             "Usage:.*" \
             "short${cut_for_thre_expr}ad apply.*" \
            ]
index 2b0c0ba1d410fb9e706aecf7575421bd90858583..1f80c8a2384c8e78dfc765411e8a202e70984ea0 100644 (file)
@@ -80,5 +80,5 @@ gdb_test "guile (print x)" "= 23"
 gdb_test_no_output "guile (define a (execute \"help\" #:to-string #t))" \
     "collect help from uiout"
 
-gdb_test "guile (print a)" "= .*aliases -- Aliases of other commands.*" \
+gdb_test "guile (print a)" "= .*aliases -- User-defined aliases of other commands.*" \
     "verify help to uiout"
index a50a7b43e2c26c250f3ca914a236f6b712bdd990..a751787b26262338e801f23293397322388c31c0 100644 (file)
@@ -187,7 +187,7 @@ gdb_test_no_output "set height 0"
 
 gdb_test_no_output "python a = gdb.execute('help', to_string=True)" "collect help from uiout"
 
-gdb_test "python print (a)" ".*aliases -- Aliases of other commands.*" "verify help to uiout"
+gdb_test "python print (a)" ".*aliases -- User-defined aliases of other commands.*" "verify help to uiout"
 
 # Test PR 12212, using InfThread.selected_thread() when no inferior is
 # loaded.
This page took 0.040288 seconds and 4 git commands to generate.