Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
@ 2011-05-19 10:41 Marek Polacek
  2011-05-26 16:24 ` Tom Tromey
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Polacek @ 2011-05-19 10:41 UTC (permalink / raw)
  To: gdb-patches

In this test, there were three occurrences of the gdb_tes_multiple.  All
of them are of course causing races.  

The first case is exactly the same as in `mi-nonstop-exit.exp'.

The second test case cannot be, I think, converted to mi_gdb_test :(.  It is
because mi_gdb_test automatically appends `\[\r\n\]+$mi_gdb_prompt', but in
this particular case, we don't want this, since we expect the following
(no prompt at the end, instead, prompt is in the middle):

-exec-interrupt --thread 1
^done
(gdb) 
*stopped,reason="signal-received",signal-name="0",signal-meaning="...

And the third case could be, fortunately, converted into mi_gdb_test.

Tested with both read{,1}.  Ok?  

2011-05-19  Marek Polacek  <mpolacek@redhat.com>

        * gdb.mi/mi-nonstop.exp: Use the send_gdb+gdb_expect or mi_gdb_test
        instead of the gdb_test_multiple.

--- gdb/gdb/testsuite/gdb.mi/mi-nonstop.exp.mp	2011-01-01 16:33:47.000000000 +0100
+++ gdb/gdb/testsuite/gdb.mi/mi-nonstop.exp	2011-05-19 12:33:22.038216967 +0200
@@ -47,13 +47,17 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load $binfile
 
 set supported 0
-gdb_test_multiple "-gdb-show non-stop" "" {
-    -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
+send_gdb "-gdb-show non-stop\n"
+gdb_expect {
+    -re "\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
 	if { $expect_out(1,string) == "1" } {
 	    set supported 1
 	}
     }
+    -re "\\^done,value=\"off\"\r\n$mi_gdb_prompt$" {
+    }
     -re ".*$mi_gdb_prompt$" {
+	fail "-gdb-show non-stop"
     }
 }
 
@@ -92,22 +96,21 @@ mi_varobj_update * {I_W1 I_W0} "update v
 mi_check_varobj_value I_W0 1 "check varobj, w0, 1"
 mi_check_varobj_value I_W1 1 "check varobj, w1, 1"
 
-gdb_test_multiple "-exec-interrupt --thread 1" "interrupted" {
+send_gdb "-exec-interrupt --thread 1\n"
+gdb_expect {
     -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
 	pass "interrupted"
     }
 }
+
 # The interrupt command sends SIGINT to the target, and therefore the
 # thread might not be stopped immediately when we return from the target.
 # So, wait a bit
 sleep 1
 mi_check_thread_states {"stopped" "stopped" "stopped"} "thread state, stop 4"
 
-gdb_test_multiple "-exec-continue --all" "resume all" {
-    -re ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"\r\n$mi_gdb_prompt" {
-	pass "resume all"
-    }
-}
+mi_gdb_test "-exec-continue --all" ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"" \
+    "resume all"
 
 mi_expect_stop "breakpoint-hit" "break_at_me" "\[^\n\]*" "non-stop.c" "\[0-9\]*" {"" "disp=\"keep\""} "w0,i2 stop"
 mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w1,i2 stop"


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-19 10:41 [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649) Marek Polacek
@ 2011-05-26 16:24 ` Tom Tromey
  2011-05-26 16:32   ` Pedro Alves
  2011-05-27 10:58   ` Marek Polacek
  0 siblings, 2 replies; 13+ messages in thread
From: Tom Tromey @ 2011-05-26 16:24 UTC (permalink / raw)
  To: Marek Polacek; +Cc: gdb-patches

>>>>> "Marek" == Marek Polacek <mpolacek@redhat.com> writes:

Marek> 2011-05-19  Marek Polacek  <mpolacek@redhat.com>
Marek>         * gdb.mi/mi-nonstop.exp: Use the send_gdb+gdb_expect or mi_gdb_test
Marek>         instead of the gdb_test_multiple.

Marek>  set supported 0
Marek> -gdb_test_multiple "-gdb-show non-stop" "" {
Marek> -    -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
Marek> +send_gdb "-gdb-show non-stop\n"
Marek> +gdb_expect {
Marek> +    -re "\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
Marek>  	if { $expect_out(1,string) == "1" } {
Marek>  	    set supported 1
Marek>  	}
Marek>      }
Marek> +    -re "\\^done,value=\"off\"\r\n$mi_gdb_prompt$" {
Marek> +    }
Marek>      -re ".*$mi_gdb_prompt$" {
Marek> +	fail "-gdb-show non-stop"
Marek>      }
Marek>  }

It seems wrong to me to have a 'fail' without a corresponding 'pass'.

Marek> -gdb_test_multiple "-exec-interrupt --thread 1" "interrupted" {
Marek> +send_gdb "-exec-interrupt --thread 1\n"
Marek> +gdb_expect {
Marek>      -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
Marek>  	pass "interrupted"
Marek>      }
Marek>  }

And likewise a pass without a fail.

Tom


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-26 16:24 ` Tom Tromey
@ 2011-05-26 16:32   ` Pedro Alves
  2011-05-27 11:20     ` Marek Polacek
  2011-05-27 14:07     ` Marek Polacek
  2011-05-27 10:58   ` Marek Polacek
  1 sibling, 2 replies; 13+ messages in thread
From: Pedro Alves @ 2011-05-26 16:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey, Marek Polacek

> >>>>> "Marek" == Marek Polacek <mpolacek@redhat.com> writes:
> 
> Marek> 2011-05-19  Marek Polacek  <mpolacek@redhat.com>
> Marek>         * gdb.mi/mi-nonstop.exp: Use the send_gdb+gdb_expect or mi_gdb_test
> Marek>         instead of the gdb_test_multiple.
> 
> Marek>  set supported 0
> Marek> -gdb_test_multiple "-gdb-show non-stop" "" {
> Marek> -    -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
> Marek> +send_gdb "-gdb-show non-stop\n"
> Marek> +gdb_expect {
> Marek> +    -re "\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
> Marek>  	if { $expect_out(1,string) == "1" } {
> Marek>  	    set supported 1
> Marek>  	}
> Marek>      }
> Marek> +    -re "\\^done,value=\"off\"\r\n$mi_gdb_prompt$" {
> Marek> +    }
> Marek>      -re ".*$mi_gdb_prompt$" {
> Marek> +	fail "-gdb-show non-stop"
> Marek>      }
> Marek>  }

This pattern appears in all the MI non-stop tests.  It'd be nice
to move it to mi-support.exp (ideally in a preparatory patch
that just does the factoring/moving, and nothing else.)

> 
> Marek> -gdb_test_multiple "-exec-interrupt --thread 1" "interrupted" {
> Marek> +send_gdb "-exec-interrupt --thread 1\n"
> Marek> +gdb_expect {
> Marek>      -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
> Marek>  	pass "interrupted"
> Marek>      }
> Marek>  }

Can you use gdb_mi_expect_interrupt (+mi_gdb_test)?  See mi-nsinterall.exp.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-26 16:24 ` Tom Tromey
  2011-05-26 16:32   ` Pedro Alves
@ 2011-05-27 10:58   ` Marek Polacek
  1 sibling, 0 replies; 13+ messages in thread
From: Marek Polacek @ 2011-05-27 10:58 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 05/26/2011 06:23 PM, Tom Tromey wrote:
[...]
> It seems wrong to me to have a 'fail' without a corresponding 'pass'.

Yes, it seems weird.  I will add a pass there.  Thanks,

	Marek


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-26 16:32   ` Pedro Alves
@ 2011-05-27 11:20     ` Marek Polacek
  2011-05-27 11:46       ` Marek Polacek
  2011-05-27 14:07     ` Marek Polacek
  1 sibling, 1 reply; 13+ messages in thread
From: Marek Polacek @ 2011-05-27 11:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Tom Tromey

On 05/26/2011 06:32 PM, Pedro Alves wrote:
> This pattern appears in all the MI non-stop tests.  It'd be nice
> to move it to mi-support.exp (ideally in a preparatory patch
> that just does the factoring/moving, and nothing else.)

I'll do it in a bit.

> Can you use gdb_mi_expect_interrupt (+mi_gdb_test)?  See mi-nsinterall.exp.

I'll take a look at it.  Thanks.

	Marek


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-27 11:20     ` Marek Polacek
@ 2011-05-27 11:46       ` Marek Polacek
  2011-05-27 12:08         ` Pedro Alves
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Polacek @ 2011-05-27 11:46 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Tom Tromey

On 05/27/2011 01:20 PM, Marek Polacek wrote:
> On 05/26/2011 06:32 PM, Pedro Alves wrote:
>> This pattern appears in all the MI non-stop tests.  It'd be nice
>> to move it to mi-support.exp (ideally in a preparatory patch
>> that just does the factoring/moving, and nothing else.)
> 
> I'll do it in a bit.

On the other hand, what's actually the point of setting the `supported'
variable?  The above mentioned pattern for setting the `supported'
variable is to be found in these tests:
	
	mi-nsthrexec.exp
	mi-nonstop-exit.exp
	mi-nsintrall.exp
	mi-nsmoribund.exp
	mi-nonstop.exp
	mi-ns-stale-regcache.exp

But the `supported' variable is never used beyond the "-gdb-show non-stop"
part.  What am I missing?

	Marek


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-27 11:46       ` Marek Polacek
@ 2011-05-27 12:08         ` Pedro Alves
  2011-05-27 12:49           ` Marek Polacek
  0 siblings, 1 reply; 13+ messages in thread
From: Pedro Alves @ 2011-05-27 12:08 UTC (permalink / raw)
  To: Marek Polacek; +Cc: gdb-patches, Tom Tromey

On Friday 27 May 2011 12:46:08, Marek Polacek wrote:
> On 05/27/2011 01:20 PM, Marek Polacek wrote:
> > On 05/26/2011 06:32 PM, Pedro Alves wrote:
> >> This pattern appears in all the MI non-stop tests.  It'd be nice
> >> to move it to mi-support.exp (ideally in a preparatory patch
> >> that just does the factoring/moving, and nothing else.)
> > 
> > I'll do it in a bit.
> 
> On the other hand, what's actually the point of setting the `supported'
> variable?  The above mentioned pattern for setting the `supported'
> variable is to be found in these tests:
> 	
> 	mi-nsthrexec.exp
> 	mi-nonstop-exit.exp
> 	mi-nsintrall.exp
> 	mi-nsmoribund.exp
> 	mi-nonstop.exp
> 	mi-ns-stale-regcache.exp
> 
> But the `supported' variable is never used beyond the "-gdb-show non-stop"
> part.  What am I missing?

Eh, good question.  I don't even remember that the ,supported= bit
ever existed?  Patch to remove all of that is pre-approved.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-27 12:08         ` Pedro Alves
@ 2011-05-27 12:49           ` Marek Polacek
  2011-05-27 17:55             ` Tom Tromey
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Polacek @ 2011-05-27 12:49 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Tom Tromey

On 05/27/2011 02:08 PM, Pedro Alves wrote:
> Eh, good question.  I don't even remember that the ,supported= bit
> ever existed?  Patch to remove all of that is pre-approved.

OK, done:

	http://sourceware.org/ml/gdb-cvs/2011-05/msg00223.html

Thanks,

	Marek


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-26 16:32   ` Pedro Alves
  2011-05-27 11:20     ` Marek Polacek
@ 2011-05-27 14:07     ` Marek Polacek
  2011-05-27 14:14       ` Pedro Alves
  1 sibling, 1 reply; 13+ messages in thread
From: Marek Polacek @ 2011-05-27 14:07 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Tom Tromey

On 05/26/2011 06:32 PM, Pedro Alves wrote:
[...]

Another take, now with the mi_gdb_test and the mi_expect_interrupt.
Tested with both read{,1}.  Ok?

2011-05-27  Marek Polacek  <mpolacek@redhat.com>

        * gdb.mi/mi-nonstop.exp: Replace gdb_test_multiple with mi_gdb_test.

--- gdb/gdb/testsuite/gdb.mi/mi-nonstop.exp.mp  2011-05-27 14:36:57.000000000 +0200
+++ gdb/gdb/testsuite/gdb.mi/mi-nonstop.exp     2011-05-27 15:54:27.063216883 +0200
@@ -81,22 +81,17 @@ mi_varobj_update * {I_W1 I_W0} "update v
 mi_check_varobj_value I_W0 1 "check varobj, w0, 1"
 mi_check_varobj_value I_W1 1 "check varobj, w1, 1"
 
-gdb_test_multiple "-exec-interrupt --thread 1" "interrupted" {
-    -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
-       pass "interrupted"
-    }
-}
+mi_gdb_test "-exec-interrupt --thread 1" "\\^done"  "interrupted"
+mi_expect_interrupt "got interrupt"
+
 # The interrupt command sends SIGINT to the target, and therefore the 
 # thread might not be stopped immediately when we return from the target.
 # So, wait a bit 
 sleep 1
 mi_check_thread_states {"stopped" "stopped" "stopped"} "thread state, stop 4"
 
-gdb_test_multiple "-exec-continue --all" "resume all" {
-    -re ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"\r\n$mi_gdb_prompt" {
-       pass "resume all"
-    }
-}
+mi_gdb_test "-exec-continue --all" ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"" \
+    "resume all"
 
 mi_expect_stop "breakpoint-hit" "break_at_me" "\[^\n\]*" "non-stop.c" "\[0-9\]*" {"" "disp=\"keep\""} "w0,i2 stop"
 mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w1,i2 stop"


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-27 14:07     ` Marek Polacek
@ 2011-05-27 14:14       ` Pedro Alves
  2011-05-27 14:18         ` Marek Polacek
  0 siblings, 1 reply; 13+ messages in thread
From: Pedro Alves @ 2011-05-27 14:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: Marek Polacek, Tom Tromey

On Friday 27 May 2011 15:06:51, Marek Polacek wrote:
> On 05/26/2011 06:32 PM, Pedro Alves wrote:
> [...]
> 
> Another take, now with the mi_gdb_test and the mi_expect_interrupt.
> Tested with both read{,1}.  Ok?

Yes, thanks.

> 
> 2011-05-27  Marek Polacek  <mpolacek@redhat.com>
> 
>         * gdb.mi/mi-nonstop.exp: Replace gdb_test_multiple with mi_gdb_test.
> 
> --- gdb/gdb/testsuite/gdb.mi/mi-nonstop.exp.mp  2011-05-27 14:36:57.000000000 +0200
> +++ gdb/gdb/testsuite/gdb.mi/mi-nonstop.exp     2011-05-27 15:54:27.063216883 +0200
> @@ -81,22 +81,17 @@ mi_varobj_update * {I_W1 I_W0} "update v
>  mi_check_varobj_value I_W0 1 "check varobj, w0, 1"
>  mi_check_varobj_value I_W1 1 "check varobj, w1, 1"
>  
> -gdb_test_multiple "-exec-interrupt --thread 1" "interrupted" {
> -    -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
> -       pass "interrupted"
> -    }
> -}
> +mi_gdb_test "-exec-interrupt --thread 1" "\\^done"  "interrupted"
> +mi_expect_interrupt "got interrupt"
> +
>  # The interrupt command sends SIGINT to the target, and therefore the 
>  # thread might not be stopped immediately when we return from the target.
>  # So, wait a bit 
>  sleep 1
>  mi_check_thread_states {"stopped" "stopped" "stopped"} "thread state, stop 4"
>  
> -gdb_test_multiple "-exec-continue --all" "resume all" {
> -    -re ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"\r\n$mi_gdb_prompt" {
> -       pass "resume all"
> -    }
> -}
> +mi_gdb_test "-exec-continue --all" ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"" \
> +    "resume all"
>  
>  mi_expect_stop "breakpoint-hit" "break_at_me" "\[^\n\]*" "non-stop.c" "\[0-9\]*" {"" "disp=\"keep\""} "w0,i2 stop"
>  mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w1,i2 stop"
> 

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-27 14:14       ` Pedro Alves
@ 2011-05-27 14:18         ` Marek Polacek
  0 siblings, 0 replies; 13+ messages in thread
From: Marek Polacek @ 2011-05-27 14:18 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Tom Tromey

On 05/27/2011 04:13 PM, Pedro Alves wrote:
>> Another take, now with the mi_gdb_test and the mi_expect_interrupt.
>> Tested with both read{,1}.  Ok?
> 
> Yes, thanks.

Checked in:
http://sourceware.org/ml/gdb-cvs/2011-05/msg00225.html

	Marek


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-27 12:49           ` Marek Polacek
@ 2011-05-27 17:55             ` Tom Tromey
  2011-05-27 17:56               ` Marek Polacek
  0 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2011-05-27 17:55 UTC (permalink / raw)
  To: Marek Polacek; +Cc: Pedro Alves, gdb-patches

>>>>> "Marek" == Marek Polacek <mpolacek@redhat.com> writes:

Marek> OK, done:
Marek> 	http://sourceware.org/ml/gdb-cvs/2011-05/msg00223.html

Just FYI -- it is customary to post the patch to gdb-patches even when
it has been pre-approved in this way.

Tom


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649)
  2011-05-27 17:55             ` Tom Tromey
@ 2011-05-27 17:56               ` Marek Polacek
  0 siblings, 0 replies; 13+ messages in thread
From: Marek Polacek @ 2011-05-27 17:56 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Pedro Alves, gdb-patches

On 05/27/2011 07:55 PM, Tom Tromey wrote:
> Just FYI -- it is customary to post the patch to gdb-patches even when
> it has been pre-approved in this way.

All right, I'll do it this way next time.  Thanks,

	Marek


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-05-27 17:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19 10:41 [PATCH] gdb.mi/mi-nonstop.exp: fix racy tests (PR testsuite/12649) Marek Polacek
2011-05-26 16:24 ` Tom Tromey
2011-05-26 16:32   ` Pedro Alves
2011-05-27 11:20     ` Marek Polacek
2011-05-27 11:46       ` Marek Polacek
2011-05-27 12:08         ` Pedro Alves
2011-05-27 12:49           ` Marek Polacek
2011-05-27 17:55             ` Tom Tromey
2011-05-27 17:56               ` Marek Polacek
2011-05-27 14:07     ` Marek Polacek
2011-05-27 14:14       ` Pedro Alves
2011-05-27 14:18         ` Marek Polacek
2011-05-27 10:58   ` Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox