Message ID | 1479117566-17709-3-git-send-email-gustavo@padovan.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Nov 14, 2016 at 06:59:14PM +0900, Gustavo Padovan wrote: > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk> > > If the event never arrives we can timeout with select and end the test. > > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk> > --- > tests/kms_atomic_transition.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c > index 1977993..e693c88 100644 > --- a/tests/kms_atomic_transition.c > +++ b/tests/kms_atomic_transition.c > @@ -296,6 +296,14 @@ static void commit_display(igt_display_t *display, unsigned event_mask, bool non > struct drm_event *e = (void *)buf; > struct drm_event_vblank *vblank = (void *)buf; > uint32_t crtc_id, pipe = I915_MAX_PIPES; > + struct timeval timeout = { .tv_sec = 3, .tv_usec = 0 }; > + fd_set fds; > + > + FD_ZERO(&fds); > + FD_SET(0, &fds); > + FD_SET(display->drm_fd, &fds); > + ret = select(display->drm_fd + 1, &fds, NULL, NULL, &timeout); > + igt_assert(ret > 0); Hm, we have igt_timeout which sends a signal and kills the test if the timeout expires. And drm event reading should be interruptible. That might be an even simpler way to implement this. -Daniel > > ret = read(display->drm_fd, buf, sizeof(buf)); > if (ret < 0 && (errno == EINTR || errno == EAGAIN)) > -- > 2.5.5 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index 1977993..e693c88 100644 --- a/tests/kms_atomic_transition.c +++ b/tests/kms_atomic_transition.c @@ -296,6 +296,14 @@ static void commit_display(igt_display_t *display, unsigned event_mask, bool non struct drm_event *e = (void *)buf; struct drm_event_vblank *vblank = (void *)buf; uint32_t crtc_id, pipe = I915_MAX_PIPES; + struct timeval timeout = { .tv_sec = 3, .tv_usec = 0 }; + fd_set fds; + + FD_ZERO(&fds); + FD_SET(0, &fds); + FD_SET(display->drm_fd, &fds); + ret = select(display->drm_fd + 1, &fds, NULL, NULL, &timeout); + igt_assert(ret > 0); ret = read(display->drm_fd, buf, sizeof(buf)); if (ret < 0 && (errno == EINTR || errno == EAGAIN))