* [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649)
@ 2011-06-28 14:19 Marek Polacek
2011-06-28 15:51 ` Joel Brobecker
0 siblings, 1 reply; 11+ messages in thread
From: Marek Polacek @ 2011-06-28 14:19 UTC (permalink / raw)
To: gdb-patches
This test fails with read1() because after sending "continue&"
the regexp with ".*" at the end didn't eat all that it ought to.
This causes trouble later on. Thusly fixed by adding the "\r\n$gdb_prompt".
Tested with both read{,1}. OK?
2011-06-28 Marek Polacek <mpolacek@redhat.com>
* gdb.python/py-evthreads.exp: Fix race by adding an anchor to match
the whole output.
--- gdb/gdb/testsuite/gdb.python/py-evthreads.exp.mp 2011-06-22 15:14:07.869452151 +0200
+++ gdb/gdb/testsuite/gdb.python/py-evthreads.exp 2011-06-28 16:10:53.157450752 +0200
@@ -86,7 +86,7 @@ gdb_expect {
send_gdb "continue&\n"
gdb_expect {
-re ".*event type: continue.*
-.*thread num: 1.*" {
+.*thread num: 1.*\r\n$gdb_prompt" {
pass "continue thread 1"
}
timeout {
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-06-28 14:19 [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) Marek Polacek @ 2011-06-28 15:51 ` Joel Brobecker 2011-06-30 10:26 ` Marek Polacek 2011-07-06 14:36 ` Marek Polacek 0 siblings, 2 replies; 11+ messages in thread From: Joel Brobecker @ 2011-06-28 15:51 UTC (permalink / raw) To: Marek Polacek; +Cc: gdb-patches > 2011-06-28 Marek Polacek <mpolacek@redhat.com> > > * gdb.python/py-evthreads.exp: Fix race by adding an anchor to match > the whole output. This is an area where I'm not entirely sure, but we usually use `$gdb_prompt $' as the anchor. I'm also surprised to see some uses of gdb_expect in gdb.python. I wonder if we could replace them with uses of gdb_test_multiple (that would be a separate patch)... -- Joel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-06-28 15:51 ` Joel Brobecker @ 2011-06-30 10:26 ` Marek Polacek 2011-07-06 17:21 ` Jan Kratochvil 2011-07-06 14:36 ` Marek Polacek 1 sibling, 1 reply; 11+ messages in thread From: Marek Polacek @ 2011-06-30 10:26 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches On 06/28/2011 05:51 PM, Joel Brobecker wrote: > This is an area where I'm not entirely sure, but we usually use > `$gdb_prompt $' as the anchor. Actually, it doesn't matter. That `$' at the end marks end of the read buffer, not the end of line. > I'm also surprised to see some uses of gdb_expect in gdb.python. > I wonder if we could replace them with uses of gdb_test_multiple > (that would be a separate patch)... Yeah, I was thinking about this change too. I'll try it. Marek ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-06-30 10:26 ` Marek Polacek @ 2011-07-06 17:21 ` Jan Kratochvil 2011-07-06 17:32 ` Joel Brobecker 0 siblings, 1 reply; 11+ messages in thread From: Jan Kratochvil @ 2011-07-06 17:21 UTC (permalink / raw) To: Marek Polacek; +Cc: Joel Brobecker, gdb-patches On Thu, 30 Jun 2011 12:25:44 +0200, Marek Polacek wrote: > On 06/28/2011 05:51 PM, Joel Brobecker wrote: > > This is an area where I'm not entirely sure, but we usually use > > `$gdb_prompt $' as the anchor. > > Actually, it doesn't matter. That `$' at the end marks end of the > read buffer, not the end of line. It is a difference as it requires the end of the read buffer that way. If GDB outputs some (gdb) unexpected_result then (without any read1 hacks) -re "$gdb_prompt $" will FAIL/timeout as it should while -re "$gdb_prompt " could give a false PASS. (I do not think it requires a new commit, it is up to you.) Thanks, Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-07-06 17:21 ` Jan Kratochvil @ 2011-07-06 17:32 ` Joel Brobecker 2011-07-06 17:57 ` Marek Polacek 0 siblings, 1 reply; 11+ messages in thread From: Joel Brobecker @ 2011-07-06 17:32 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Marek Polacek, gdb-patches > It is a difference as it requires the end of the read buffer that way. > > If GDB outputs some > (gdb) unexpected_result > > then (without any read1 hacks) -re "$gdb_prompt $" will FAIL/timeout as it > should while -re "$gdb_prompt " could give a false PASS. > > (I do not think it requires a new commit, it is up to you.) Let's fix it. If anything, we should be consistent. I might have a minute later today, but I don't want to make the change without running the testcase... So, I won't mind if someone gets to it before I do. -- Joel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-07-06 17:32 ` Joel Brobecker @ 2011-07-06 17:57 ` Marek Polacek 2011-07-06 19:53 ` Jan Kratochvil 0 siblings, 1 reply; 11+ messages in thread From: Marek Polacek @ 2011-07-06 17:57 UTC (permalink / raw) To: Joel Brobecker; +Cc: Jan Kratochvil, gdb-patches On 07/06/2011 07:26 PM, Joel Brobecker wrote: >> It is a difference as it requires the end of the read buffer that way. >> >> If GDB outputs some >> (gdb) unexpected_result >> >> then (without any read1 hacks) -re "$gdb_prompt $" will FAIL/timeout as it >> should while -re "$gdb_prompt " could give a false PASS. >> >> (I do not think it requires a new commit, it is up to you.) > > Let's fix it. If anything, we should be consistent. I might have > a minute later today, but I don't want to make the change without > running the testcase... So, I won't mind if someone gets to it before > I do. > Sure. Shall I commit the patch below? 2011-07-06 Marek Polacek <mpolacek@redhat.com> * gdb.python/py-evthreads.exp: Add missing `$'. --- gdb/gdb/testsuite/gdb.python/py-evthreads.exp.mp 2011-07-06 19:34:05.210582529 +0200 +++ gdb/gdb/testsuite/gdb.python/py-evthreads.exp 2011-07-06 19:34:14.660516229 +0200 @@ -86,7 +86,7 @@ gdb_expect { send_gdb "continue&\n" gdb_expect { -re ".*event type: continue.* -.*thread num: 1.*\r\n$gdb_prompt " { +.*thread num: 1.*\r\n$gdb_prompt $" { pass "continue thread 1" } timeout { ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-07-06 17:57 ` Marek Polacek @ 2011-07-06 19:53 ` Jan Kratochvil 2011-07-06 22:06 ` Marek Polacek 0 siblings, 1 reply; 11+ messages in thread From: Jan Kratochvil @ 2011-07-06 19:53 UTC (permalink / raw) To: Marek Polacek; +Cc: Joel Brobecker, gdb-patches On Wed, 06 Jul 2011 19:42:15 +0200, Marek Polacek wrote: > 2011-07-06 Marek Polacek <mpolacek@redhat.com> > > * gdb.python/py-evthreads.exp: Add missing `$'. > > Sure. Shall I commit the patch below? I find it OK, please check it in as asked by Joel. Anyway I have finally completed rework of the testcase which I had TODO-pending for some months so I will update it anywhere after some review time. Re: [patch] Support inferior events in python http://sourceware.org/ml/gdb-patches/2011-07/msg00209.html Thanks, Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-07-06 19:53 ` Jan Kratochvil @ 2011-07-06 22:06 ` Marek Polacek 0 siblings, 0 replies; 11+ messages in thread From: Marek Polacek @ 2011-07-06 22:06 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Joel Brobecker, gdb-patches On 07/06/2011 09:42 PM, Jan Kratochvil wrote: > I find it OK, please check it in as asked by Joel. It's in: http://sourceware.org/ml/gdb-cvs/2011-07/msg00079.html > Anyway I have finally completed rework of the testcase which I had > TODO-pending for some months so I will update it anywhere after some review > time. > Re: [patch] Support inferior events in python > http://sourceware.org/ml/gdb-patches/2011-07/msg00209.html Cool. Marek ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-06-28 15:51 ` Joel Brobecker 2011-06-30 10:26 ` Marek Polacek @ 2011-07-06 14:36 ` Marek Polacek 2011-07-06 14:51 ` Joel Brobecker 1 sibling, 1 reply; 11+ messages in thread From: Marek Polacek @ 2011-07-06 14:36 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches On 06/28/2011 05:51 PM, Joel Brobecker wrote: > I'm also surprised to see some uses of gdb_expect in gdb.python. > I wonder if we could replace them with uses of gdb_test_multiple > (that would be a separate patch)... Hmm, after a few days of struggling with converting gdb_expect to gdb_test_multiple, I don't think that's The Right Thing anymore. The issue is that with send_gdb+gdb_expect we always get the same sequence--e.g., at the "next" test case, we get: next^M event type: continue^M thread num: 1^M [New Thread 0x7ffff7fe5710 (LWP 1364)]^M event type: continue^M thread num: 1^M 47 pthread_create (&thread3_id, NULL, thread3, NULL);^M event type: stop^M event type: stop^M (gdb) ^M Breakpoint 2, thread2 (d=0x0) at ./gdb.python/py-evthreads.c:39^M 39 int count2 = 0;^M event type: stop^M event type: stop^M stop reason: breakpoint^M breakpoint number: 2^M thread num: 2Quitting ... However, with gdb_test_multiple, we sometimes get: next^M event type: continue^M thread num: 1^M [New Thread 0x7ffff7fe5710 (LWP 31327)]^M event type: continue^M thread num: 1^M ^M Breakpoint 2, thread2 (d=0x0) at ./gdb.python/py-evthreads.c:39^M 39 int count2 = 0;^M event type: stop^M event type: stop^M stop reason: breakpointQuitting ... and some other time (and this fails): next^M event type: continue^M thread num: 1^M [New Thread 0x7ffff7fe5710 (LWP 31212)]^M event type: continue^M thread num: 1^M 47 pthread_create (&thread3_id, NULL, thread3, NULL);^M event type: stop^M event type: stop^M (gdb) FAIL: gdb.python/py-evthreads.exp: reached breakpoint 2 Quitting ... I don't understand why the gdb_test_multiple is non-deterministics :(. I thus propose this simple patch to avoid race (basically the same as before, just one extra space more). At least, for now. Tested with read{,1}. OK to commit? Thanks. 2011-07-06 Marek Polacek <mpolacek@redhat.com> * gdb.python/py-evthreads.exp: Fix race by adding an anchor to match the whole output. --- gdb/gdb/testsuite/gdb.python/py-evthreads.exp.mp 2011-06-22 15:14:07.869452151 +0200 +++ gdb/gdb/testsuite/gdb.python/py-evthreads.exp 2011-07-06 13:57:08.651591506 +0200 @@ -86,7 +86,7 @@ gdb_expect { send_gdb "continue&\n" gdb_expect { -re ".*event type: continue.* -.*thread num: 1.*" { +.*thread num: 1.*\r\n$gdb_prompt " { pass "continue thread 1" } timeout { ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-07-06 14:36 ` Marek Polacek @ 2011-07-06 14:51 ` Joel Brobecker 2011-07-06 15:46 ` Marek Polacek 0 siblings, 1 reply; 11+ messages in thread From: Joel Brobecker @ 2011-07-06 14:51 UTC (permalink / raw) To: Marek Polacek; +Cc: gdb-patches > I don't understand why the gdb_test_multiple is non-deterministics :(. Off the top of my head like that, I don't know either. It might be a question of bad anchoring, maybe? In any case, I really meant that as a followup patch anyways... > 2011-07-06 Marek Polacek <mpolacek@redhat.com> > > * gdb.python/py-evthreads.exp: Fix race by adding an anchor to match > the whole output. This is OK. Thank you. -- Joel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) 2011-07-06 14:51 ` Joel Brobecker @ 2011-07-06 15:46 ` Marek Polacek 0 siblings, 0 replies; 11+ messages in thread From: Marek Polacek @ 2011-07-06 15:46 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches On 07/06/2011 04:44 PM, Joel Brobecker wrote: > This is OK. Thank you. Applied: http://sourceware.org/ml/gdb-cvs/2011-07/msg00077.html Thanks, Marek ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-07-06 19:53 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-06-28 14:19 [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) Marek Polacek 2011-06-28 15:51 ` Joel Brobecker 2011-06-30 10:26 ` Marek Polacek 2011-07-06 17:21 ` Jan Kratochvil 2011-07-06 17:32 ` Joel Brobecker 2011-07-06 17:57 ` Marek Polacek 2011-07-06 19:53 ` Jan Kratochvil 2011-07-06 22:06 ` Marek Polacek 2011-07-06 14:36 ` Marek Polacek 2011-07-06 14:51 ` Joel Brobecker 2011-07-06 15:46 ` Marek Polacek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox