event-loop-test: Verify proper timer cancellation
authorManuel Stoeckl <code@mstoeckl.com>
Fri, 3 Jan 2020 19:25:04 +0000 (14:25 -0500)
committerSimon Ser <contact@emersion.fr>
Tue, 21 Jan 2020 11:31:35 +0000 (11:31 +0000)
commita0d941e411820e6d49a528757f53fd0f6ce53f3e
treec49adcb9e3630aaa4930f0f57af147c42bfaa742
parentfab3cb3bfedd649d668e37d81b90c3dbad9f4fad
event-loop-test: Verify proper timer cancellation

The implementation of timer event sources based on timerfds ensured
specific edge-case behavior with regards to removing and updating timers:

Calls to `wl_event_loop_dispatch` will dispatch all timer event sources
that have expired up to that point, with one exception. When multiple
timer event sources are due to be dispatched in a single call of
`wl_event_loop_dispatch`, calling wl_event_source_remove` from within a
timer event source callback will prevent the removed event source's
callback from being called. Note that disarming or updating one of the
later timers that is due to be dispatched, from within a timer callback,
will NOT prevent that timer's callback from being invoked by
`wl_event_loop_dispatch`.

This commit adds a test that verifies the above behavior. (Because
epoll_wait is not documented to return timerfds in chronological order,
(although it does, in practice), the test code does not depend on the
order in which timers are dispatched.)

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
tests/event-loop-test.c