From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 4CB8D388A800 for ; Mon, 22 Jun 2020 14:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4CB8D388A800 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id DF57F1E79B; Mon, 22 Jun 2020 10:18:41 -0400 (EDT) Subject: Re: [RFAv8 2/3] Add tests for new alias default-args related commands and arguments. To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20200621183130.11503-1-philippe.waroquiers@skynet.be> <20200621183130.11503-3-philippe.waroquiers@skynet.be> From: Simon Marchi Message-ID: Date: Mon, 22 Jun 2020 10:18:41 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200621183130.11503-3-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, 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: Mon, 22 Jun 2020 14:18:44 -0000 On 2020-06-21 2:31 p.m., Philippe Waroquiers via Gdb-patches wrote: > 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. I got: Applying: Add tests for new alias default-args related commands and arguments. .git/rebase-apply/patch:202: trailing whitespace. .git/rebase-apply/patch:204: new blank line at EOF. + warning: 2 lines add whitespace errors. I've noted a few comments, but with those addressed the patch LGTM. > > 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. 2020, or 2019-2020 if it was a copy of something that was copyright 2019. > + > + 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; This appears to be unused. > + > +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) > 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" Interesting. I think that should eventually be fixed / handled in gdb_test_multiline. Since it doesn't seem related to this patchset, I'd leave it out of the patch. > > @@ -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} A lot of changes in python.exp also appear to be related to making test names unique, which is noble but unrelated to the scope of this patch. Can you please submit it as a separate patch? Simon