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 C1C5538708D8 for ; Tue, 23 Jun 2020 21:32:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C1C5538708D8 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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 049361E792; Tue, 23 Jun 2020 17:32:19 -0400 (EDT) Subject: Re: [RFA] Make test names unique in python.exp and guile.exp To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20200623205159.23461-1-philippe.waroquiers@skynet.be> From: Simon Marchi Message-ID: Date: Tue, 23 Jun 2020 17:32:19 -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: <20200623205159.23461-1-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, 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: Tue, 23 Jun 2020 21:32:22 -0000 On 2020-06-23 4:51 p.m., Philippe Waroquiers via Gdb-patches wrote: > Note that gdb_test_multiline and gdb_py_test_multiple are using > the "input line" as the test name, and so when there is a duplicated > input line (such as a line containing "end"), we have duplicated test > names => as gdb_test_multiline and gdb_py_test_multiple are identical, > as indicated in FIXME, move this to gdb.exp, and make the test name unique > by adding the inputnr to the pass message for each input. > > YYYY-MM-DD Philippe Waroquiers > > * lib/gdb.exp (gdb_test_multiline): New, moved from gdb-guile.exp, > have a seq nr in each pass message. > * lib/gdb-guile.exp (gdb_test_multiline): Move to gdb.exp. > * lib/gdb-python.exp (gdb_py_test_multiple): Remove. > * gdb.python/python.exp: Make test names unique, > use gdb_test_multiline instead of gdb_py_test_multiple. > * gdb.guile/guile.exp: Make test names unique. > --- > gdb/testsuite/gdb.python/python.exp | 50 ++++++++++++++--------------- > gdb/testsuite/lib/gdb-guile.exp | 20 ------------ > gdb/testsuite/lib/gdb-python.exp | 19 ----------- > gdb/testsuite/lib/gdb.exp | 22 +++++++++++++ > 4 files changed, 47 insertions(+), 64 deletions(-) > > diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp > index a751787b26..8efecd8655 100644 > --- a/gdb/testsuite/gdb.python/python.exp > +++ b/gdb/testsuite/gdb.python/python.exp > @@ -46,7 +46,7 @@ gdb_test_multiple "python print (23)" "verify python support" { > "source source2.py when python disabled" > > # Verify multi-line python commands cause an error. > - gdb_py_test_multiple "multi-line python command" \ > + gdb_test_multiline "multi-line python command" \ > "python" "" \ > "print (23)" "" \ > "end" "not supported.*" > @@ -56,7 +56,7 @@ gdb_test_multiple "python print (23)" "verify python support" { > -re "$gdb_prompt $" {} > } > > -gdb_py_test_multiple "multi-line python command" \ > +gdb_test_multiline "multi-line python command" \ > "python" "" \ > "print (23)" "" \ > "end" "23" > @@ -77,15 +77,15 @@ with_test_prefix "python interactive help" { > } > } > > -gdb_py_test_multiple "show python command" \ > +gdb_test_multiline "show python command" \ > "define zzq" "Type commands for definition of .* just \"end\"\\.*" \ > "python" "" \ > "print (23)" "" \ > - "end" "" \ > + " end" "" \ This change is not needed anymore then? > "end" "" \ > "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end" > > -gdb_py_test_multiple "indented multi-line python command" \ > +gdb_test_multiline "indented multi-line python command" \ > "python" "" \ > "def foo ():" "" \ > " print ('hello, world!')" "" \ > @@ -124,7 +124,7 @@ gdb_test "python gdb.execute('echo 2\\necho 3\\\\n\\n')" "23" \ > gdb_test " " "23" "gdb.execute does not affect repeat history" > > # Test post_event. > -gdb_py_test_multiple "post event insertion" \ > +gdb_test_multiline "post event insertion" \ > "python" "" \ > "someVal = 0" "" \ > "class Foo(object):" "" \ > @@ -194,7 +194,7 @@ gdb_test "python print (a)" ".*aliases -- User-defined aliases of other commands > gdb_py_test_silent_cmd "python nothread = gdb.selected_thread()" "Attempt to aquire thread with no inferior" 1 > gdb_test "python print (nothread == None)" "True" "ensure that no threads are returned" > > -gdb_py_test_multiple "register atexit function" \ > +gdb_test_multiline "register atexit function" \ > "python" "" \ > "import atexit" "" \ > "def printit(arg):" "" \ > @@ -229,10 +229,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" I think it would make sense to use with_test_prefix here, instead of repeating test decode_line current location. And the test name should be at least a bit descriptive of what we test. This is what I would write: with_test_prefix "test decode_line current location" { gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "decode current line" 1 gdb_test "python print (len(symtab))" "2" "length of result" gdb_test "python print (symtab\[0\])" "None" "no unparsed text" gdb_test "python print (len(symtab\[1\]))" "1" "length of result locations" } That could apply to other cases below in this file as well. > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 7b243f5fff..12886c43f1 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -1236,6 +1236,28 @@ proc gdb_test_multiple { command message args } { > return $result > } > > +# Usage: gdb_test_multiline NAME INPUT RESULT {INPUT RESULT} ... > +# Run a test named NAME, consisting of multiple lines of input. > +# After each input line INPUT, search for result line RESULT. > +# Succeed if all results are seen; fail otherwise. > + > +proc gdb_test_multiline { name args } { > + global gdb_prompt > + set inputnr 0 > + foreach {input result} $args { > + set inputnr [expr ${inputnr} + 1] You can use `incr inputnr` > + if {[gdb_test_multiple $input "$name - $input" { > + -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { > + pass "$name - $input (input nr $inputnr)" The test name passed as the second argument of `gdb_test_multiple` and the test name passed to `pass` should match. This is why the special variable $gdb_test_name was added, to avoid potential mismatches. You can use "pass $gdb_test_name" inside the gdb_test_multiple body. Simon