Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Pedro Alves <palves@redhat.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp
Date: Wed, 15 Nov 2017 16:09:00 -0000	[thread overview]
Message-ID: <08f40746-3771-d36a-889c-a31069436062@ericsson.com> (raw)
In-Reply-To: <1509039747-15026-7-git-send-email-palves@redhat.com>

On 2017-10-26 01:42 PM, Pedro Alves wrote:
> 'make check-read1 TESTS="gdb.tui/tui-completion.exp"' exposes this test race:
> 
>   (gdb) PASS: gdb.tui/completion.exp: set max-completions unlimited
>   layout ^G
>   asm    next   prev   regs   split  src
>   (gdb) FAIL: gdb.tui/completion.exp: completion of layout names: tab completion
>   Quit
>   (gdb) PASS: gdb.tui/completion.exp: completion of layout names: quit command input
>   focus ^G
>   cmd   next  prev  src
>   (gdb) FAIL: gdb.tui/completion.exp: completion of focus command: tab completion
>   Quit
> 
> This is caused by expecting "$gdb_prompt layout $".
> gdb_test_multiple's internal prompt regexp can match first if expect's
> internal buffer is filled with partial output.  Fix that by splitting
> the gdb_test_multiple in question in two.  Since the same problem/code
> appears twice in the file, factor out a common procedure.
> 
> gdb/testsuite/ChangeLog:
> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
> 
> 	* gdb.tui/tui-completion.exp (test_tab_completion): New procedure,
> 	factored out from ...
> 	(top level): ... here, and adjusted to avoid expecting beyond the
> 	prompt in a single gdb_test_multiple.
> ---
>  gdb/testsuite/gdb.tui/completion.exp | 36 +++++++++++++++++-------------------
>  1 file changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp
> index ac5d5f2..f53a244 100644
> --- a/gdb/testsuite/gdb.tui/completion.exp
> +++ b/gdb/testsuite/gdb.tui/completion.exp
> @@ -22,12 +22,20 @@ if {[skip_tui_tests] || [target_info exists gdb,nointerrupts]} {
>  
>  gdb_test_no_output "set max-completions unlimited"
>  
> -with_test_prefix "completion of layout names" {
> +# TAB-complete INPUT_LINE, and expect EXPECTED_RE as completion match
> +# output.
> +proc test_tab_completion {input_line expected_re} {
> +    global gdb_prompt
> +
>      set test "tab completion"
> -    send_gdb "layout\t\t\t"
> +    send_gdb "$input_line\t\t\t"
>      gdb_test_multiple "" "$test" {
> -	-re "asm *next *prev *regs *split *src *\r\n$gdb_prompt layout $" {
> -	    pass "$test"
> +	-re "$expected_re\r\n$gdb_prompt " {
> +	    gdb_test_multiple "" "$test" {
> +		-re "^$input_line$" {
> +		    pass "$test"
> +		}
> +	    }
>  	}
>      }
>      send_gdb "\003"
> @@ -39,20 +47,10 @@ with_test_prefix "completion of layout names" {
>      }
>  }
>  
> -with_test_prefix "completion of focus command" {
> -    set test "tab completion"
> -    send_gdb "focus \t\t"
> -    gdb_test_multiple "" "$test" {
> -	-re "cmd *next *prev *src *\r\n$gdb_prompt focus $" {
> -	    pass "$test"
> -	}
> -    }
> +with_test_prefix "completion of layout names" {
> +    test_tab_completion "layout" "asm *next *prev *regs *split *src *"
> +}
>  
> -    send_gdb "\003"
> -    set test "quit command input"
> -    gdb_test_multiple "" "$test" {
> -	-re "$gdb_prompt $" {
> -	    pass "$test"
> -	}
> -    }
> +with_test_prefix "completion of focus command" {
> +    test_tab_completion "focus" "cmd *next *prev *src *"
>  }
> 

Hi Pedro,

I am seeing a failure in this test (gdb.tui/completion.exp), I pushed
this patch to fix it.

commit 71774bc994e3f2a09c3b1988dbf2e99b86f53e2e
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Wed Nov 15 11:07:02 2017 -0500

    Fix gdb.tui/completion.exp test

    When I run it locally, the test gdb.tui/completion.exp test fails
    because of a timeout:

    Running /home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.tui/completion.exp ...
    FAIL: gdb.tui/completion.exp: completion of layout names: tab completion (timeout)

    The problem seems to be this regex, which confirms that after doing
    layout<TAB>, "layout" is printed again after the gdb prompt:

      -re "^$input_line$"

    The problem is that there's a trailing space in the output after
    "layout".  Since the regex has an anchored end (the $), it doesn't
    match.  Adding a space fixes the test.

    gdb/testsuite/ChangeLog:

    	* gdb.tui/completionn.exp (test_tab_completion): Add space in
    	regex.

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8c57179..bb8dd79 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-15  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* gdb.tui/completionn.exp (test_tab_completion): Add space in
+	regex.
+
 2017-11-13  Simon Marchi  <simon.marchi@polymtl.ca>

 	* gdb.opt/inline-locals.exp: Remove trailing parentheses from
diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp
index f53a244..426b6bf 100644
--- a/gdb/testsuite/gdb.tui/completion.exp
+++ b/gdb/testsuite/gdb.tui/completion.exp
@@ -32,7 +32,7 @@ proc test_tab_completion {input_line expected_re} {
     gdb_test_multiple "" "$test" {
 	-re "$expected_re\r\n$gdb_prompt " {
 	    gdb_test_multiple "" "$test" {
-		-re "^$input_line$" {
+		-re "^$input_line $" {
 		    pass "$test"
 		}
 	    }


  reply	other threads:[~2017-11-15 16:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
2017-10-26 17:42 ` [PATCH 3/6] Fix racy output matching in gdb.base/memattr.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 1/6] Fix racy output matching in gdb.asm/asm-source.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp Pedro Alves
2017-11-15 16:09   ` Simon Marchi [this message]
2017-11-15 16:16     ` Pedro Alves
2017-10-26 17:42 ` [PATCH 4/6] Fix racy output matching in gdb.base/cpcompletion.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 5/6] Fix racy output matching in gdb.base/multi-attach.exp, gdb.server/ext-{attach, restart, ext-run}.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 2/6] Fix racy output matching in gdb.base/completion.exp Pedro Alves
2017-11-09 22:50 ` [PATCH 0/6] Fix several cases of racy output matching 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=08f40746-3771-d36a-889c-a31069436062@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /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