fix the spelling in whole piglit
[piglit.git] / tests / spec / arb_internalformat_query2 / api-errors.c
blob055fa1e23aea58a6c9cbd8df53ee637e48e0c4ee
1 /*
2 * Copyright © 2015 Intel Corporation
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:
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.
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.
24 /**
25 * \file api-errors.c
26 * Verify a handful of error conditions required by the spec.
28 * None of these subtests is large enough to warrant a separate test case.
30 * Equivalent to internalformat_query-api-errors, with testing
31 * GetInternalformati64v and in addition to test that a INVALID_ENUM
32 * is returned with an invalid combination, it also tests that a valid
33 * combination doesn't return an INVALID_ENUM.
35 * The rationale of this is that is really likely that the implementation
36 * of arb_internal_format_query2 would reuse a lot of bits of
37 * arb_internal_format_query, so we want to be sure that a combination
38 * that was invalid with arb_internal_format_query is not considered
39 * invalid by arb_internal_format_query2.
43 #include "common.h"
45 PIGLIT_GL_TEST_CONFIG_BEGIN
47 config.supports_gl_compat_version = 10;
48 config.window_visual = PIGLIT_GL_VISUAL_RGB;
49 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
51 PIGLIT_GL_TEST_CONFIG_END
53 enum piglit_result
54 piglit_display(void)
56 return PIGLIT_FAIL;
59 static bool
60 try(const GLenum *targets, unsigned num_targets,
61 const GLenum *pnames, unsigned num_pnames,
62 GLenum expected_error)
64 GLint params[64];
65 GLint64 params64[64];
66 bool pass = true;
67 unsigned i;
68 unsigned j;
70 for (i = 0; i < num_targets; i++) {
71 for (j = 0; j < num_pnames; j++) {
72 bool this_test;
73 bool this_test64;
75 /* We can use any internalformat, as we are
76 * just checking that the pname/target
77 * combination is or not valid. Knowing if the
78 * internalformat is supported is done on
79 * query2 using INTERNALFORMAT_SUPPORTED
80 * pname*/
82 glGetInternalformativ(targets[i],
83 GL_RGBA,
84 pnames[j],
85 ARRAY_SIZE(params),
86 params);
88 this_test =
89 piglit_check_gl_error(expected_error);
91 glGetInternalformati64v(targets[i],
92 GL_RGBA,
93 pnames[j],
94 ARRAY_SIZE(params),
95 params64);
97 this_test64 =
98 piglit_check_gl_error(expected_error);
100 if (this_test && this_test64)
101 continue;
103 fprintf(stderr,
104 " Failing case was "
105 "target = %s, pname = %s\n",
106 piglit_get_gl_enum_name(targets[i]),
107 piglit_get_gl_enum_name(pnames[j]));
109 if (!this_test)
110 fprintf(stderr,
111 " Calling glGetInternalformativ\n");
112 if (!this_test64)
113 fprintf(stderr,
114 " Calling glGetInternalformati64v\n");
115 pass = false;
119 return pass;
122 void
123 piglit_init(int argc, char **argv)
125 bool pass = true;
127 piglit_require_extension("GL_ARB_framebuffer_object");
128 piglit_require_extension("GL_ARB_internalformat_query2");
130 /* The GL_ARB_internalformat_query2 spec says:
132 * The INVALID_ENUM error is generated if the <target> parameter to
133 * GetInternalformati*v is not one of the targets listed in Table 6.xx.
135 * The INVALID_ENUM error is generated if the <pname> parameter is
136 * not one of the listed possibilities.
138 * So we will test that with all the listed pname/targets, no
139 * error is returned, and that without those, INVALID_ENUM is
140 * returned.
142 pass = try(valid_targets, ARRAY_SIZE(valid_targets),
143 valid_pnames, ARRAY_SIZE(valid_pnames),
144 GL_NO_ERROR)
145 && pass;
147 pass = try(invalid_targets, ARRAY_SIZE(invalid_targets),
148 valid_pnames, ARRAY_SIZE(valid_pnames),
149 GL_INVALID_ENUM)
150 && pass;
152 pass = try(valid_targets, ARRAY_SIZE(valid_targets),
153 invalid_pnames, ARRAY_SIZE(invalid_pnames),
154 GL_INVALID_ENUM)
155 && pass;
157 pass = try(invalid_targets, ARRAY_SIZE(invalid_targets),
158 invalid_pnames, ARRAY_SIZE(invalid_pnames),
159 GL_INVALID_ENUM)
160 && pass;
162 /* The GL_ARB_internalformat_query spec says:
164 * "If the <bufSize> parameter to GetInternalformativ is negative,
165 * then an INVALID_VALUE error is generated."
167 * Although not specified on query2 spec, we understand that
168 * it should be the case, and is a missing on the query2
169 * spec. It is properly checked on all the query2
170 * implementations we tested so far.
172 glGetInternalformativ(valid_targets[0],
173 GL_RGBA,
174 valid_pnames[0],
175 -1, NULL);
176 pass = piglit_check_gl_error(GL_INVALID_VALUE)
177 && pass;
179 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);