ARB_ubo/referenced-by-shader: pass if shader compiler moves UBOs between shaders
[piglit.git] / tests / spec / glx_ext_import_context / free-context.c
blob6520d4b84aaca24bfe910aed707d436a985f4bc4
1 /* Copyright © 2011 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 #include "piglit-util-gl.h"
24 #include "piglit-glx-util.h"
25 #include "common.h"
27 static bool try_free_context(GLXContext ctx, enum context_mode mode,
28 const char *extra)
30 bool pass;
31 const GLXContextID id =
32 (mode != invalid) ? glXGetContextIDEXT(ctx) : None;
34 /* Free the context.
36 glXFreeContextEXT(dpy, ctx);
37 XSync(dpy, 0);
39 pass = validate_glx_error_code(Success, -1);
40 if (!pass)
41 fprintf(stderr, "Context is %s in free\n\n", extra);
43 /* The GLX_EXT_import_context spec says:
45 * "glXFreeContext does not free the server-side context
46 * information or the XID associated with the server-side
47 * context."
49 * Attempt to verify that the context still exists on the server by
50 * trying to import it again.
52 if (mode != invalid && pass) {
53 assert(id != None);
55 pass = try_import_context(id, mode);
56 if (!pass)
57 fprintf(stderr, "Context is %s in re-import\n\n",
58 extra);
62 return pass;
65 int main(int argc, char **argv)
67 bool pass = true;
68 GLXContext ctx;
70 GLX_EXT_import_context_setup();
71 get_context_IDs();
73 ctx = glXImportContextEXT(dpy, indirectID);
74 if (ctx == NULL) {
75 fprintf(stderr, "Could not import indirect context.\n");
76 piglit_report_result(PIGLIT_FAIL);
79 pass = try_free_context(ctx, indirect_rendering,
80 "an imported context")
81 && pass;
82 ctx = NULL;
84 if (directCtx != NULL) {
85 pass = try_free_context(directCtx, direct_rendering,
86 "a non-imported direct-rendering "
87 "context")
88 && pass;
89 directCtx = NULL;
92 pass = try_free_context(indirectCtx, indirect_rendering,
93 "a non-imported indirect-rendering context")
94 && pass;
95 indirectCtx = NULL;
97 pass = try_free_context(NULL, invalid,
98 "a NULL pointer / invalid context")
99 && pass;
101 GLX_EXT_import_context_teardown();
103 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
104 return 0;