mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-07 08:28:01 +02:00
test: abort litest_wait_for_events() if we don't get events after 2s
Previously we kept polling but this just delays what will almost certainly be a failure anyway - none of our tests require even 2000ms for an event to arrive. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
This commit is contained in:
parent
35b223aa8e
commit
978871c450
1 changed files with 17 additions and 1 deletions
|
|
@ -3465,17 +3465,33 @@ _litest_wait_for_event_of_type(struct libinput *li,
|
||||||
fds.events = POLLIN;
|
fds.events = POLLIN;
|
||||||
fds.revents = 0;
|
fds.revents = 0;
|
||||||
|
|
||||||
|
const int timeout = 2000;
|
||||||
|
uint64_t expiry = 0;
|
||||||
|
int rc = now_in_us(&expiry);
|
||||||
|
expiry += ms2us(timeout);
|
||||||
|
litest_assert_errno_success(rc);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
size_t i;
|
size_t i;
|
||||||
struct libinput_event *event;
|
struct libinput_event *event;
|
||||||
|
enum libinput_event_type type;
|
||||||
|
|
||||||
while ((type = libinput_next_event_type(li)) == LIBINPUT_EVENT_NONE) {
|
while ((type = libinput_next_event_type(li)) == LIBINPUT_EVENT_NONE) {
|
||||||
int rc = poll(&fds, 1, 2000);
|
int rc = poll(&fds, 1, timeout);
|
||||||
litest_assert_errno_success(rc);
|
litest_assert_errno_success(rc);
|
||||||
litest_assert_int_gt(rc, 0);
|
litest_assert_int_gt(rc, 0);
|
||||||
libinput_dispatch(li);
|
libinput_dispatch(li);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == LIBINPUT_EVENT_NONE) {
|
||||||
|
uint64_t now;
|
||||||
|
now_in_us(&now);
|
||||||
|
if (now > expiry) {
|
||||||
|
litest_abort_msg("Waited >%dms for events, but no events are pending",
|
||||||
|
timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* no event mask means wait for any event */
|
/* no event mask means wait for any event */
|
||||||
if (ntypes == 0)
|
if (ntypes == 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue