From: Simon Marchi <simark@simark.ca>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
gdb-patches@sourceware.org
Subject: Re: [RFA] Make test names unique in python.exp and guile.exp
Date: Tue, 23 Jun 2020 17:32:19 -0400 [thread overview]
Message-ID: <bf9dc761-2e70-729e-44dc-56cdcacf30e1@simark.ca> (raw)
In-Reply-To: <20200623205159.23461-1-philippe.waroquiers@skynet.be>
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 <philippe.waroquiers@skynet.be>
>
> * 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
next prev parent reply other threads:[~2020-06-23 21:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 20:51 Philippe Waroquiers
2020-06-23 21:32 ` Simon Marchi [this message]
2020-06-23 21:43 ` Pedro Alves
2020-06-23 21:56 ` Simon Marchi
2020-06-24 11:28 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf9dc761-2e70-729e-44dc-56cdcacf30e1@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=philippe.waroquiers@skynet.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox