[Piglit] [PATCH 04/14] util: Add piglit_is_glx_extension_supported

Brian Paul brianp at vmware.com
Thu Dec 8 16:12:00 PST 2011


On 12/08/2011 04:41 PM, Ian Romanick wrote:
> From: Ian Romanick<ian.d.romanick at intel.com>
>
> Signed-off-by: Ian Romanick<ian.d.romanick at intel.com>
> ---
>   tests/util/piglit-glx-util.c |   14 ++++++++++++--
>   tests/util/piglit-glx-util.h |    1 +
>   2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/tests/util/piglit-glx-util.c b/tests/util/piglit-glx-util.c
> index e9d7977..6bd512f 100644
> --- a/tests/util/piglit-glx-util.c
> +++ b/tests/util/piglit-glx-util.c
> @@ -135,8 +135,8 @@ piglit_get_glx_window(Display *dpy, XVisualInfo *visinfo)
>   	return _piglit_get_glx_window(dpy, visinfo, true);
>   }
>
> -void
> -piglit_require_glx_extension(Display *dpy, const char *name)
> +bool
> +piglit_is_glx_extension_supported(Display *dpy, const char *name)
>   {
>   	const char *glx_extension_list;
>   	int screen = DefaultScreen(dpy);
> @@ -146,6 +146,16 @@ piglit_require_glx_extension(Display *dpy, const char *name)
>   	 */
>   	glx_extension_list = glXQueryExtensionsString(dpy, screen);
>   	if (strstr(glx_extension_list, name) == NULL) {
> +		return false;

It's a little dangerous to use strstr() to test for an extension 
string.  Consider:

     GLX_ARB_create_context
     GLX_ARB_create_context_profile
     GLX_ARB_create_context_robustness

In this example, the later two exts depend on the first one, but who 
knows about the future.

piglit_is_extension_supported() does the right thing.


-Brian


More information about the Piglit mailing list