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
22 #include "piglit-util-gl.h"
23 #include "piglit-glx-util.h"
26 static bool try_attribute(int attribute
)
28 /* If the attribute is GLX_CONTEXT_CORE_PROFILE_BIT_ARB, use a valid
29 * value for that attribute. This ensures that the attribute is
30 * rejected for the correct reason.
32 const int attribs
[] = {
34 (attribute
== GLX_CONTEXT_PROFILE_MASK_ARB
)
35 ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB
: 0,
41 ctx
= glXCreateContextAttribsARB(dpy
, fbconfig
, NULL
, True
, attribs
);
46 "Created OpenGL context with invalid attribute "
47 "0x%08x, but this should have failed.\n",
49 glXDestroyContext(dpy
, ctx
);
53 /* The GLX_ARB_create_context spec says:
55 * "* If an attribute or attribute value in <attrib_list> is not
56 * recognized (including unrecognized bits in bitmask
57 * attributes), BadValue is generated."
59 if (!validate_glx_error_code(BadValue
, -1)) {
60 fprintf(stderr
, "Attribute = 0x%08x\n", attribute
);
67 int main(int argc
, char **argv
)
69 static const int bad_attributes
[] = {
76 for (int i
= 1; i
< argc
; i
++) {
77 if (!strcmp(argv
[i
], "-auto"))
80 fprintf(stderr
, "Unknown option: %s\n", argv
[i
]);
83 GLX_ARB_create_context_setup();
85 for (i
= 0; i
< ARRAY_SIZE(bad_attributes
); i
++) {
86 pass
= try_attribute(bad_attributes
[i
]) && pass
;
89 /* The GLX_ARB_create_context spec says:
91 * "If GLX_ARB_create_context_profile is not supported, then the
92 * GLX_CONTEXT_PROFILE_MASK_ARB attribute [is] not defined, and
93 * specifying the attribute in <attribList> attribute will
96 if (!piglit_is_glx_extension_supported(dpy
, "GLX_ARB_create_context_profile")) {
97 pass
= try_attribute(GLX_CONTEXT_PROFILE_MASK_ARB
)
101 GLX_ARB_create_context_teardown();
103 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);