summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-02-02 11:37:15 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-02-02 17:19:48 +0000
commit84e824873be4172c0ef51744fc9455bb9c12cc9a (patch)
treef200564af741140c69353eadb0d8f4b7971aec61 /test
parent2bee35a86b77bc7371a81dfa1586398edde56917 (diff)
test/dri2-race: Capture race between window-manger and clients
If the window manager closes the Window before the client disconnects, we can end up with a blocked client as dri2 does not call AttendClient() in its DRI2DrawableGone. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/dri2-race.c223
-rw-r--r--test/dri2-test.c1
2 files changed, 224 insertions, 0 deletions
diff --git a/test/dri2-race.c b/test/dri2-race.c
index c589f2b8..39e2bbd5 100644
--- a/test/dri2-race.c
+++ b/test/dri2-race.c
@@ -221,6 +221,221 @@ static void race_window(Display *dpy, int width, int height,
XSync(dpy, 1);
}
+static void race_manager(Display *dpy, int width, int height,
+ unsigned int *attachments, int nattachments,
+ const char *name)
+{
+ Display *mgr = XOpenDisplay(NULL);
+ Window win;
+ XSetWindowAttributes attr;
+ int count, loop;
+ DRI2Buffer *buffers;
+
+ printf("%s(%s)\n", __func__, name);
+
+ /* Be nasty and install a fullscreen window on top so that we
+ * can guarantee we do not get clipped by children.
+ */
+ attr.override_redirect = 1;
+ loop = 100;
+ do {
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ DefaultDepth(dpy, DefaultScreen(dpy)),
+ InputOutput,
+ DefaultVisual(dpy, DefaultScreen(dpy)),
+ CWOverrideRedirect, &attr);
+ XMapWindow(dpy, win);
+
+ DRI2CreateDrawable(dpy, win);
+
+ buffers = DRI2GetBuffers(dpy, win, &width, &height,
+ attachments, nattachments, &count);
+ if (count != nattachments)
+ return;
+
+ free(buffers);
+ for (count = 0; count < loop; count++)
+ DRI2SwapBuffers(dpy, win, 0, 0, 0);
+ XFlush(dpy);
+ XDestroyWindow(mgr, win);
+ XFlush(mgr);
+ printf("."); fflush(stdout);
+ } while (--loop);
+ printf("*\n");
+
+ loop = 100;
+ do {
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ DefaultDepth(dpy, DefaultScreen(dpy)),
+ InputOutput,
+ DefaultVisual(dpy, DefaultScreen(dpy)),
+ CWOverrideRedirect, &attr);
+ XMapWindow(dpy, win);
+
+ DRI2CreateDrawable(dpy, win);
+
+ buffers = DRI2GetBuffers(dpy, win, &width, &height,
+ attachments, nattachments, &count);
+ if (count != nattachments)
+ return;
+
+ free(buffers);
+ for (count = 0; count < loop; count++)
+ DRI2SwapBuffers(dpy, win, 0, 1, 0);
+ XFlush(dpy);
+ XDestroyWindow(mgr, win);
+ XFlush(mgr);
+ printf("."); fflush(stdout);
+ } while (--loop);
+ printf("*\n");
+
+ loop = 100;
+ do {
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ DefaultDepth(dpy, DefaultScreen(dpy)),
+ InputOutput,
+ DefaultVisual(dpy, DefaultScreen(dpy)),
+ CWOverrideRedirect, &attr);
+ XMapWindow(dpy, win);
+
+ DRI2CreateDrawable(dpy, win);
+
+ buffers = DRI2GetBuffers(dpy, win, &width, &height,
+ attachments, nattachments, &count);
+ if (count != nattachments)
+ return;
+
+ free(buffers);
+ for (count = 0; count < loop; count++)
+ DRI2SwapBuffers(dpy, win, 0, 16, count & 15);
+ XFlush(dpy);
+ XDestroyWindow(mgr, win);
+ XFlush(mgr);
+ printf("."); fflush(stdout);
+ } while (--loop);
+ printf("*\n");
+
+ loop = 100;
+ do {
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ DefaultDepth(dpy, DefaultScreen(dpy)),
+ InputOutput,
+ DefaultVisual(dpy, DefaultScreen(dpy)),
+ CWOverrideRedirect, &attr);
+ XMapWindow(dpy, win);
+
+ DRI2CreateDrawable(dpy, win);
+
+ buffers = DRI2GetBuffers(dpy, win, &width, &height,
+ attachments, nattachments, &count);
+ if (count != nattachments)
+ return;
+
+ free(buffers);
+ for (count = 0; count < loop; count++)
+ swap_buffers(dpy, win, 0, attachments, nattachments);
+ XFlush(dpy);
+ XDestroyWindow(mgr, win);
+ XFlush(mgr);
+ printf("."); fflush(stdout);
+ } while (--loop);
+ printf("*\n");
+
+ loop = 100;
+ do {
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ DefaultDepth(dpy, DefaultScreen(dpy)),
+ InputOutput,
+ DefaultVisual(dpy, DefaultScreen(dpy)),
+ CWOverrideRedirect, &attr);
+ XMapWindow(dpy, win);
+
+ DRI2CreateDrawable(dpy, win);
+
+ buffers = DRI2GetBuffers(dpy, win, &width, &height,
+ attachments, nattachments, &count);
+ if (count != nattachments)
+ return;
+
+ free(buffers);
+ for (count = 0; count < loop; count++)
+ swap_buffers(dpy, win, 1, attachments, nattachments);
+ XFlush(dpy);
+ XDestroyWindow(mgr, win);
+ XFlush(mgr);
+ printf("."); fflush(stdout);
+ } while (--loop);
+ printf("*\n");
+
+ loop = 100;
+ do {
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ DefaultDepth(dpy, DefaultScreen(dpy)),
+ InputOutput,
+ DefaultVisual(dpy, DefaultScreen(dpy)),
+ CWOverrideRedirect, &attr);
+ XMapWindow(dpy, win);
+
+ DRI2CreateDrawable(dpy, win);
+
+ buffers = DRI2GetBuffers(dpy, win, &width, &height,
+ attachments, nattachments, &count);
+ if (count != nattachments)
+ return;
+
+ free(buffers);
+ for (count = 0; count < loop; count++)
+ swap_buffers(dpy, win, 16, attachments, nattachments);
+ XFlush(dpy);
+ XDestroyWindow(mgr, win);
+ XFlush(mgr);
+ printf("."); fflush(stdout);
+ } while (--loop);
+ printf("*\n");
+
+ loop = 100;
+ do {
+ uint64_t ignore, msc;
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ DefaultDepth(dpy, DefaultScreen(dpy)),
+ InputOutput,
+ DefaultVisual(dpy, DefaultScreen(dpy)),
+ CWOverrideRedirect, &attr);
+ XMapWindow(dpy, win);
+
+ DRI2CreateDrawable(dpy, win);
+ DRI2GetMSC(dpy, win, &ignore, &msc, &ignore);
+ for (count = 0; count < loop; count++)
+ xcb_discard_reply(c,
+ xcb_dri2_wait_msc(c, win,
+ upper_32_bits(msc + count + 1),
+ lower_32_bits(msc + count + 1),
+ 0, 1, 0, 0).sequence);
+ XFlush(dpy);
+ XDestroyWindow(mgr, win);
+ XFlush(mgr);
+ printf("."); fflush(stdout);
+ } while (--loop);
+ printf("*\n");
+
+ XSync(dpy, 1);
+ XSync(mgr, 1);
+ sleep(2);
+ XSync(dpy, 1);
+ XSync(mgr, 1);
+
+ XCloseDisplay(mgr);
+}
+
static void race_client(int width, int height,
unsigned int *attachments, int nattachments,
const char *name)
@@ -359,6 +574,10 @@ int main(void)
height = HeightOfScreen(DefaultScreenOfDisplay(dpy));
race_window(dpy, width, height, attachments, 1, "fullscreen");
race_window(dpy, width, height, attachments, 2, "fullscreen (with front)");
+
+ race_manager(dpy, width, height, attachments, 1, "fullscreen");
+ race_manager(dpy, width, height, attachments, 2, "fullscreen (with front)");
+
race_client(width, height, attachments, 1, "fullscreen");
race_client(width, height, attachments, 2, "fullscreen (with front)");
@@ -366,6 +585,10 @@ int main(void)
height /= 2;
race_window(dpy, width, height, attachments, 1, "windowed");
race_window(dpy, width, height, attachments, 2, "windowed (with front)");
+
+ race_manager(dpy, width, height, attachments, 1, "windowed");
+ race_manager(dpy, width, height, attachments, 2, "windowed (with front)");
+
race_client(width, height, attachments, 1, "windowed");
race_client(width, height, attachments, 2, "windowed (with front)");
diff --git a/test/dri2-test.c b/test/dri2-test.c
index 88c0e4c1..d5753050 100644
--- a/test/dri2-test.c
+++ b/test/dri2-test.c
@@ -186,6 +186,7 @@ static void run(Display *dpy, int width, int height,
name, width, height, elapsed(&start, &end));
DRI2SwapInterval(dpy, win, 0);
+ wait_next_vblank(dpy, win);
swap_buffers(c, win, attachments, nattachments);
start_msc = check_msc(dpy, win, end_msc);