[Piglit] [PATCH] glx-close-display: New test for reusing GLX after XCloseDisplay.
jfonseca at vmware.com
jfonseca at vmware.com
Fri May 20 03:48:44 PDT 2011
From: José Fonseca <jfonseca at vmware.com>
Exercises an issue reloading LLVM enabled DRI drivers on Fedora 15.
---
tests/all.tests | 1 +
tests/glx/CMakeLists.gl.txt | 1 +
tests/glx/glx-close-display.c | 91 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+), 0 deletions(-)
create mode 100644 tests/glx/glx-close-display.c
diff --git a/tests/all.tests b/tests/all.tests
index a18cbfe..561fc42 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -504,6 +504,7 @@ glx = Group()
add_plain_test(glx, 'glx-copy-sub-buffer')
add_plain_test(glx, 'glx-destroycontext-1')
add_plain_test(glx, 'glx-destroycontext-2')
+add_plain_test(glx, 'glx-close-display')
add_plain_test(glx, 'glx-fbconfig-sanity')
glx['glx-fbconfig-sanity'].runConcurrent = True
add_plain_test(glx, 'glx-fbconfig-compliance')
diff --git a/tests/glx/CMakeLists.gl.txt b/tests/glx/CMakeLists.gl.txt
index c3b2bfc..d364cb2 100644
--- a/tests/glx/CMakeLists.gl.txt
+++ b/tests/glx/CMakeLists.gl.txt
@@ -18,6 +18,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_executable (glx-fbconfig-sanity glx-fbconfig-sanity.c)
add_executable (glx-fbconfig-compliance glx-fbconfig-compliance.c)
add_executable (glx-shader-sharing glx-shader-sharing.c)
+ add_executable (glx-close-display glx-close-display.c)
add_executable (glx-destroycontext-1 glx-destroycontext-1.c)
add_executable (glx-destroycontext-2 glx-destroycontext-2.c)
add_executable (glx-multithread glx-multithread.c)
diff --git a/tests/glx/glx-close-display.c b/tests/glx/glx-close-display.c
new file mode 100644
index 0000000..775fcd3
--- /dev/null
+++ b/tests/glx/glx-close-display.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2011 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Jose Fonseca <jfonseca at vmware.com>
+ *
+ */
+
+
+/** @file glx-closedisplay.c
+ *
+ * Test that calling XCloseDisplay after using GLX context works correctly.
+ */
+
+#include "piglit-util.h"
+#include "piglit-glx-util.h"
+
+/**
+ * Straightforward function to check whether GLX direct rendering is supported
+ * or not.
+ */
+static Bool
+isDirectRendering(void)
+{
+ Display *dpy;
+ GLXContext ctx;
+ GLXFBConfig *configs;
+ GLXFBConfig config;
+ int attribList[] = {
+ GLX_DRAWABLE_TYPE, GLX_USE_GL,
+ GLX_RENDER_TYPE, GLX_USE_GL,
+ GLX_DOUBLEBUFFER,
+ 0
+ };
+ int nitems = 0;
+ Bool result;
+
+ dpy = XOpenDisplay(NULL);
+ if (dpy == NULL) {
+ fprintf(stderr, "couldn't open display\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ configs = glXChooseFBConfig(dpy, 0, attribList, &nitems);
+ if (dpy == NULL) {
+ fprintf(stderr, "couldn't find a matching framebuffer configuration\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ config = configs[0];
+
+ ctx = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, True);
+ result = glXIsDirect(dpy, ctx);
+ glXDestroyContext(dpy, ctx);
+
+ /* This call will cause *_dri.so to be dlclosed and unloaded. */
+ XCloseDisplay(dpy);
+
+ return result;
+}
+
+int
+main(int argc, char **argv)
+{
+ isDirectRendering();
+
+ /* Run a second to exercise reloading the *_dri.so driver. */
+ isDirectRendering();
+
+ piglit_report_result(PIGLIT_PASS);
+
+ return 0;
+}
--
1.7.5.1
More information about the Piglit
mailing list