summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac1
-rw-r--r--test/Makefile.am42
-rw-r--r--test/glx_common.c104
-rw-r--r--test/glx_common.h31
-rw-r--r--test/glx_public_api.c103
7 files changed, 285 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 35b14ca..91370fa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,6 +80,7 @@ core
#
configure.lineno
.dirstamp
+test-driver
gl_generated_dispatch.c
gl_generated.h
diff --git a/Makefile.am b/Makefile.am
index 3d8179b..2607558 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,9 +20,9 @@
SUBDIRS = src
-#if HAVE_X11
-#SUBDIRS += test
-#endif
+if HAVE_X11
+SUBDIRS += test
+endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = epoxy.pc
diff --git a/configure.ac b/configure.ac
index f2f137f..36e3b3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,7 @@ AC_CONFIG_FILES([
epoxy.pc
Makefile
src/Makefile
+ test/Makefile
])
AC_OUTPUT
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..e913c82
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,42 @@
+# Copyright 2005 Adam Jackson.
+#
+# 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
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+# ADAM JACKSON 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.
+
+EPOXY = $(builddir)/../src/libepoxy.la
+
+check_LTLIBRARIES = libglx_common.la
+
+libglx_common_la_SOURCES = \
+ glx_common.c \
+ glx_common.h
+ $()
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ $(X11_CFLAGS)
+
+TESTS = \
+ glx_public_api
+ $()
+
+check_PROGRAMS = $(TESTS)
+
+glx_public_api_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la
+glx_public_api_DEPENDENCIES = libglx_common.la
+
diff --git a/test/glx_common.c b/test/glx_common.c
new file mode 100644
index 0000000..1c1b3f5
--- /dev/null
+++ b/test/glx_common.c
@@ -0,0 +1,104 @@
+/*
+ * 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 <X11/Xlib.h>
+#include "epoxy/glx.h"
+
+Display *
+get_display_or_skip(void)
+{
+ Display *dpy = XOpenDisplay(NULL);
+
+ if (!dpy) {
+ fprintf(stderr, "couldn't open display\n");
+ exit(77);
+ }
+
+ return dpy;
+}
+
+static XVisualInfo *
+get_glx_visual(Display *dpy)
+{
+ XVisualInfo *visinfo;
+ int attrib[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ None
+ };
+ int screen = DefaultScreen(dpy);
+
+ visinfo = glXChooseVisual(dpy, screen, attrib);
+ if (visinfo == NULL) {
+ fprintf(stderr,
+ "Couldn't get an RGBA, double-buffered visual\n");
+ exit(1);
+ }
+
+ return visinfo;
+}
+
+static Window
+get_glx_window(Display *dpy, XVisualInfo *visinfo, bool map)
+{
+ XSetWindowAttributes window_attr;
+ unsigned long mask;
+ int screen = DefaultScreen(dpy);
+ Window root_win = RootWindow(dpy, screen);
+ Window win;
+
+ window_attr.background_pixel = 0;
+ window_attr.border_pixel = 0;
+ window_attr.colormap = XCreateColormap(dpy, root_win,
+ visinfo->visual, AllocNone);
+ window_attr.event_mask = StructureNotifyMask | ExposureMask |
+ KeyPressMask;
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+ win = XCreateWindow(dpy, root_win, 0, 0,
+ 10, 10, /* width, height */
+ 0, visinfo->depth, InputOutput,
+ visinfo->visual, mask, &window_attr);
+
+ return win;
+}
+
+void
+make_glx_context_current_or_skip(Display *dpy)
+{
+ GLXContext ctx;
+ XVisualInfo *visinfo = get_glx_visual(dpy);
+ Window win = get_glx_window(dpy, visinfo, false);
+
+ ctx = glXCreateContext(dpy, visinfo, False, True);
+ if (ctx == None) {
+ fprintf(stderr, "glXCreateContext failed\n");
+ exit(1);
+ }
+
+ glXMakeCurrent(dpy, win, ctx);
+}
diff --git a/test/glx_common.h b/test/glx_common.h
new file mode 100644
index 0000000..35882f5
--- /dev/null
+++ b/test/glx_common.h
@@ -0,0 +1,31 @@
+/*
+ * 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 "epoxy/glx.h"
+
+Display *
+get_display_or_skip(void);
+
+GLXContext
+make_glx_context_current_or_skip(Display *dpy);
+
diff --git a/test/glx_public_api.c b/test/glx_public_api.c
new file mode 100644
index 0000000..71cf45c
--- /dev/null
+++ b/test/glx_public_api.c
@@ -0,0 +1,103 @@
+/*
+ * 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 <assert.h>
+#include "epoxy/gl.h"
+#include "epoxy/glx.h"
+#include <X11/Xlib.h>
+
+#include "glx_common.h"
+
+static Display *dpy;
+
+static bool
+test_gl_version(void)
+{
+ int version = epoxy_gl_version();
+ if (version < 12) {
+ fprintf(stderr,
+ "Reported GL version %d, should be at least 12\n",
+ version);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+test_glx_version(void)
+{
+ int version = epoxy_glx_version();
+ 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();
+ make_glx_context_current_or_skip(dpy);
+
+ pass = test_gl_version() && pass;
+ pass = test_glx_version() && pass;
+
+ return pass != true;
+}