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
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
23 #include "piglit-util-gl.h"
24 #include "piglit-glx-util.h"
27 static bool try_free_context(GLXContext ctx
, enum context_mode mode
,
31 const GLXContextID id
=
32 (mode
!= invalid
) ? glXGetContextIDEXT(ctx
) : None
;
36 glXFreeContextEXT(dpy
, ctx
);
39 pass
= validate_glx_error_code(Success
, -1);
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
49 * Attempt to verify that the context still exists on the server by
50 * trying to import it again.
52 if (mode
!= invalid
&& pass
) {
55 pass
= try_import_context(id
, mode
);
57 fprintf(stderr
, "Context is %s in re-import\n\n",
65 int main(int argc
, char **argv
)
70 GLX_EXT_import_context_setup();
73 ctx
= glXImportContextEXT(dpy
, indirectID
);
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")
84 if (directCtx
!= NULL
) {
85 pass
= try_free_context(directCtx
, direct_rendering
,
86 "a non-imported direct-rendering "
92 pass
= try_free_context(indirectCtx
, indirect_rendering
,
93 "a non-imported indirect-rendering context")
97 pass
= try_free_context(NULL
, invalid
,
98 "a NULL pointer / invalid context")
101 GLX_EXT_import_context_teardown();
103 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);