mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-31 22:25:25 -04:00
tests: use nanosleep instead of usleep
man usleep says that bahaviour of using usleep with SIGALRM signal is unspecified. So create our own usleep that calls nanosleep instead. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
44bf13ba0f
commit
d837741166
1 changed files with 19 additions and 4 deletions
|
|
@ -333,6 +333,21 @@ register_reading(struct wl_display *display)
|
||||||
assert(wl_display_flush(display) >= 0);
|
assert(wl_display_flush(display) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define USEC_TO_NSEC(n) (1000 * (n))
|
||||||
|
|
||||||
|
/* since we are using alarm() and SIGABRT, we can not
|
||||||
|
* use usleep function (see 'man usleep') */
|
||||||
|
static void
|
||||||
|
test_usleep(useconds_t usec)
|
||||||
|
{
|
||||||
|
struct timespec ts = {
|
||||||
|
.tv_sec = 0,
|
||||||
|
.tv_nsec = USEC_TO_NSEC(usec)
|
||||||
|
};
|
||||||
|
|
||||||
|
assert(nanosleep(&ts, NULL) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* create thread that will call prepare+read so that
|
/* create thread that will call prepare+read so that
|
||||||
* it will block */
|
* it will block */
|
||||||
static pthread_t
|
static pthread_t
|
||||||
|
|
@ -349,8 +364,8 @@ create_thread(struct client *c, void *(*func)(void*))
|
||||||
* so call usleep once again after the loop ends - it should
|
* so call usleep once again after the loop ends - it should
|
||||||
* be sufficient... */
|
* be sufficient... */
|
||||||
while (c->display_stopped == 0)
|
while (c->display_stopped == 0)
|
||||||
usleep(500);
|
test_usleep(500);
|
||||||
usleep(10000);
|
test_usleep(10000);
|
||||||
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
@ -517,8 +532,8 @@ threading_read_after_error(void)
|
||||||
|
|
||||||
/* make sure thread is sleeping */
|
/* make sure thread is sleeping */
|
||||||
while (c->display_stopped == 0)
|
while (c->display_stopped == 0)
|
||||||
usleep(500);
|
test_usleep(500);
|
||||||
usleep(10000);
|
test_usleep(10000);
|
||||||
|
|
||||||
assert(wl_display_read_events(c->wl_display) == -1);
|
assert(wl_display_read_events(c->wl_display) == -1);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue