summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-12-04 16:00:34 -0800
committerEric Anholt <eric@anholt.net>2013-12-05 12:56:58 -0800
commit20f03e65c45d0f906952c3dd4a2f990d02a8870c (patch)
treee056a4803f85a2a62ef56495f9da666846815745 /test
parenta258cdcffe9ce30eb7c046aa0ed5fe77e19977b7 (diff)
Add a new test for our public API against a core context.
Our extension detection for core is totally broken.
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile.am6
-rw-r--r--test/glx_common.c4
-rw-r--r--test/glx_common.h8
-rw-r--r--test/glx_public_api_core.c167
5 files changed, 183 insertions, 3 deletions
diff --git a/test/.gitignore b/test/.gitignore
index 8377d0e..4e30176 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -2,6 +2,7 @@ egl_has_extension_nocontext
glx_glxgetprocaddress_nocontext
glx_has_extension_nocontext
glx_public_api
+glx_public_api_core
headerguards
*.log
*.trs
diff --git a/test/Makefile.am b/test/Makefile.am
index 01fdc65..4fe2535 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -42,11 +42,14 @@ AM_CPPFLAGS = \
TESTS = \
egl_has_extension_nocontext \
glx_public_api \
+ glx_public_api_core \
glx_glxgetprocaddress_nocontext \
glx_has_extension_nocontext \
headerguards \
$()
+XFAIL_TESTS = glx_public_api_core
+
check_PROGRAMS = $(TESTS)
egl_has_extension_nocontext_LDFLAGS = $(X11_LIBS) $(EPOXY) libegl_common.la
@@ -55,6 +58,9 @@ egl_has_extension_nocontext_DEPENDENCIES = libegl_common.la
glx_public_api_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la
glx_public_api_DEPENDENCIES = libglx_common.la
+glx_public_api_core_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la
+glx_public_api_core_DEPENDENCIES = libglx_common.la
+
glx_glxgetprocaddress_nocontext_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la
glx_glxgetprocaddress_nocontext_DEPENDENCIES = libglx_common.la
diff --git a/test/glx_common.c b/test/glx_common.c
index 1c00a6a..4a1d460 100644
--- a/test/glx_common.c
+++ b/test/glx_common.c
@@ -39,7 +39,7 @@ get_display_or_skip(void)
return dpy;
}
-static XVisualInfo *
+XVisualInfo *
get_glx_visual(Display *dpy)
{
XVisualInfo *visinfo;
@@ -63,7 +63,7 @@ get_glx_visual(Display *dpy)
return visinfo;
}
-static Window
+Window
get_glx_window(Display *dpy, XVisualInfo *visinfo, bool map)
{
XSetWindowAttributes window_attr;
diff --git a/test/glx_common.h b/test/glx_common.h
index 544d3d9..3a2e41d 100644
--- a/test/glx_common.h
+++ b/test/glx_common.h
@@ -30,4 +30,10 @@ GLXContext
make_glx_context_current_or_skip(Display *dpy);
GLXFBConfig
-get_fbconfig_for_visual(XVisualInfo *visinfo);
+get_fbconfig_for_visinfo(Display *dpy, XVisualInfo *visinfo);
+
+XVisualInfo *
+get_glx_visual(Display *dpy);
+
+Window
+get_glx_window(Display *dpy, XVisualInfo *visinfo, bool map);
diff --git a/test/glx_public_api_core.c b/test/glx_public_api_core.c
new file mode 100644
index 0000000..c130d86
--- /dev/null
+++ b/test/glx_public_api_core.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <err.h>
+#include "epoxy/gl.h"
+#include "epoxy/glx.h"
+#include <X11/Xlib.h>
+
+#include "glx_common.h"
+
+static Display *dpy;
+
+static bool
+test_has_extensions(void)
+{
+ int num_extensions;
+
+ glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
+
+ for (int i = 0; i < num_extensions; i++) {
+ char *ext = (char *)glGetStringi(GL_EXTENSIONS, i);
+
+ if (!epoxy_has_gl_extension(ext)) {
+ fprintf(stderr, "GL implementation reported support for %s, "
+ "but epoxy didn't\n", ext);
+ return false;
+ }
+ }
+
+ if (epoxy_has_gl_extension("GL_ARB_ham_sandwich")) {
+ fprintf(stderr, "epoxy implementation reported support for "
+ "GL_ARB_ham_sandwich, but it shouldn't\n");
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+test_gl_version(void)
+{
+ int gl_version, epoxy_version;
+ int major, minor;
+
+ glGetIntegerv(GL_MAJOR_VERSION, &major);
+ glGetIntegerv(GL_MINOR_VERSION, &minor);
+ gl_version = major * 10 + minor;
+
+ if (gl_version < 32) {
+ fprintf(stderr,
+ "Implementation reported GL version %d, should be at least 32\n",
+ gl_version);
+ return false;
+ }
+
+ epoxy_version = epoxy_gl_version();
+ if (epoxy_version != gl_version) {
+ fprintf(stderr,
+ "Epoxy reported GL version %d, should be %d\n",
+ epoxy_version, gl_version);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+test_glx_version(void)
+{
+ int version = epoxy_glx_version(dpy, 0);
+ const char *version_string;
+ int ret;
+ int server_major, server_minor;
+ int client_major, client_minor;
+ int server, client, expected;
+
+ if (version < 13) {
+ fprintf(stderr,
+ "Reported GLX version %d, should be at least 13 "
+ "according to Linux GL ABI\n",
+ version);
+ return false;
+ }
+
+ version_string = glXQueryServerString(dpy, 0, GLX_VERSION);
+ ret = sscanf(version_string, "%d.%d", &server_major, &server_minor);
+ assert(ret == 2);
+ server = server_major * 10 + server_minor;
+
+ version_string = glXGetClientString(dpy, GLX_VERSION);
+ ret = sscanf(version_string, "%d.%d", &client_major, &client_minor);
+ assert(ret == 2);
+ client = client_major * 10 + client_minor;
+
+ if (client < server)
+ expected = client;
+ else
+ expected = server;
+
+ if (version != expected) {
+ fprintf(stderr,
+ "Reported GLX version %d, should be %d (%s)\n",
+ version, expected, version_string);
+ return false;
+ }
+
+ return true;
+}
+
+int
+main(int argc, char **argv)
+{
+ bool pass = true;
+
+ dpy = get_display_or_skip();
+
+ if (!epoxy_has_glx_extension(dpy, 0, "GLX_ARB_create_context_profile"))
+ errx(77, "Test requires GLX_ARB_create_context_profile");
+
+ XVisualInfo *visinfo = get_glx_visual(dpy);
+ Window win = get_glx_window(dpy, visinfo, false);
+ GLXFBConfig config = get_fbconfig_for_visinfo(dpy, visinfo);
+ static const int attribs[] = {
+ GLX_CONTEXT_PROFILE_MASK_ARB,
+ GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
+ GLX_CONTEXT_MAJOR_VERSION_ARB,
+ 3,
+ GLX_CONTEXT_MINOR_VERSION_ARB,
+ 2,
+ None
+ };
+ GLXContext ctx = glXCreateContextAttribsARB(dpy, config, NULL, True,
+ attribs);
+ if (ctx == None)
+ errx(77, "glXCreateContext failed");
+
+ glXMakeCurrent(dpy, win, ctx);
+
+ pass = test_gl_version() && pass;
+ pass = test_glx_version() && pass;
+ pass = test_has_extensions() && pass;
+
+ return pass != true;
+}