Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Andrew Burgess <andrew.burgess@embecosm.com>,
	gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb/testsuite: Add gdb_test_multiple_name variable
Date: Sun, 06 Oct 2019 08:24:00 -0000	[thread overview]
Message-ID: <77c374d5-570d-6443-34c1-284b44d3a60b@suse.de> (raw)
In-Reply-To: <20191001172850.29867-1-andrew.burgess@embecosm.com>

On 01-10-19 19:28, Andrew Burgess wrote:
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 3a1f053cf8a..a472650cc75 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -719,10 +719,24 @@ proc gdb_internal_error_resync {} {
>  #
>  # gdb_test_multiple "print foo" "test foo" {
>  #    -re "expected output 1" {
> -#        pass "print foo"
> +#        pass "test foo"
>  #    }
>  #    -re "expected output 2" {
> -#        fail "print foo"
> +#        fail "test foo"
> +#    }
> +# }
> +#
> +# Within action elements you can also make use of the variable
> +# gdb_test_multiple_name, this variable is setup automatically by
> +# gdb_test_multiple, and contains the value of MESSAGE.  You can then
> +# write this, which is equivalent to the above:
> +#

I'd split up the first line, f.i. like so:
...
# Within action elements you can also make use of the variable
# gdb_test_multiple_name.  This variable is setup automatically by
# gdb_test_multiple, and contains the value of MESSAGE.
...


> +# gdb_test_multiple "print foo" "test foo" {
> +#    -re "expected output 1" {
> +#        pass $gdb_test_multiple_name
> +#    }
> +#    -re "expected output 2" {
> +#        fail $gdb_test_multiple_name
>  #    }
>  # }
>  #
> @@ -1038,8 +1052,28 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
>  	}
>      }
>  
> +    # Create gdb_test_multiple_name in the parent scope.  If this
> +    # variable already exists, which is might if we have nested calls

is -> it

> +    # to gdb_test_multiple, then preserve the old value, otherwise,
> +    # create a new variable in the parent scope.
> +    upvar gdb_test_multiple_name gdb_test_multiple_name
> +    if { [info exists gdb_test_multiple_name] } {
> +	set gdb_test_multiple_name_old "$gdb_test_multiple_name"
> +    }
> +    set gdb_test_multiple_name "$message"
> +
>      set result 0
>      set code [catch {gdb_expect $code} string]
> +
> +    # Clean up the gdb_test_multiple_name variable.  If we had a
> +    # previous value then restore it, otherwise, delete the variable
> +    # from the parent scope.
> +    if { [info exists gdb_test_multiple_name_old] } {
> +	set gdb_test_multiple_name "$gdb_test_multiple_name_old"
> +    } else {
> +	unset gdb_test_multiple_name
> +    }
> +
>      if {$code == 1} {
>  	global errorInfo errorCode
>  	return -code error -errorinfo $errorInfo -errorcode $errorCode $string
> 

Other than these nits, looks good to me.

[ FWIW, Pedro's suggestion of using gdb_test_name instead of
gdb_test_multiple_name is fine by me. ]

Thanks,
- Tom


  parent reply	other threads:[~2019-10-06  8:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01 17:29 Andrew Burgess
2019-10-01 17:41 ` Keith Seitz
2019-10-02 13:03   ` Andrew Burgess
2019-10-02 17:17     ` Keith Seitz
2019-10-03 10:02       ` Andrew Burgess
2019-10-01 18:31 ` Pedro Alves
2019-10-06  8:24 ` Tom de Vries [this message]
2019-10-07 10:28 ` Andrew Burgess

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=77c374d5-570d-6443-34c1-284b44d3a60b@suse.de \
    --to=tdevries@suse.de \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /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