Fix racy test in gdb.threads/thread-specific-bp.exp

Message ID 1491253593-4116-1-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi April 3, 2017, 9:06 p.m. UTC
  I see the following test fail from time to time, due to the racy test
in gdb.threads/thread-specific-bp.exp.

continue -a^M
Continuing.^M
^M
Thread 1 "thread-specific" hit Breakpoint 4, end () at binutils-gdb/gdb/testsuite/gdb.threads/thread-specific-bp.c:29^M
29      }^M
(gdb) [Thread 0x40322460 (LWP 12950) exited]^M
Thread-specific breakpoint 3 deleted - thread 2 no longer in the thread list.^M
FAIL: gdb.threads/thread-specific-bp.exp: non-stop: continue to end (timeout)

This patch changes gdb_test to gdb_test_multiple to match prompt only
instead of both prompt and anchor.

gdb/testsuite:

2017-04-03  Yao Qi  <yao.qi@linaro.org>

	* gdb.threads/thread-specific-bp.exp (check_thread_specific_breakpoint):
	Use gdb_test_multiple, and don't match anchor.
---
 gdb/testsuite/gdb.threads/thread-specific-bp.exp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Comments

Simon Marchi April 4, 2017, 1:49 a.m. UTC | #1
On 2017-04-03 17:06, Yao Qi wrote:
> diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp
> b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
> index bdf12f8..a652e9c 100644
> --- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp
> +++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
> @@ -87,9 +87,12 @@ proc check_thread_specific_breakpoint {mode} {
>  	} else {
>  	    set cmd "continue"
>  	}
> -	gdb_test "$cmd" \
> -	    "Breakpoint .* end .* at .*" \
> -	    "continue to end"
> +	set test "continue to end"
> +	gdb_test_multiple "$cmd" $test {
> +	    -re "Breakpoint .* end .* at .*(\[^\r\n\]*)\r\n$gdb_prompt " {

I am not sure I understand what this is supposed to match.  First are 
the parenthesis useful, since we're not using any capture group?  Then, 
.* followed with [^\r\n]* doesn't seem useful, since the .* can just 
match anything the [^\r\n]* doesn't match.

What about just this?

	set test "continue to end"
	gdb_test_multiple "$cmd" $test {
	    -re "hit Breakpoint $decimal, end \\(\\) at.*$gdb_prompt " {
		pass $test
	    }
	}

Simon
  
Yao Qi April 4, 2017, 8:08 a.m. UTC | #2
Simon Marchi <simon.marchi@polymtl.ca> writes:

> I am not sure I understand what this is supposed to match.  First are
> the parenthesis useful, since we're not using any capture group?

I don't capture anything.

> Then, .* followed with [^\r\n]* doesn't seem useful, since the .* can
> just match anything the [^\r\n]* doesn't match.
>
> What about just this?
>
> 	set test "continue to end"
> 	gdb_test_multiple "$cmd" $test {
> 	    -re "hit Breakpoint $decimal, end \\(\\) at.*$gdb_prompt " {

We should still keep \r\n before $gdb_prompt.

> 		pass $test
> 	    }
> 	}

The original pattern is "end .* at", so I want to leave it there, and
change it to

	set test "continue to end"
	gdb_test_multiple "$cmd" $test {
	    -re "Breakpoint .* end .* at .*\r\n$gdb_prompt " {
		pass $test
	    }
	}
  
Simon Marchi April 4, 2017, 1:37 p.m. UTC | #3
On 2017-04-04 04:08, Yao Qi wrote:
>> Then, .* followed with [^\r\n]* doesn't seem useful, since the .* can
>> just match anything the [^\r\n]* doesn't match.
>> 
>> What about just this?
>> 
>> 	set test "continue to end"
>> 	gdb_test_multiple "$cmd" $test {
>> 	    -re "hit Breakpoint $decimal, end \\(\\) at.*$gdb_prompt " {
> 
> We should still keep \r\n before $gdb_prompt.
> 
>> 		pass $test
>> 	    }
>> 	}
> 
> The original pattern is "end .* at", so I want to leave it there, and
> change it to
> 
> 	set test "continue to end"
> 	gdb_test_multiple "$cmd" $test {
> 	    -re "Breakpoint .* end .* at .*\r\n$gdb_prompt " {
> 		pass $test
> 	    }
> 	}

LGTM.
  
Yao Qi April 5, 2017, 1:49 p.m. UTC | #4
On Tue, Apr 4, 2017 at 2:37 PM, Simon Marchi <simon.marchi@polymtl.ca> wrote:
>
> LGTM.

Patch is pushed in.
  

Patch

diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
index bdf12f8..a652e9c 100644
--- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
@@ -87,9 +87,12 @@  proc check_thread_specific_breakpoint {mode} {
 	} else {
 	    set cmd "continue"
 	}
-	gdb_test "$cmd" \
-	    "Breakpoint .* end .* at .*" \
-	    "continue to end"
+	set test "continue to end"
+	gdb_test_multiple "$cmd" $test {
+	    -re "Breakpoint .* end .* at .*(\[^\r\n\]*)\r\n$gdb_prompt " {
+		pass $test
+	    }
+	}
 
 	set test "thread-specific breakpoint was deleted"
 	gdb_test_multiple "info breakpoint" $test {