From a0bf3c1f48bc77f508f169d3ec8b64aecc902bc2 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 15 Mar 2016 16:12:56 +0000 Subject: [PATCH] test/present: Catch FPE when notifies are broken If the Xserver reports 10 frames passed instantaneously, flag an error rather than divide by zero. Signed-off-by: Chris Wilson --- test/present-test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/present-test.c b/test/present-test.c index b33fd2e0..af1882a3 100644 --- a/test/present-test.c +++ b/test/present-test.c @@ -248,6 +248,12 @@ static uint64_t msc_interval(Display *dpy, Window win, void *q) free(ev); } while (complete != 2); + printf("10 frame interval: msc=%lld, ust=%lld\n", + (long long)msc, (long long)ust); + XSync(dpy, True); + if (msc == 0) + return 0; + return (ust + msc/2) / msc; } @@ -466,6 +472,10 @@ static int test_future(Display *dpy, Window win, const char *phase, void *Q) _x_error_occurred = 0; interval = msc_interval(dpy, win, Q); + if (interval == 0) { + printf("Zero delay between frames\n"); + return 1; + } pixmap = XCreatePixmap(dpy, win, width, height, depth); msc = flush_flips(dpy, win, pixmap, Q, &ust); @@ -918,6 +928,10 @@ static int test_future_msc(Display *dpy, void *Q) _x_error_occurred = 0; interval = msc_interval(dpy, root, Q); + if (interval == 0) { + printf("Zero delay between frames\n"); + return 1; + } msc = check_msc(dpy, root, Q, 0, &ust); for (n = 1; n <= 10; n++)