[PATCH wayland 2/4] tests: add timeout test
Marek Chalupa
mchqwerty at gmail.com
Wed Nov 12 02:26:00 PST 2014
Thanks, didn't notice it in man pages before... I'll use nanosleep.
Thanks,
Marek
On 10 November 2014 13:16, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20141112/0f1a1381/attachment.html>
More information about the wayland-devel
mailing list