From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailsec117.isp.belgacom.be (mailsec117.isp.belgacom.be [195.238.20.113]) by sourceware.org (Postfix) with ESMTPS id 160A33840C2D for ; Sat, 16 May 2020 17:19:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 160A33840C2D IronPort-SDR: wwzIeMRGJff1mpZ675PurrEbi6x0kPh5AN9+EOrCXto9qTL15RwTwLmryu0SwmbPx9yLeNcrny 8nwwOz20/RZVehOFN6sggyjKooQg1NZHY81zBh+K9CF0ierVJWl16m5l+AZ9looV7m1qZWp/IL HnhMkJ5D3gJ2ivRDykRXMptzWwkb3PXpMq/kXTY53/8kOdIsH5nqTcg50KwCj5lYNwZ3WtAH0D nLyWuDjTK77VlWWolh3PnW2keIwkJJ9cFB1B6bUOSdMf2d+WfxMP5yXKrFOm84fOIqQvAhPHGE zAU= IronPort-PHdr: =?us-ascii?q?9a23=3A0hbAQRPB/dvgdij0lPwl6mtUPXoX/o7sNwtQ0K?= =?us-ascii?q?IMzox0I/vyrarrMEGX3/hxlliBBdydt6sZzbOO6+u5AT1IyK3CmUhKSIZLWR?= =?us-ascii?q?4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBx?= =?us-ascii?q?rwKxd+KPjrFY7OlcS30P2594HObwlSizexfLN/IA+roQnNqsUajpZuJro1xx?= =?us-ascii?q?DUvnZGZuNayH9yK1mOhRj8/MCw/JBi8yRUpf0s8tNLXLv5caolU7FWFSwqPG?= =?us-ascii?q?8p6sLlsxnDVhaP6WAHUmoKiBpIAhPK4w/8U5zsryb1rOt92C2dPc3rUbA5XC?= =?us-ascii?q?mp4ql3RBP0jioMKjg0+3zVhMNtlqJWuBKvqQJizYDaY4+bM/hxfq3Sct0VXm?= =?us-ascii?q?dNQsVcWjZdDo6mc4cDE+wMNvtYoYnnoFsOqAOzCxOsBOPuzj9Ih2f23bUk3O?= =?us-ascii?q?88EQ7JxhYgH9UXsHTJrdX6Kr0SUfuox6TP1TXDb/JW2TP86IjQahAuv+uAXL?= =?us-ascii?q?xqfsrLzkkvDh7FjlSOpoz/JDOYzf8Ns2ub7upmS+2vl3QrpBpvrTW2wMonl4?= =?us-ascii?q?bGiJ4PxF/e6SV53Jg6Jce+SENjf9KqEIVcui6eOoZqQs4vQG5ltSI6x7AHt5?= =?us-ascii?q?O2YSgExZo5yhPdavGJc5SF7BL9WOuQLjp1inNodKywiRu9/katxOvxXdS63l?= =?us-ascii?q?ZNqypKiNjMtnYV2hzc7MiHV+Fx/kC72TaA0Q3Y9+JKIVgsmKbFNpIswKQ8mo?= =?us-ascii?q?cdvEnCBCP7m1j6gLWYe0gq/OWj9v7pba/8ppCGMo95kgT+MqMzlcOhGek4KQ?= =?us-ascii?q?0OX3SD+eS7yb3j4VX1QLVUgf0ylanUqJXaKtkBqq65BA9V15gs5w6+Dzegzt?= =?us-ascii?q?sYgWEKIExYdB+FlYTlJl/DLfHiAfq8nligijlmyv7eMr3kGJrNL3zDkLn7fb?= =?us-ascii?q?Z67k5R0BIzzdBe55JQC7EBOOrzVVHruN3WFBA5KQu0w//6CNV8yIweQ3mPD7?= =?us-ascii?q?SCMKPRsV6I4PwgI/WWaIAOpjnxM+Il6OL2jX8lhV8derGk3ZQKZ3+jB/hmO1?= =?us-ascii?q?+WYWbwjdcBD2gKpREzTPftiF2fSz5ce2i9Xqwm6TEhFo2qF4DDRpqigLaZxi?= =?us-ascii?q?e0AoVWZnxaClCLCXrob4WEW/YIaCKTOs9hiiILWaKvSoA7zxGusxb6y6dmLu?= =?us-ascii?q?XK4C0Yronu1MN25+zTkxE96yB0A96G3G6THClImTYHSzVzxKljqkxw0X+Y1r?= =?us-ascii?q?ViiPFHHMZeofRTXVQUL5nZmtR6CtTzQhrMNuiAUlG/X9SrGyp5GsoxwtsPe1?= =?us-ascii?q?5wXcqrlBfawiunGaQ9jL+aApEotKjRiSuib/1hwmrLgfFyx2ItRdFCYDWr?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2CQEgDYH8Be/yFRiNlmHgEBCxIMggm?= =?us-ascii?q?CKipFVCESLI0lhXqcDYFnCwEBAQEBAQEBAQgfDQECBAEBgVCCdAKCFSc4EwI?= =?us-ascii?q?DAQEBAwIFAQEGAQEBAQEBBAQBbAQBAQcKAgGETiEBAwEBBQoBNwxCFgGBYiK?= =?us-ascii?q?DFQYyASMjED8SVxkJgx0BgwCwX4VRg2+BQIE4AYdahHaBTD+BEAGCYoNIgTW?= =?us-ascii?q?GMQSOLBEIBolXgliXKmwHglOBAQSXNgwdgl2aeZIfjWuONIFpIoFWbVOCaQl?= =?us-ascii?q?HGA2DaoxiF4hjhURCMDcCBggBAQMJVwEiAYoBhGABAQ?= X-IPAS-Result: =?us-ascii?q?A2CQEgDYH8Be/yFRiNlmHgEBCxIMggmCKipFVCESLI0lh?= =?us-ascii?q?XqcDYFnCwEBAQEBAQEBAQgfDQECBAEBgVCCdAKCFSc4EwIDAQEBAwIFAQEGA?= =?us-ascii?q?QEBAQEBBAQBbAQBAQcKAgGETiEBAwEBBQoBNwxCFgGBYiKDFQYyASMjED8SV?= =?us-ascii?q?xkJgx0BgwCwX4VRg2+BQIE4AYdahHaBTD+BEAGCYoNIgTWGMQSOLBEIBolXg?= =?us-ascii?q?liXKmwHglOBAQSXNgwdgl2aeZIfjWuONIFpIoFWbVOCaQlHGA2DaoxiF4hjh?= =?us-ascii?q?URCMDcCBggBAQMJVwEiAYoBhGABAQ?= Received: from 33.81-136-217.adsl-dyn.isp.belgacom.be (HELO md.home) ([217.136.81.33]) by relay.skynet.be with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 16 May 2020 19:19:53 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Subject: [RFAv6 2/3] Add tests for new default-args related commands and arguments. Date: Sat, 16 May 2020 19:19:46 +0200 Message-Id: <20200516171947.10507-3-philippe.waroquiers@skynet.be> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200516171947.10507-1-philippe.waroquiers@skynet.be> References: <20200516171947.10507-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPAM_BODY, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2020 17:20:00 -0000 Test the new default-args behaviour and completion. 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 YYYY-MM-DD Philippe Waroquiers * 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 and make test names unique. * 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/gdb.base/alias.exp | 2 +- gdb/testsuite/gdb.base/default-args.c | 41 ++++++++ gdb/testsuite/gdb.base/default-args.exp | 124 ++++++++++++++++++++++++ gdb/testsuite/gdb.base/default.exp | 4 +- gdb/testsuite/gdb.base/help.exp | 2 +- gdb/testsuite/gdb.base/page.exp | 4 +- gdb/testsuite/gdb.base/style.exp | 8 +- gdb/testsuite/gdb.guile/guile.exp | 5 +- gdb/testsuite/gdb.python/python.exp | 37 +++---- 9 files changed, 198 insertions(+), 29 deletions(-) create mode 100644 gdb/testsuite/gdb.base/default-args.c create mode 100644 gdb/testsuite/gdb.base/default-args.exp diff --git a/gdb/testsuite/gdb.base/alias.exp b/gdb/testsuite/gdb.base/alias.exp index 6993d42648..03c440dfd7 100644 --- a/gdb/testsuite/gdb.base/alias.exp +++ b/gdb/testsuite/gdb.base/alias.exp @@ -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 index 0000000000..c6426625d4 --- /dev/null +++ b/gdb/testsuite/gdb.base/default-args.c @@ -0,0 +1,41 @@ +/* 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 . */ + +int xxx1 = 123; + +struct S +{ + int a; + int b; + int c; +}; + +struct S g_s = {1, 2, 3}; + +static void +inc () +{ + g_s.a++;; +} + +int +main () +{ + 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 index 0000000000..e0f423404c --- /dev/null +++ b/gdb/testsuite/gdb.base/default-args.exp @@ -0,0 +1,124 @@ +# 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 . + +# Test the "default-args" related commands and arguments. + +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 "show default-args PP" "default-args PP = -pretty --" \ + "show default-args PP = print -pretty --" + gdb_test "PP g_s" \ + [multi_line \ + " = {" \ + " a = 1," \ + " b = 2," \ + " c = 3" \ + "}"] + + # Define default-args for an alias of frame apply all + gdb_test_no_output "alias frame apply tout = frame apply all -past-entry -past-main" \ + "alias frame apply tout" + gdb_test "show default-args frame apply tout" \ + "default-args frame apply tout = -past-entry -past-main" + + # Show all default args. + gdb_test "show default-args" \ + [multi_line \ + "default-args PP = -pretty --" \ + "default-args frame apply tout = -past-entry -past-main" ] \ + "show default-args" + + # Clear the default-args of "PP". + gdb_test_no_output "set default-args PP" "clear PP default-args" + gdb_test "show default-args PP" "default-args PP = " + gdb_test "PP g_s" " = {a = 1, b = 2, c = 3}" "simple PP print" + +} + +# Check errors. +with_test_prefix "errors" { + # Verify we cannot set default args for commands and pre-defined aliases. + gdb_test "set default-args backtrace -full" \ + "Default args can only be specified for user-defined aliases\\." + + + # Try an unknown root setting. + gdb_test "set default-args xxxx yyyy -someoption" \ + "Undefined command: \"xxxx\". Try \"help\"\\." + + # Try ambiguous command. + gdb_test "set default-args a" \ + "Ambiguous command \"a\":.*" "ambiguous a" + gdb_test "set default-args 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" + + # Test completion of 'set default-args' (sharing most + # of the code that alias command uses to complete after + # the first =. + test_gdb_complete_unique \ + "set default-args btf" \ + "set default-args btfu" + + test_gdb_complete_unique \ + "set default-args btfu -frame-a" \ + "set default-args btfu -frame-arguments" + +} diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index c34bb9a92a..ac1a0f5b6e 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -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 diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp index 8ed0be45db..0b6893cf79 100644 --- a/gdb/testsuite/gdb.base/help.exp +++ b/gdb/testsuite/gdb.base/help.exp @@ -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\]+" } diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp index c34c886c64..5936845885 100644 --- a/gdb/testsuite/gdb.base/page.exp +++ b/gdb/testsuite/gdb.base/page.exp @@ -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" diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 129f1746a3..bfd26144fa 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -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.*" \ ] diff --git a/gdb/testsuite/gdb.guile/guile.exp b/gdb/testsuite/gdb.guile/guile.exp index 2b0c0ba1d4..5d7b50fa15 100644 --- a/gdb/testsuite/gdb.guile/guile.exp +++ b/gdb/testsuite/gdb.guile/guile.exp @@ -58,11 +58,12 @@ gdb_test_multiline "multi-line guile command" \ "(print 23)" "" \ "end" "= 23" +# To avoid duplicate test error, prefix one of the "end" with spaces. gdb_test_multiline "show guile command" \ "define zzq" "Type commands for definition of .* just \"end\"\\.*" \ "guile" "" \ "(print 23)" "" \ - "end" "" \ + " end" "" \ "end" "" \ "show user zzq" "User command \"zzq\":.* guile.*\\(print 23\\).* end" @@ -80,5 +81,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" diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index a50a7b43e2..8045c666a3 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -77,11 +77,12 @@ with_test_prefix "python interactive help" { } } +# To avoid duplicate test error, prefix one of the "end" with spaces. gdb_py_test_multiple "show python command" \ "define zzq" "Type commands for definition of .* just \"end\"\\.*" \ "python" "" \ "print (23)" "" \ - "end" "" \ + " end" "" \ "end" "" \ "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end" @@ -187,7 +188,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. @@ -229,10 +230,10 @@ runto $lineno gdb_test "python gdb.decode_line(\"main.c:43\")" \ "gdb.error: No source file named main.c.*" "test decode_line no source named main" -gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "test decode_line current location" 1 -gdb_test "python print (len(symtab))" "2" "test decode_line current location" -gdb_test "python print (symtab\[0\])" "None" "test decode_line expression parse" -gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line current location" +gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "test decode_line current location =" 1 +gdb_test "python print (len(symtab))" "2" "test decode_line current location len" +gdb_test "python print (symtab\[0\])" "None" "test decode_line expression parse None" +gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line current location len 1" # Test that decode_line with an empty string argument does not crash. gdb_py_test_silent_cmd "python symtab2 = gdb.decode_line('')" \ @@ -246,18 +247,18 @@ if { [is_remote host] } { gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "test decode_line current location filename" gdb_test "python print (symtab\[1\]\[0\].line)" "$lineno" "test decode_line current location line number" -gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"python.c:26 if foo\")" "test decode_line python.c:26" 1 -gdb_test "python print (len(symtab))" "2" "test decode_line python.c:26 length" +gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"python.c:26 if foo\")" "test decode_line python.c:26 decode" 1 +gdb_test "python print (len(symtab))" "2" "test decode_line python.c:26 length 2" gdb_test "python print (symtab\[0\])" "if foo" "test decode_line expression parse" -gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line python.c:26 length" +gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line python.c:26 length 1" gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_c}" "test decode_line python.c:26 filename" gdb_test "python print (symtab\[1\]\[0\].line)" "26" "test decode_line python.c:26 line number" gdb_test "python gdb.decode_line(\"randomfunc\")" \ "gdb.error: Function \"randomfunc\" not defined.*" "test decode_line randomfunc" gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "test decode_line func1()" 1 -gdb_test "python print (len(symtab))" "2" "test decode_line func1 length" -gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line func1 length" +gdb_test "python print (len(symtab))" "2" "test decode_line func1 length 2" +gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line func1 length 1" if { [is_remote host] } { set python_1_c [string_to_regexp "python-1.c"] @@ -336,7 +337,7 @@ set testfake "testfake" gdb_test_multiple "python gdb.prompt_hook = prompt" "set the hook" { -re "\[\r\n\]$newprompt $" { - pass "set hook" + pass "set hook prompt" } } @@ -395,7 +396,7 @@ gdb_test_multiple "end" "end programming" { } } -gdb_py_test_multiple "prompt substitution readline" \ +gdb_py_test_multiple "prompt substitution readline import" \ "python" "" \ "import gdb.command.prompt" "" \ "end" "" @@ -449,7 +450,7 @@ gdb_test "show python print-stack" \ gdb_py_test_silent_cmd "set python print-stack message" \ "Test print-stack set setting to message" 1 -gdb_py_test_multiple "prompt substitution readline" \ +gdb_py_test_multiple "prompt substitution readline error_prompt" \ "python" "" \ "pCounter = 0" "" \ "def error_prompt(current):" "" \ @@ -458,24 +459,24 @@ gdb_py_test_multiple "prompt substitution readline" \ gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" { -re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|class ')RuntimeError'>) Python exception called.*$gdb_prompt $" { - pass "set hook" + pass "set hook error_prompt" } } gdb_py_test_silent_cmd "python gdb.prompt_hook = None" \ - "set the hook to default" 1 + "set the hook to default 1" 1 gdb_py_test_silent_cmd "set python print-stack full" \ "set print-stack full for prompt error test" 1 gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" { -re "Traceback.*File.*line.*RuntimeError.*Python exception called.*$gdb_prompt $" { - pass "set hook" + pass "set hook error_prompt traceback" } } gdb_py_test_silent_cmd "python gdb.prompt_hook = None" \ - "set the hook to default" 1 + "set the hook to default 2" 1 # Start with a fresh gdb. clean_restart ${testfile} -- 2.20.1