Extend the egl_without_glx test for another quirk of the platform.

Epoxy dlsym()s directly into libEGL instead of using dlsym() on a NULL
handle, so we can't relying on ELF resolution like we do for dlopen().
Instead, just override epoxy's function pointers for the functions
epoxy will call in the process of getting one of these bootstrap
functions.
macos/v1.5.9
Eric Anholt 11 years ago
parent d4ad80fb8e
commit f15c169cad
  1. 6
      test/Makefile.am
  2. 58
      test/egl_without_glx.c

@ -60,6 +60,8 @@ TESTS = \
$() $()
XFAIL_TESTS = \ XFAIL_TESTS = \
egl_gles1_without_glx \
egl_gles2_without_glx \
$() $()
check_PROGRAMS = $(TESTS) check_PROGRAMS = $(TESTS)
@ -103,11 +105,11 @@ endif
egl_has_extension_nocontext_LDADD = $(EPOXY) libegl_common.la $(X11_LIBS) egl_has_extension_nocontext_LDADD = $(EPOXY) libegl_common.la $(X11_LIBS)
egl_gles1_without_glx_CPPFLAGS = $(AM_CPPFLAGS) -DGLES_VERSION=1 egl_gles1_without_glx_CPPFLAGS = $(AM_CPPFLAGS) -DGLES_VERSION=1
egl_gles1_without_glx_SOURCES = egl_without_glx.c egl_gles1_without_glx_SOURCES = egl_without_glx.c egl_without_glx_overrides.c
egl_gles1_without_glx_LDADD = $(EPOXY) $(DLOPEN_LIBS) libegl_common.la $(X11_LIBS) egl_gles1_without_glx_LDADD = $(EPOXY) $(DLOPEN_LIBS) libegl_common.la $(X11_LIBS)
egl_gles2_without_glx_CPPFLAGS = $(AM_CPPFLAGS) -DGLES_VERSION=2 egl_gles2_without_glx_CPPFLAGS = $(AM_CPPFLAGS) -DGLES_VERSION=2
egl_gles2_without_glx_SOURCES = egl_without_glx.c egl_gles2_without_glx_SOURCES = egl_without_glx.c egl_without_glx_overrides.c
egl_gles2_without_glx_LDADD = $(EPOXY) $(DLOPEN_LIBS) libegl_common.la $(X11_LIBS) egl_gles2_without_glx_LDADD = $(EPOXY) $(DLOPEN_LIBS) libegl_common.la $(X11_LIBS)
glx_beginend_LDADD = $(EPOXY) libglx_common.la $(GL_LIBS) $(X11_LIBS) glx_beginend_LDADD = $(EPOXY) libglx_common.la $(GL_LIBS) $(X11_LIBS)

@ -24,10 +24,10 @@
/** /**
* @file egl_without_glx.c * @file egl_without_glx.c
* *
* Tries to test operation of the library on a system with a GLES * Tries to test operation of the library on a GL stack with EGL and
* installed but no GLX. This test is varied by the GLES_VERSION * GLES but no GLX or desktop GL (such as Arm's Mali GLES3 drivers).
* defined at compile time to test either a GLES1-only or a GLES2-only * This test is varied by the GLES_VERSION defined at compile time to
* system. * test either a GLES1-only or a GLES2-only system.
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
@ -70,6 +70,51 @@ dlopen(const char *filename, int flag)
return dlopen_unwrapped(filename, flag); return dlopen_unwrapped(filename, flag);
} }
static EGLenum last_api;
static EGLenum extra_error = EGL_SUCCESS;
/**
* Override of the real libEGL's eglBindAPI to simulate the target
* system's eglBindAPI.
*/
static EGLBoolean
override_eglBindAPI(EGLenum api)
{
void *egl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
EGLBoolean (*real_eglBindAPI)(EGLenum api) = dlsym(egl, "eglBindAPI");
last_api = api;
if (api == EGL_OPENGL_API) {
extra_error = EGL_BAD_PARAMETER;
return EGL_FALSE;
}
assert(real_eglBindAPI);
return real_eglBindAPI(api);
}
/**
* Override of the real libEGL's eglGetError() to feed back the error
* that might have been generated by override_eglBindAPI().
*/
static EGLint
override_eglGetError(void)
{
void *egl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
EGLint (*real_eglGetError)(void) = dlsym(egl, "eglGetError");
if (extra_error != EGL_SUCCESS) {
EGLenum error = extra_error;
extra_error = EGL_SUCCESS;
return error;
}
assert(real_eglGetError);
return real_eglGetError();
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
@ -92,6 +137,9 @@ main(int argc, char **argv)
EGLContext ctx; EGLContext ctx;
const unsigned char *string; const unsigned char *string;
epoxy_eglBindAPI = override_eglBindAPI;
epoxy_eglGetError = override_eglGetError;
if (!epoxy_has_egl_extension(dpy, "EGL_KHR_surfaceless_context")) if (!epoxy_has_egl_extension(dpy, "EGL_KHR_surfaceless_context"))
errx(77, "Test requires EGL_KHR_surfaceless_context"); errx(77, "Test requires EGL_KHR_surfaceless_context");
@ -109,5 +157,7 @@ main(int argc, char **argv)
string = glGetString(GL_VERSION); string = glGetString(GL_VERSION);
printf("GL_VERSION: %s\n", string); printf("GL_VERSION: %s\n", string);
assert(eglGetError() == EGL_SUCCESS);
return pass != true; return pass != true;
} }

Loading…
Cancel
Save