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

Ian Romanick idr at freedesktop.org
Thu Dec 8 17:41:54 PST 2011


On 12/08/2011 04:12 PM, Brian Paul wrote:
> 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.

Yeah, I know.  I've scorned people for that many, many times. :)

I was just moving the existing code around.  I *thought* sent along a 
second patch that actually fixed the problem, but it seems I missed it. 
  I'll send a follow-on patch.

I think I'll make a utility function that just searches an extension 
string for a bit of text.  That way piglit_is_extension_supported, 
piglit_is_glx_extension_supported, and the code in common.c (from this 
patch series) that searches the GLX client extensions call use the same 
code.


More information about the Piglit mailing list