* [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c
@ 2003-11-05 17:56 Michael Elizabeth Chastain
2003-11-05 19:21 ` Elena Zannoni
2003-11-05 19:25 ` Michael Snyder
0 siblings, 2 replies; 5+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-05 17:56 UTC (permalink / raw)
To: gdb-patches
This patch changes gdb.mi/pthreads.c so that it gives repeatable results
under gdb.
Currently, the gdb.mi/mi*-pthreads.exp tests give irregular results
because the call to sleep() will often return prematurely. Thus, many
of the threads exit before the test script can see them. All the
results are PASS, but there are different PASSes on different test runs.
With this patch, all the threads live as long as they are intended to
live, so that the test script sees all the threads.
This patch has a disadvantage. gdb is supposed to work with all kinds
of inferior programs, not just well-written inferior programs.
Arguably, I should live pthreads.c alone, and change the *.exp files to
be more flexible about what they recognize.
I thought about that approach and decided that I like it better if the
test program covers what it is intended to cover (thread backtraces)
even at the expense of other coverage (of nothing particularly useful).
Also, gdb.threads/pthreads.c still has the broken call to sleep()
with no return value checking, so we do still have an instance of this
programming idiom in the test corpus.
My motivation for doing this is that I'm processing two million
test results on every spin, so the more uniform and regular they are,
the less work I have to do. This also helps anyone who compares
test runs with 'diff' or with Andrew's script.
Testing: I'm in the process of testing this. So far it looks okay
but I won't say anything until the test bed finishes.
Anyways ... comments?
Michael C
2003-11-05 Michael Chastain <mec@shout.net>
* gdb.mi/pthreads.c (routine): Handle early return from sleep.
Index: pthreads.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/pthreads.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 pthreads.c
*** pthreads.c 24 Oct 2003 19:55:09 -0000 1.4
--- pthreads.c 5 Nov 2003 17:43:00 -0000
*************** static pthread_attr_t null_attr;
*** 42,48 ****
void *
routine (void *arg)
{
! sleep (9);
printf ("hello thread\n");
}
--- 42,55 ----
void *
routine (void *arg)
{
! /* When gdb is running, it sets hidden breakpoints in the thread
! library. The signals caused by these hidden breakpoints can
! cause system calls such as 'sleep' to return early. Pay attention
! to the return value from 'sleep' to get the full sleep. */
! int unslept = 9;
! while (unslept > 0)
! unslept = sleep (unslept);
!
printf ("hello thread\n");
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c
2003-11-05 17:56 [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c Michael Elizabeth Chastain
@ 2003-11-05 19:21 ` Elena Zannoni
2003-11-05 19:25 ` Michael Snyder
1 sibling, 0 replies; 5+ messages in thread
From: Elena Zannoni @ 2003-11-05 19:21 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: gdb-patches
Michael Elizabeth Chastain writes:
> This patch changes gdb.mi/pthreads.c so that it gives repeatable results
> under gdb.
>
> Currently, the gdb.mi/mi*-pthreads.exp tests give irregular results
> because the call to sleep() will often return prematurely. Thus, many
> of the threads exit before the test script can see them. All the
> results are PASS, but there are different PASSes on different test runs.
>
> With this patch, all the threads live as long as they are intended to
> live, so that the test script sees all the threads.
Thank you! I love this.
>
> This patch has a disadvantage. gdb is supposed to work with all kinds
> of inferior programs, not just well-written inferior programs.
> Arguably, I should live pthreads.c alone, and change the *.exp files to
> be more flexible about what they recognize.
>
Nah, the purpose of the testsuite is to find regressions, and for that
you need repeatable test results.
> I thought about that approach and decided that I like it better if the
> test program covers what it is intended to cover (thread backtraces)
> even at the expense of other coverage (of nothing particularly useful).
> Also, gdb.threads/pthreads.c still has the broken call to sleep()
> with no return value checking, so we do still have an instance of this
> programming idiom in the test corpus.
>
> My motivation for doing this is that I'm processing two million
> test results on every spin, so the more uniform and regular they are,
> the less work I have to do. This also helps anyone who compares
> test runs with 'diff' or with Andrew's script.
>
> Testing: I'm in the process of testing this. So far it looks okay
> but I won't say anything until the test bed finishes.
>
> Anyways ... comments?
I like the comment. ;-)
elena
>
> Michael C
>
> 2003-11-05 Michael Chastain <mec@shout.net>
>
> * gdb.mi/pthreads.c (routine): Handle early return from sleep.
>
> Index: pthreads.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/pthreads.c,v
> retrieving revision 1.4
> diff -c -3 -p -r1.4 pthreads.c
> *** pthreads.c 24 Oct 2003 19:55:09 -0000 1.4
> --- pthreads.c 5 Nov 2003 17:43:00 -0000
> *************** static pthread_attr_t null_attr;
> *** 42,48 ****
> void *
> routine (void *arg)
> {
> ! sleep (9);
> printf ("hello thread\n");
> }
>
> --- 42,55 ----
> void *
> routine (void *arg)
> {
> ! /* When gdb is running, it sets hidden breakpoints in the thread
> ! library. The signals caused by these hidden breakpoints can
> ! cause system calls such as 'sleep' to return early. Pay attention
> ! to the return value from 'sleep' to get the full sleep. */
> ! int unslept = 9;
> ! while (unslept > 0)
> ! unslept = sleep (unslept);
> !
> printf ("hello thread\n");
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c
2003-11-05 17:56 [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c Michael Elizabeth Chastain
2003-11-05 19:21 ` Elena Zannoni
@ 2003-11-05 19:25 ` Michael Snyder
1 sibling, 0 replies; 5+ messages in thread
From: Michael Snyder @ 2003-11-05 19:25 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: gdb-patches
Michael Elizabeth Chastain wrote:
> This patch changes gdb.mi/pthreads.c so that it gives repeatable results
> under gdb.
Great, Michael. This needed doing. Approved, and I would
encourage you to do it to the parent test as well.
>
> Currently, the gdb.mi/mi*-pthreads.exp tests give irregular results
> because the call to sleep() will often return prematurely. Thus, many
> of the threads exit before the test script can see them. All the
> results are PASS, but there are different PASSes on different test runs.
>
> With this patch, all the threads live as long as they are intended to
> live, so that the test script sees all the threads.
>
> This patch has a disadvantage. gdb is supposed to work with all kinds
> of inferior programs, not just well-written inferior programs.
> Arguably, I should live pthreads.c alone, and change the *.exp files to
> be more flexible about what they recognize.
>
> I thought about that approach and decided that I like it better if the
> test program covers what it is intended to cover (thread backtraces)
> even at the expense of other coverage (of nothing particularly useful).
> Also, gdb.threads/pthreads.c still has the broken call to sleep()
> with no return value checking, so we do still have an instance of this
> programming idiom in the test corpus.
>
> My motivation for doing this is that I'm processing two million
> test results on every spin, so the more uniform and regular they are,
> the less work I have to do. This also helps anyone who compares
> test runs with 'diff' or with Andrew's script.
>
> Testing: I'm in the process of testing this. So far it looks okay
> but I won't say anything until the test bed finishes.
>
> Anyways ... comments?
>
> Michael C
>
> 2003-11-05 Michael Chastain <mec@shout.net>
>
> * gdb.mi/pthreads.c (routine): Handle early return from sleep.
>
> Index: pthreads.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/pthreads.c,v
> retrieving revision 1.4
> diff -c -3 -p -r1.4 pthreads.c
> *** pthreads.c 24 Oct 2003 19:55:09 -0000 1.4
> --- pthreads.c 5 Nov 2003 17:43:00 -0000
> *************** static pthread_attr_t null_attr;
> *** 42,48 ****
> void *
> routine (void *arg)
> {
> ! sleep (9);
> printf ("hello thread\n");
> }
>
> --- 42,55 ----
> void *
> routine (void *arg)
> {
> ! /* When gdb is running, it sets hidden breakpoints in the thread
> ! library. The signals caused by these hidden breakpoints can
> ! cause system calls such as 'sleep' to return early. Pay attention
> ! to the return value from 'sleep' to get the full sleep. */
> ! int unslept = 9;
> ! while (unslept > 0)
> ! unslept = sleep (unslept);
> !
> printf ("hello thread\n");
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c
@ 2003-11-06 2:16 Michael Elizabeth Chastain
0 siblings, 0 replies; 5+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-06 2:16 UTC (permalink / raw)
To: gdb-patches, mec
I've committed this patch.
After my next spin, I'll pursue Michael Snyder's suggestion to do
the same thing in gdb.threads/pthreads.c.
It feels good to cut down the clutter in my test reports!
Michael C
===
2003-11-05 Michael Chastain <mec@shout.net>
* gdb.mi/pthreads.c (routine): Handle early return from sleep.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c
@ 2003-11-05 18:04 Michael Elizabeth Chastain
0 siblings, 0 replies; 5+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-05 18:04 UTC (permalink / raw)
To: gdb-patches, mec
mec> My motivation for doing this is that I'm processing two million
mec> test results on every spin,
Think-o. In the interests of accuracy -- it's 0.75 million
results per spin these days.
Can't even read my own reports ...
Michael C
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-11-06 2:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-05 17:56 [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c Michael Elizabeth Chastain
2003-11-05 19:21 ` Elena Zannoni
2003-11-05 19:25 ` Michael Snyder
2003-11-05 18:04 Michael Elizabeth Chastain
2003-11-06 2:16 Michael Elizabeth Chastain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox