diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.gitignore | 2 | ||||
-rw-r--r-- | test/Makefile.am | 17 | ||||
-rw-r--r-- | test/egl_without_glx.c | 113 |
3 files changed, 132 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore index b3e8334..a09d5cb 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,4 +1,6 @@ egl_has_extension_nocontext +egl_gles1_without_glx +egl_gles2_without_glx glx_beginend glx_glxgetprocaddress_nocontext glx_has_extension_nocontext diff --git a/test/Makefile.am b/test/Makefile.am index 60816c6..7f43f26 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -56,11 +56,18 @@ TESTS = \ miscdefines$(EXEEXT) \ $() +XFAIL_TESTS = \ + egl_gles1_without_glx \ + egl_gles2_without_glx \ + $() + check_PROGRAMS = $(TESTS) if BUILD_EGL EGL_TESTS = \ egl_has_extension_nocontext \ + egl_gles1_without_glx \ + egl_gles2_without_glx \ $() EGL_LIBS = libegl_common.la @@ -95,6 +102,16 @@ endif egl_has_extension_nocontext_LDFLAGS = $(X11_LIBS) $(EPOXY) libegl_common.la egl_has_extension_nocontext_DEPENDENCIES = $(EPOXY) libegl_common.la +egl_gles1_without_glx_CPPFLAGS = $(AM_CPPFLAGS) -DGLES_VERSION=1 +egl_gles1_without_glx_SOURCES = egl_without_glx.c +egl_gles1_without_glx_LDFLAGS = $(X11_LIBS) $(EPOXY) $(DLOPEN_LIBS) libegl_common.la +egl_gles1_without_glx_DEPENDENCIES = $(EPOXY) libegl_common.la + +egl_gles2_without_glx_CPPFLAGS = $(AM_CPPFLAGS) -DGLES_VERSION=2 +egl_gles2_without_glx_SOURCES = egl_without_glx.c +egl_gles2_without_glx_LDFLAGS = $(X11_LIBS) $(EPOXY) $(DLOPEN_LIBS) libegl_common.la +egl_gles2_without_glx_DEPENDENCIES = $(EPOXY) libegl_common.la + glx_beginend_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la $(GL_LIBS) glx_beginend_DEPENDENCIES = $(EPOXY) libglx_common.la diff --git a/test/egl_without_glx.c b/test/egl_without_glx.c new file mode 100644 index 0000000..88a6233 --- /dev/null +++ b/test/egl_without_glx.c @@ -0,0 +1,113 @@ +/* + * Copyright © 2014 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_without_glx.c + * + * Tries to test operation of the library on a system with a GLES + * installed but no GLX. This test is varied by the GLES_VERSION + * defined at compile time to test either a GLES1-only or a GLES2-only + * system. + */ + +#define _GNU_SOURCE + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> +#include <err.h> +#include <dlfcn.h> +#include "epoxy/gl.h" +#include "epoxy/egl.h" + +#include "egl_common.h" + +/** + * Wraps the system dlopen(), which libepoxy will end up calling when + * it tries to dlopen() the API libraries, and errors out the + * libraries we're trying to simulate not being installed on the + * system. + */ +void * +dlopen(const char *filename, int flag) +{ + void * (*dlopen_unwrapped)(const char *filename, int flag); + + if (!strcmp(filename, "libGL.so.1")) + return NULL; +#if GLES_VERSION == 2 + if (!strcmp(filename, "libGLESv1_CM.so.1")) + return NULL; +#else + if (!strcmp(filename, "libGLESv2.so.2")) + return NULL; +#endif + + dlopen_unwrapped = dlsym(RTLD_NEXT, "dlopen"); + assert(dlopen_unwrapped); + + return dlopen_unwrapped(filename, flag); +} + +int +main(int argc, char **argv) +{ + bool pass = true; + EGLDisplay *dpy = get_egl_display_or_skip(); + EGLint context_attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, GLES_VERSION, + EGL_NONE + }; + EGLConfig cfg; + EGLint config_attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + EGL_NONE + }; + EGLint count; + EGLContext ctx; + const unsigned char *string; + + if (!epoxy_has_egl_extension(dpy, "EGL_KHR_surfaceless_context")) + errx(77, "Test requires EGL_KHR_surfaceless_context"); + + eglBindAPI(EGL_OPENGL_ES_API); + + if (!eglChooseConfig(dpy, config_attribs, &cfg, 1, &count)) + errx(77, "Couldn't get an EGLConfig\n"); + + ctx = eglCreateContext(dpy, cfg, NULL, context_attribs); + if (!ctx) + errx(77, "Couldn't create a GLES%d context\n", GLES_VERSION); + + eglMakeCurrent(dpy, NULL, NULL, ctx); + + string = glGetString(GL_VERSION); + printf("GL_VERSION: %s\n", string); + + return pass != true; +} |