Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Tom de Vries <tdevries@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Don't use FOOBAR pattern in gdb_test
Date: Thu, 19 Sep 2019 16:41:00 -0000	[thread overview]
Message-ID: <20190919164055.GD4962@embecosm.com> (raw)
In-Reply-To: <20190919134051.GA15061@delia>

* Tom de Vries <tdevries@suse.de> [2019-09-19 15:40:53 +0200]:

> Hi,
> 
> If gdb_test is used with fewer than five arguments, then the question_string
> defaults to "^FOOBAR$":
> ...
>     if [llength $args]==5 {
>        set question_string [lindex $args 3]
>        set response_string [lindex $args 4]
>     } else {
>        set question_string "^FOOBAR$"
>     }
> ...
> 
> This can however match "FOOBAR", so perhaps "\$FOOBAR^" would have been a
> better choice.
> 
> Eliminate the FOOBAR pattern from gdb_test by instead of defining a default
> regexp, conditionally appending the regexp matching to a user_code variable.
> 
> Tested on x86_64-linux.
> 
> OK for trunk?

Looks good to me, a nice clean up.

Thanks,
Andrew



> 
> Thanks,
> - Tom
> 
> [gdb/testsuite] Don't use FOOBAR pattern in gdb_test
> 
> gdb/testsuite/ChangeLog:
> 
> 2019-09-19  Tom de Vries  <tdevries@suse.de>
> 
> 	* lib/gdb.exp (gdb_test): Eliminate "^FOOBAR$" pattern.
> 
> ---
>  gdb/testsuite/lib/gdb.exp | 28 ++++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index acbeb01376..3a1f053cf8 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -1083,24 +1083,28 @@ proc gdb_test { args } {
>      set command [lindex $args 0]
>      set pattern [lindex $args 1]
>  
> -    if [llength $args]==5 {
> -	set question_string [lindex $args 3]
> -	set response_string [lindex $args 4]
> -    } else {
> -	set question_string "^FOOBAR$"
> -    }
> -
> -    return [gdb_test_multiple $command $message {
> +    set user_code {}
> +    lappend user_code {
>  	-re "\[\r\n\]*(?:$pattern)\[\r\n\]+$gdb_prompt $" {
>  	    if ![string match "" $message] then {
>  		pass "$message"
>              }
>          }
> -	-re "(${question_string})$" {
> -	    send_gdb "$response_string\n"
> -	    exp_continue
> +    }
> +
> +    if { [llength $args] == 5 } {
> +	set question_string [lindex $args 3]
> +	set response_string [lindex $args 4]
> +	lappend user_code {
> +	    -re "(${question_string})$" {
> +		send_gdb "$response_string\n"
> +		exp_continue
> +	    }
>  	}
> -     }]
> +     }
> +
> +    set user_code [join $user_code]
> +    return [gdb_test_multiple $command $message $user_code]
>  }
>  
>  # Return 1 if version MAJOR.MINOR is at least AT_LEAST_MAJOR.AT_LEAST_MINOR.


      reply	other threads:[~2019-09-19 16:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 13:40 Tom de Vries
2019-09-19 16:41 ` Andrew Burgess [this message]

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=20190919164055.GD4962@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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