@ -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 ;
}
}