[PATCH wayland 2/4] tests: add timeout test

Pekka Paalanen ppaalanen at gmail.com
Mon Nov 10 04:16:27 PST 2014


On Fri, 7 Nov 2014 22:08:43 +0200
Giulio Camuffo <giuliocamuffo at gmail.com> wrote:

> Looks good, they fail as expected.
> 
> Reviewed-by: Giulio Camuffo <giuliocamuffo at gmail.com>
> 
> 2014-09-24 15:37 GMT+03:00 Marek Chalupa <mchqwerty at gmail.com>:
> > sanity test if timeouts work.
> >
> > Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> > ---
> >  tests/sanity-test.c | 25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> >
> > diff --git a/tests/sanity-test.c b/tests/sanity-test.c
> > index 46f4f85..5a03e7c 100644
> > --- a/tests/sanity-test.c
> > +++ b/tests/sanity-test.c
> > @@ -29,6 +29,9 @@
> >  #include "test-runner.h"
> >  #include "wayland-util.h"
> >
> > +#define WL_HIDE_DEPRECATED
> > +#include "test-compositor.h"
> > +
> >  extern int leak_check_enabled;
> >
> >  TEST(empty)
> > @@ -125,3 +128,25 @@ TEST(sanity_fd_exec)
> >
> >         exec_fd_leak_check(nr_fds + 2);
> >  }
> > +
> > +FAIL_TEST(timeout_tst)
> > +{
> > +       test_set_timeout(1);
> > +       sleep(2);
> > +}
> > +
> > +static void
> > +client_timeout(void)
> > +{
> > +       test_set_timeout(1);
> > +       sleep(2);
> > +}
> > +
> > +/* test timeout with test-compositor */
> > +FAIL_TEST(tc_timeout_tst)
> > +{
> > +       struct display *d = display_create();
> > +       client_create(d, client_timeout);
> > +       display_run(d);
> > +       display_destroy(d);
> > +}

Unfortunately, this is not guaranteed. 'man alarm' says:
"sleep(3) may be implemented using SIGALRM; mixing calls to alarm()
and sleep(3) is a bad idea."

I suppose we should use nanosleep()?
Like we replaced usleep() with nanosleep() too.


Thanks,
pq


More information about the wayland-devel mailing list