~ubuntu-branches/ubuntu/trusty/libepoxy/trusty-security

« back to all changes in this revision

Viewing changes to test/egl_has_extension_nocontext.c

  • Committer: Package Import Robot
  • Author(s): Eric Anholt
  • Date: 2014-01-31 16:52:20 UTC
  • Revision ID: package-import@ubuntu.com-20140131165220-667dryh9rgibah2g
Tags: upstream-1.1
Import upstream version 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2013 Intel Corporation
 
3
 *
 
4
 * Permission is hereby granted, free of charge, to any person obtaining a
 
5
 * copy of this software and associated documentation files (the "Software"),
 
6
 * to deal in the Software without restriction, including without limitation
 
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
8
 * and/or sell copies of the Software, and to permit persons to whom the
 
9
 * Software is furnished to do so, subject to the following conditions:
 
10
 *
 
11
 * The above copyright notice and this permission notice (including the next
 
12
 * paragraph) shall be included in all copies or substantial portions of the
 
13
 * Software.
 
14
 *
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 
21
 * IN THE SOFTWARE.
 
22
 */
 
23
 
 
24
/**
 
25
 * @file egl_has_extension_nocontext.c
 
26
 *
 
27
 * Catches a bug in early development where eglGetProcAddress() with
 
28
 * no context bound would fail out in dispatch.
 
29
 */
 
30
 
 
31
#include <stdio.h>
 
32
#include <string.h>
 
33
#include <stdlib.h>
 
34
#include <assert.h>
 
35
#include <err.h>
 
36
#include "epoxy/gl.h"
 
37
#include "epoxy/egl.h"
 
38
 
 
39
#include "egl_common.h"
 
40
 
 
41
int
 
42
main(int argc, char **argv)
 
43
{
 
44
    bool pass = true;
 
45
 
 
46
    EGLDisplay *dpy = get_egl_display_or_skip();
 
47
    const char *extensions = eglQueryString(dpy, EGL_EXTENSIONS);
 
48
    char *first_space;
 
49
    char *an_extension;
 
50
 
 
51
    /* We don't have any extensions guaranteed by the ABI, so for the
 
52
     * touch test we just check if the first one is reported to be there.
 
53
     */
 
54
    first_space = strstr(extensions, " ");
 
55
    if (first_space) {
 
56
        an_extension = strndup(extensions, first_space - extensions);
 
57
    } else {
 
58
        an_extension = strdup(extensions);
 
59
    }
 
60
 
 
61
    if (!epoxy_has_egl_extension(dpy, an_extension))
 
62
        errx(1, "Implementation reported absence of %s", an_extension);
 
63
 
 
64
    free(an_extension);
 
65
 
 
66
    if (epoxy_has_egl_extension(dpy, "GLX_ARB_ham_sandwich"))
 
67
        errx(1, "Implementation reported presence of GLX_ARB_ham_sandwich");
 
68
 
 
69
    return pass != true;
 
70
}