tests: add test_usleep and test_sleep functions

The former one was already used in tests, but was private.
These functions can be shared across the tests, so make them
public.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Marek Chalupa 2014-11-12 13:14:46 +01:00 committed by Pekka Paalanen
parent 7bf8049c48
commit 6ebe55060e
3 changed files with 44 additions and 15 deletions

View file

@ -333,21 +333,6 @@ register_reading(struct wl_display *display)
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
* it will block */
static pthread_t