Commit b24fa4c8 authored by Marek Chalupa's avatar Marek Chalupa Committed by Pekka Paalanen
Browse files

tests: fix event_loop_timer_updates

It may happen that there's some time between the first and the other timer expire.
If epoll_wait is called after the first timer expired and
the other not, it returns only one source to dispatch and therefore
the test fails. To fix that, sleep a while before
wl_event_loop_dispatch() to make sure both timers expired.

To be 100% sure, we could use poll() before calling
wl_event_loop_dispatch(), but that would need modification in libwayland
(need to get the source's fd somehow)

Signed-off-by: default avatarMarek Chalupa <>
Reviewed-by: Pekka Paalanen's avatarPekka Paalanen <>
parent 12ec6570
......@@ -240,6 +240,8 @@ TEST(event_loop_timer)
#define MSEC_TO_USEC(msec) ((msec) * 1000)
struct timer_update_context {
struct wl_event_source *source1, *source2;
int count;
......@@ -291,6 +293,18 @@ TEST(event_loop_timer_updates)
context.count = 0;
/* Since calling the functions between source2's update and
* wl_event_loop_dispatch() takes some time, it may happen
* that only one timer expires until we call epoll_wait.
* This naturally means that only one source is dispatched
* and the test fails. To fix that, sleep 15 ms before
* calling wl_event_loop_dispatch(). That should be enough
* for the second timer to expire.
gettimeofday(&start_time, NULL);
wl_event_loop_dispatch(loop, 20);
gettimeofday(&end_time, NULL);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment