xref: /aosp_15_r20/external/libepoxy/test/glx_static.c (revision 706d0b42ae4182339789e08d473a0b312ecdc60f)
1*706d0b42SXin Li /*
2*706d0b42SXin Li  * Copyright © 2013 Intel Corporation
3*706d0b42SXin Li  *
4*706d0b42SXin Li  * Permission is hereby granted, free of charge, to any person obtaining a
5*706d0b42SXin Li  * copy of this software and associated documentation files (the "Software"),
6*706d0b42SXin Li  * to deal in the Software without restriction, including without limitation
7*706d0b42SXin Li  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*706d0b42SXin Li  * and/or sell copies of the Software, and to permit persons to whom the
9*706d0b42SXin Li  * Software is furnished to do so, subject to the following conditions:
10*706d0b42SXin Li  *
11*706d0b42SXin Li  * The above copyright notice and this permission notice (including the next
12*706d0b42SXin Li  * paragraph) shall be included in all copies or substantial portions of the
13*706d0b42SXin Li  * Software.
14*706d0b42SXin Li  *
15*706d0b42SXin Li  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*706d0b42SXin Li  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*706d0b42SXin Li  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*706d0b42SXin Li  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*706d0b42SXin Li  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*706d0b42SXin Li  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*706d0b42SXin Li  * IN THE SOFTWARE.
22*706d0b42SXin Li  */
23*706d0b42SXin Li 
24*706d0b42SXin Li /**
25*706d0b42SXin Li  * @file glx_static.c
26*706d0b42SXin Li  *
27*706d0b42SXin Li  * Simple touch-test of using epoxy when linked statically.  On Linux,
28*706d0b42SXin Li  * the ifunc support we'd like to use has some significant behavior
29*706d0b42SXin Li  * changes depending on whether it's a static build or shared library
30*706d0b42SXin Li  * build.
31*706d0b42SXin Li  *
32*706d0b42SXin Li  * Note that if configured without --enable-static, this test will end
33*706d0b42SXin Li  * up dynamically linked anyway, defeating the test.
34*706d0b42SXin Li  */
35*706d0b42SXin Li 
36*706d0b42SXin Li #include <stdio.h>
37*706d0b42SXin Li #include <assert.h>
38*706d0b42SXin Li #include "epoxy/gl.h"
39*706d0b42SXin Li #include "epoxy/glx.h"
40*706d0b42SXin Li #include <X11/Xlib.h>
41*706d0b42SXin Li #include <dlfcn.h>
42*706d0b42SXin Li 
43*706d0b42SXin Li #include "glx_common.h"
44*706d0b42SXin Li 
45*706d0b42SXin Li int
main(int argc,char ** argv)46*706d0b42SXin Li main(int argc, char **argv)
47*706d0b42SXin Li {
48*706d0b42SXin Li     bool pass = true;
49*706d0b42SXin Li     int val;
50*706d0b42SXin Li 
51*706d0b42SXin Li #if NEEDS_TO_BE_STATIC
52*706d0b42SXin Li     if (dlsym(NULL, "epoxy_glCompileShader")) {
53*706d0b42SXin Li         fputs("glx_static requires epoxy built with --enable-static\n", stderr);
54*706d0b42SXin Li         return 77;
55*706d0b42SXin Li     }
56*706d0b42SXin Li #endif
57*706d0b42SXin Li 
58*706d0b42SXin Li     Display *dpy = get_display_or_skip();
59*706d0b42SXin Li     make_glx_context_current_or_skip(dpy);
60*706d0b42SXin Li 
61*706d0b42SXin Li     glEnable(GL_LIGHTING);
62*706d0b42SXin Li     val = 0;
63*706d0b42SXin Li     glGetIntegerv(GL_LIGHTING, &val);
64*706d0b42SXin Li     if (!val) {
65*706d0b42SXin Li         fputs("Enabling GL_LIGHTING didn't stick.\n", stderr);
66*706d0b42SXin Li         pass = false;
67*706d0b42SXin Li     }
68*706d0b42SXin Li 
69*706d0b42SXin Li     return pass != true;
70*706d0b42SXin Li }
71