summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-12-02 16:25:02 -0800
committerEric Anholt <eric@anholt.net>2013-12-05 12:38:15 -0800
commit0270c80008e3c6b9f2f5dfba03631f72c7920796 (patch)
tree0f09c960c787fe3a67213f214263d4f983472213 /test
parent111c54992b54f090b63278daa541e29b341bb2ad (diff)
Add support for EGL.
This totally replaces the getprocaddress and dlsym code, which was basically just stubs up until now. The is_glx/is_egl() is also dropped -- they weren't doing anything, and the only false answer they could give is if the dlopen were to fail.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am14
-rw-r--r--test/egl_common.c50
-rw-r--r--test/egl_common.h25
-rw-r--r--test/egl_has_extension_nocontext.c70
-rw-r--r--test/headerguards.c3
5 files changed, 161 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 81263b0..01fdc65 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -20,7 +20,15 @@
EPOXY = $(builddir)/../src/libepoxy.la
-check_LTLIBRARIES = libglx_common.la
+check_LTLIBRARIES = \
+ libegl_common.la \
+ libglx_common.la \
+ $()
+
+libegl_common_la_SOURCES = \
+ egl_common.c \
+ egl_common.h
+ $()
libglx_common_la_SOURCES = \
glx_common.c \
@@ -32,6 +40,7 @@ AM_CPPFLAGS = \
$(X11_CFLAGS)
TESTS = \
+ egl_has_extension_nocontext \
glx_public_api \
glx_glxgetprocaddress_nocontext \
glx_has_extension_nocontext \
@@ -40,6 +49,9 @@ TESTS = \
check_PROGRAMS = $(TESTS)
+egl_has_extension_nocontext_LDFLAGS = $(X11_LIBS) $(EPOXY) libegl_common.la
+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
diff --git a/test/egl_common.c b/test/egl_common.c
new file mode 100644
index 0000000..4cc0409
--- /dev/null
+++ b/test/egl_common.c
@@ -0,0 +1,50 @@
+/*
+ * 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 <err.h>
+#include <epoxy/egl.h>
+
+/**
+ * Do whatever it takes to get us an EGL display for the system.
+ *
+ * This needs to be ported to other window systems.
+ */
+EGLDisplay *
+get_egl_display_or_skip(void)
+{
+ Display *dpy = XOpenDisplay(NULL);
+ EGLint major, minor;
+
+ if (!dpy)
+ errx(77, "couldn't open display\n");
+
+ EGLDisplay *edpy = eglGetDisplay(dpy);
+ if (!edpy)
+ errx(1, "Couldn't get EGL display for X11 Display.\n");
+
+ bool ok = eglInitialize(edpy, &major, &minor);
+ if (!ok)
+ errx(1, "eglInitialize() failed\n");
+
+ return edpy;
+}
diff --git a/test/egl_common.h b/test/egl_common.h
new file mode 100644
index 0000000..1c5963b
--- /dev/null
+++ b/test/egl_common.h
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+EGLDisplay *
+get_egl_display_or_skip(void);
diff --git a/test/egl_has_extension_nocontext.c b/test/egl_has_extension_nocontext.c
new file mode 100644
index 0000000..7f658af
--- /dev/null
+++ b/test/egl_has_extension_nocontext.c
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+/**
+ * @file egl_has_extension_nocontext.c
+ *
+ * Catches a bug in early development where eglGetProcAddress() with
+ * no context bound would fail out in dispatch.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <err.h>
+#include "epoxy/gl.h"
+#include "epoxy/egl.h"
+
+#include "egl_common.h"
+
+int
+main(int argc, char **argv)
+{
+ bool pass = true;
+
+ EGLDisplay *dpy = get_egl_display_or_skip();
+ const char *extensions = eglQueryString(dpy, EGL_EXTENSIONS);
+ char *first_space;
+ char *an_extension;
+
+ /* We don't have any extensions guaranteed by the ABI, so for the
+ * touch test we just check if the first one is reported to be there.
+ */
+ first_space = strstr(extensions, " ");
+ if (first_space) {
+ an_extension = strndup(extensions, first_space - extensions);
+ } else {
+ an_extension = strdup(extensions);
+ }
+
+ if (!epoxy_has_egl_extension(dpy, an_extension))
+ errx(1, "Implementation reported absence of GLX_ARB_get_proc_address");
+
+ free(an_extension);
+
+ if (epoxy_has_egl_extension(dpy, "GLX_ARB_ham_sandwich"))
+ errx(1, "Implementation reported presence of GLX_ARB_ham_sandwich");
+
+ return pass != true;
+}
diff --git a/test/headerguards.c b/test/headerguards.c
index 17e6aef..a270b53 100644
--- a/test/headerguards.c
+++ b/test/headerguards.c
@@ -22,8 +22,11 @@
*/
#include <epoxy/gl.h>
+#include <epoxy/egl.h>
#include <epoxy/glx.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glx.h>