Commit Graph

26 Commits

Author SHA1 Message Date
Simon Ser
0d314c4a04 build: don't rely on implicit GNU extensions
Currently libwayland assumes GNU extensions will be available, but
doesn't define the C standard to use. Instead, let's unconditionally
enable POSIX extensions, and enable GNU extensions on a case-by-case
basis as needed.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-01-10 15:08:46 +01:00
Alex Richardson
ed423b8ac6 Allow event-loop signal tests to pass on FreeBSD
On Linux the signal will be immediately visible in the epoll_wait() call.
However, on FreeBSD we may need a small delay between kill() call and the
signal being visible to the kevent() call. This sometimes happens when the
signal processing and kevent processing runs on different CPUs in the
kernel, so becomes more likely when the system is under load (e.g. running
all tests in parallel).

See https://github.com/jiixyj/epoll-shim/pull/32

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
2021-09-10 11:35:54 +00:00
Manuel Stoeckl
2f88814d9b event-loop-test: Add test to verify timer ordering
The new test verifies that, for a set of timers and a short sequence
of timer update calls, when the event loop is run the timer callbacks
are run in the expected order.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2020-01-21 11:31:35 +00:00
Manuel Stoeckl
75d1483457 event-loop-test: Confirm distant timers do not fire
This change expands the `event_loop_timer` test to use two different
timers with different timeouts; it now implicitly checks that e.g.
both timers do not expire at the same time, and that the first timer
expiring does not prevent the second from doing so. (While such failure
modes are unlikely with timer event sources based on individual
timerfds, they are possible when multiple timers share a common timerfd.)

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2020-01-21 11:31:35 +00:00
Manuel Stoeckl
a0d941e411 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>
2020-01-21 11:31:35 +00:00
Michael Forney
55d044810c Use wl_container_of internally
Rather than have two versions of the macro with slightly different
interfaces, just use wl_container_of internally.

This also removes use of statement expressions, a GNU C extension.

Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-05 09:58:14 +00:00
Yong Bakos
2b1c1b2d66 (multiple): Include stdint.h
Some headers and source files have been using types such as uint32_t
without explicitly including stdint.h.

Explicitly include stdint.h where appropriate.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-25 18:39:32 -07:00
Bryce Harrington
773babedfc tests: Update boilerplate from MIT X11 license to MIT Expat license
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-06-12 15:31:24 -07:00
Marek Chalupa
b24fa4c821 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)

https://bugs.freedesktop.org/show_bug.cgi?id=80594

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-19 14:34:50 +03:00
Marek Chalupa
12ec657014 tests: event_loop_timer_updates - add asserts and fix indentation
Make sure the wl_event_source_timer_update suceeded. Also, fix weird
indentation.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-19 14:34:34 +03:00
Marek Chalupa
5bed9e46e7 tests: add one more test for event-loop signal source
Test if when we get a signal, all signal sources for that signal
get dispatched.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-18 13:36:22 +03:00
Marek Chalupa
5504c9338b tests: make event-loop-test more explicit
Check value set in handler against an explicit value instead of:
  assert(value);

also add one assert() for non-NULL value.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-18 12:55:35 +03:00
Jonas Ådahl
591f5ee3b1 event-loop-test: Remove unused variable
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-05-09 14:29:27 -07:00
Andrew Wedgbury
74df22befe test: Add test showing blocking problem when updating timers
I've noticed a blocking problem in Wayland's event-loop code when updating
timer event sources. The problem occurs if you update the timer at a point
after is has expired, but before it has been dispatched, i.e. from an event
callback that happens during the same epoll wakeup.

When the timer is subsequently dispatched, wl_event_source_timer_dispatch
blocks for the duration of the new timeout in its call to read() from the
timer fd (which is the expected behaviour according to the man page for
timerfd_settime).

This isn't too uncommon a scenario - for example, a socket with an associated
timeout timer. You'd typically want to update the timer when reading from the
socket. This is how I noticed the issue, since I was setting a timeout of
1 minute, and saw my server blocking for this duration!

The following patch adds a (currently failing) test case to Wayland's
event-loop-test.c. It demonstrates the problem using two timers, which are
set to expire at the same time. The first timer to receive its expiry
callback updates the other timer with a much larger timeout, which then
causes the test to block for this timeout before calling the second timer's
callback.

As for a fix, I'm not so sure (which is why I thought I'd post the failing
test case first to show what I mean). I notice that it doesn't actually do
anything with the value read from the timerfd socket, which gives the number
of times the timer expired since the last read, or when the timer was last
updated (which blocks if the timer hasn't yet expired). I believe this value
should always read as 1 anyway, since we don't use periodic timers.

A simple fix would be to use the TFD_NONBLOCK option when creating the
timerfd, ensuring that the read call won't block. We'd then have to ignore
the case when the read returns EAGAIN.
2014-04-25 14:08:31 -07:00
U. Artie Eoff
5e096ccc94 event-loop-test: assert non-NULL results
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
Kristian Høgsberg
d94a8722cb server: Make wl_object and wl_resource opaque structs
With the work to add wl_resource accessors and port weston to use them,
we're ready to make wl_resource and wl_object opaque structs.  We keep
wl_buffer in the header for EGL stacks to use, but don't expose it by
default.  In time we'll remove it completely, but for now it provides a
transition paths for code that still uses wl_buffer.

Reviewed-by: Jason Ekstrand<jason@jlekstrand.net>
2013-07-02 15:52:47 -04:00
Jason Ekstrand
2423497b99 Add a destroy signal to the wl_event_loop object 2013-01-15 14:05:27 -05:00
Quentin Glidic
0d2c233e15 test/event-loop: Check readable state on a pipe
When redirecting stdout to a non-readable file makes the test fail as a
false negative
2013-01-11 15:12:45 -05:00
Dylan Noblesmith
b486e3aba5 tests: fix make check for out-of-tree builds
It was failing with missing include files.

While here, destroy the ugly "../src/..." include
paths used in the tests that was just hacking around
this problem in the Makefile:

sed -i s/..\\/src\\/// tests/*.c
2012-06-30 19:58:37 +00:00
Kristian Høgsberg
f42d763cd0 tests: prefix event loop tests with event_loop_ 2012-05-08 09:58:01 -04:00
Kristian Høgsberg
d8dda50d27 tests: assert that mask is zero is post_dispatch callback 2012-05-08 09:57:17 -04:00
Kristian Høgsberg
550e8f3861 tests: Add timerfd test 2012-05-08 09:55:55 -04:00
Kristian Høgsberg
d56af2787e tests: Add signal test case
Doesn't necessarily catch the signalfd bug just fixed, since that only
triggers when an uninitialized int is negative.
2012-05-08 09:41:37 -04:00
Pekka Paalanen
7c0aa1a4a3 tests: plug fd leaks in free_source_with_data
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-04-20 14:58:31 +03:00
Kristian Høgsberg
f48bd0714a tests: Add test case for freeing source with pending data 2012-03-21 10:30:19 -04:00
Ander Conselvan de Oliveira
707623f0cb test: add a unit test for the event loop post dispatch check 2012-03-20 15:49:27 -04:00