1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 2.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative GL State API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es2fNegativeStateApiTests.hpp"
25 #include "es2fApiCase.hpp"
26 #include "gluShaderProgram.hpp"
27 #include "deMemory.h"
28 
29 #include "glwEnums.hpp"
30 #include "glwDefs.hpp"
31 
32 using namespace glw; // GL types
33 
34 namespace deqp
35 {
36 namespace gles2
37 {
38 namespace Functional
39 {
40 
41 using tcu::TestLog;
42 
43 static const char* uniformTestVertSource	=	"uniform mediump vec4 vTest;\n"
44 												"void main (void)\n"
45 												"{\n"
46 												"	gl_Position = vTest;\n"
47 												"}\n\0";
48 static const char* uniformTestFragSource	=	"uniform mediump ivec4 fTest;\n"
49 												"void main (void)\n"
50 												"{\n"
51 												"	gl_FragColor = vec4(fTest);\n"
52 												"}\n\0";
53 
NegativeStateApiTests(Context & context)54 NegativeStateApiTests::NegativeStateApiTests (Context& context)
55 	: TestCaseGroup(context, "state", "Negative GL State API Cases")
56 {
57 }
58 
~NegativeStateApiTests(void)59 NegativeStateApiTests::~NegativeStateApiTests (void)
60 {
61 }
62 
init(void)63 void NegativeStateApiTests::init (void)
64 {
65 	// Enabling & disabling states
66 
67 	ES2F_ADD_API_CASE(enable, "Invalid glEnable() usage",
68 		{
69 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
70 			glEnable(-1);
71 			expectError(GL_INVALID_ENUM);
72 			m_log << TestLog::EndSection;
73 		});
74 	ES2F_ADD_API_CASE(disable, "Invalid glDisable() usage",
75 		{
76 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
77 			glDisable(-1);
78 			expectError(GL_INVALID_ENUM);
79 			m_log << TestLog::EndSection;
80 		});
81 
82 	// Simple state queries
83 
84 	ES2F_ADD_API_CASE(get_booleanv, "Invalid glGetBooleanv() usage",
85 		{
86 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
87 			GLboolean params[1] = { GL_FALSE };
88 			glGetBooleanv(-1, &params[0]);
89 			expectError(GL_INVALID_ENUM);
90 			m_log << TestLog::EndSection;
91 		});
92 	ES2F_ADD_API_CASE(get_floatv, "Invalid glGetFloatv() usage",
93 		{
94 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
95 			GLfloat params[1] = { 0.0f };
96 			glGetFloatv(-1, &params[0]);
97 			expectError(GL_INVALID_ENUM);
98 			m_log << TestLog::EndSection;
99 		});
100 	ES2F_ADD_API_CASE(get_integerv, "Invalid glGetIntegerv() usage",
101 		{
102 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
103 			GLint params[1] = { 0 };
104 			glGetIntegerv(-1, &params[0]);
105 			expectError(GL_INVALID_ENUM);
106 			m_log << TestLog::EndSection;
107 		});
108 	ES2F_ADD_API_CASE(get_string, "Invalid glGetString() usage",
109 		{
110 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
111 			glGetString(0);
112 			expectError(GL_INVALID_ENUM);
113 			m_log << TestLog::EndSection;
114 		});
115 
116 	// Enumerated state queries: Shaders
117 
118 	ES2F_ADD_API_CASE(get_attached_shaders, "Invalid glGetAttachedShaders() usage",
119 		{
120 			GLuint shaders[1]	= { 0 };
121 			GLuint shaderObject = glCreateShader(GL_VERTEX_SHADER);
122 			GLuint program		= glCreateProgram();
123 			GLsizei count[1]	= { -1 };
124 
125 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
126 			glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
127 			expectError(GL_INVALID_VALUE);
128 			m_log << TestLog::EndSection;
129 
130 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
131 			glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
132 			expectError(GL_INVALID_OPERATION);
133 			m_log << TestLog::EndSection;
134 
135 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxCount is less than 0.");
136 			glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
137 			expectError(GL_INVALID_VALUE);
138 			m_log << TestLog::EndSection;
139 
140 			glDeleteShader(shaderObject);
141 			glDeleteProgram(program);
142 		});
143 	ES2F_ADD_API_CASE(get_shaderiv, "Invalid glGetShaderiv() usage",
144 		{
145 			GLboolean shaderCompilerSupported;
146 			glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
147 			if (!shaderCompilerSupported)
148 				m_log << TestLog::Message << "// Shader compiler not supported, always expect GL_INVALID_OPERATION" << TestLog::EndMessage;
149 			else
150 				m_log << TestLog::Message << "// Shader compiler supported" << TestLog::EndMessage;
151 
152 			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
153 			GLuint program	= glCreateProgram();
154 			GLint param[1]	= { -1 };
155 
156 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
157 			glGetShaderiv(shader, -1, &param[0]);
158 			expectError(GL_INVALID_ENUM);
159 			m_log << TestLog::EndSection;
160 
161 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
162 			glGetShaderiv(-1, GL_SHADER_TYPE, &param[0]);
163 			expectError(GL_INVALID_VALUE);
164 			m_log << TestLog::EndSection;
165 
166 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if pname is GL_COMPILE_STATUS, GL_INFO_LOG_LENGTH, or GL_SHADER_SOURCE_LENGTH but a shader compiler is not supported.");
167 			glGetShaderiv(shader, GL_COMPILE_STATUS, &param[0]);
168 			expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
169 			glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &param[0]);
170 			expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
171 			glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &param[0]);
172 			expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
173 			m_log << TestLog::EndSection;
174 
175 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
176 			glGetShaderiv(program, GL_SHADER_TYPE, &param[0]);
177 			expectError(GL_INVALID_OPERATION);
178 			m_log << TestLog::EndSection;
179 
180 			glDeleteShader(shader);
181 			glDeleteProgram(program);
182 		});
183 	ES2F_ADD_API_CASE(get_shader_info_log, "Invalid glGetShaderInfoLog() usage",
184 		{
185 			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
186 			GLuint program	= glCreateProgram();
187 			GLsizei length[1] = { -1 };
188 			char infoLog[128];
189 
190 			deMemset(&infoLog[0], 0, sizeof(infoLog));
191 
192 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
193 			glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
194 			expectError(GL_INVALID_VALUE);
195 			m_log << TestLog::EndSection;
196 
197 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
198 			glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
199 			expectError(GL_INVALID_OPERATION);
200 			m_log << TestLog::EndSection;
201 
202 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
203 			glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
204 			expectError(GL_INVALID_VALUE);
205 			m_log << TestLog::EndSection;
206 
207 			glDeleteShader(shader);
208 			glDeleteProgram(program);
209 		});
210 	ES2F_ADD_API_CASE(get_shader_precision_format, "Invalid glGetShaderPrecisionFormat() usage",
211 		{
212 			GLboolean shaderCompilerSupported;
213 			glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
214 			if (!shaderCompilerSupported)
215 				m_log << TestLog::Message << "// Shader compiler not supported, always expect GL_INVALID_OPERATION" << TestLog::EndMessage;
216 			else
217 				m_log << TestLog::Message << "// Shader compiler supported" << TestLog::EndMessage;
218 
219 			GLint range[2];
220 			range[0] = -1;
221 			range[1] = -1;
222 			GLint precision[1] = { -1 };
223 
224 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
225 			glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
226 			expectError(shaderCompilerSupported ? GL_INVALID_ENUM : GL_INVALID_OPERATION);
227 			glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
228 			expectError(shaderCompilerSupported ? GL_INVALID_ENUM : GL_INVALID_OPERATION);
229 			glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]);
230 			expectError(shaderCompilerSupported ? GL_INVALID_ENUM : GL_INVALID_OPERATION);
231 			m_log << TestLog::EndSection;
232 
233 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a shader compiler is not supported.");
234 			glGetShaderPrecisionFormat (GL_VERTEX_SHADER, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
235 			expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
236 			m_log << TestLog::EndSection;
237 		});
238 	ES2F_ADD_API_CASE(get_shader_source, "Invalid glGetShaderSource() usage",
239 		{
240 			GLsizei length[1] = { -1 };
241 			char source[1] = { 0 };
242 			GLuint program	= glCreateProgram();
243 			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
244 
245 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
246 			glGetShaderSource(-1, 1, &length[0], &source[0]);
247 			expectError(GL_INVALID_VALUE);
248 			m_log << TestLog::EndSection;
249 
250 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
251 			glGetShaderSource(program, 1, &length[0], &source[0]);
252 			expectError(GL_INVALID_OPERATION);
253 			m_log << TestLog::EndSection;
254 
255 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
256 			glGetShaderSource(shader, -1, &length[0], &source[0]);
257 			expectError(GL_INVALID_VALUE);
258 			m_log << TestLog::EndSection;
259 
260 			glDeleteProgram(program);
261 			glDeleteShader(shader);
262 		});
263 
264 	// Enumerated state queries: Programs
265 
266 	ES2F_ADD_API_CASE(get_programiv, "Invalid glGetProgramiv() usage",
267 		{
268 			GLuint program	= glCreateProgram();
269 			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
270 			GLint params[1] = { -1 };
271 
272 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
273 			glGetProgramiv(program, -1, &params[0]);
274 			expectError(GL_INVALID_ENUM);
275 			m_log << TestLog::EndSection;
276 
277 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
278 			glGetProgramiv(-1, GL_LINK_STATUS, &params[0]);
279 			expectError(GL_INVALID_VALUE);
280 			m_log << TestLog::EndSection;
281 
282 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program does not refer to a program object.");
283 			glGetProgramiv(shader, GL_LINK_STATUS, &params[0]);
284 			expectError(GL_INVALID_OPERATION);
285 			m_log << TestLog::EndSection;
286 
287 			glDeleteProgram(program);
288 			glDeleteShader(shader);
289 		});
290 	ES2F_ADD_API_CASE(get_program_info_log, "Invalid glGetProgramInfoLog() usage",
291 		{
292 			GLuint program	= glCreateProgram();
293 			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
294 			GLsizei length[1] = { -1 };
295 			char infoLog[1] = { 0 };
296 
297 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
298 			glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]);
299 			expectError(GL_INVALID_VALUE);
300 			m_log << TestLog::EndSection;
301 
302 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
303 			glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]);
304 			expectError(GL_INVALID_OPERATION);
305 			m_log << TestLog::EndSection;
306 
307 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
308 			glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]);
309 			expectError(GL_INVALID_VALUE);
310 			m_log << TestLog::EndSection;
311 
312 			glDeleteProgram(program);
313 			glDeleteShader(shader);
314 		});
315 
316 	// Enumerated state queries: Shader variables
317 
318 	ES2F_ADD_API_CASE(get_tex_parameterfv, "Invalid glGetTexParameterfv() usage",
319 		{
320 			GLfloat params[1] = { 0.0f };
321 
322 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
323 			glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
324 			expectError(GL_INVALID_ENUM);
325 			glGetTexParameterfv (GL_TEXTURE_2D, -1, &params[0]);
326 			expectError(GL_INVALID_ENUM);
327 			glGetTexParameterfv (-1, -1, &params[0]);
328 			expectError(GL_INVALID_ENUM);
329 			m_log << TestLog::EndSection;
330 		});
331 	ES2F_ADD_API_CASE(get_tex_parameteriv, "Invalid glGetTexParameteriv() usage",
332 		{
333 			GLint params[1] = { -1 };
334 
335 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
336 			glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
337 			expectError(GL_INVALID_ENUM);
338 			glGetTexParameteriv (GL_TEXTURE_2D, -1, &params[0]);
339 			expectError(GL_INVALID_ENUM);
340 			glGetTexParameteriv (-1, -1, &params[0]);
341 			expectError(GL_INVALID_ENUM);
342 			m_log << TestLog::EndSection;
343 		});
344 	ES2F_ADD_API_CASE(get_uniformfv, "Invalid glGetUniformfv() usage",
345 		{
346 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
347 			glUseProgram(program.getProgram());
348 
349 			GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest");	// vec4
350 			GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest");	// ivec4
351 			if (vUnif == -1 || fUnif == -1)
352 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
353 
354 			GLuint shader		= glCreateShader(GL_VERTEX_SHADER);
355 			GLuint programEmpty = glCreateProgram();
356 			GLfloat params[4];
357 
358 			deMemset(&params[0], 0, sizeof(params));
359 
360 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
361 			glGetUniformfv (-1, vUnif, &params[0]);
362 			expectError(GL_INVALID_VALUE);
363 			m_log << TestLog::EndSection;
364 
365 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
366 			glGetUniformfv (shader, vUnif, &params[0]);
367 			expectError(GL_INVALID_OPERATION);
368 			m_log << TestLog::EndSection;
369 
370 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
371 			glGetUniformfv (programEmpty, vUnif, &params[0]);
372 			expectError(GL_INVALID_OPERATION);
373 			m_log << TestLog::EndSection;
374 
375 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
376 			glGetUniformfv (program.getProgram(), de::max(vUnif, fUnif)+1, &params[0]);
377 			expectError(GL_INVALID_OPERATION);
378 			m_log << TestLog::EndSection;
379 
380 			glDeleteShader(shader);
381 			glDeleteProgram(programEmpty);
382 		});
383 	ES2F_ADD_API_CASE(get_uniformiv, "Invalid glGetUniformiv() usage",
384 		{
385 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
386 			glUseProgram(program.getProgram());
387 
388 			GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest");	// vec4
389 			GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest");	// ivec4
390 			if (vUnif == -1 || fUnif == -1)
391 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
392 
393 			GLuint shader		= glCreateShader(GL_VERTEX_SHADER);
394 			GLuint programEmpty = glCreateProgram();
395 			GLint params[4];
396 
397 			deMemset(&params[0], 0, sizeof(params));
398 
399 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
400 			glGetUniformiv (-1, vUnif, &params[0]);
401 			expectError(GL_INVALID_VALUE);
402 			m_log << TestLog::EndSection;
403 
404 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
405 			glGetUniformiv (shader, vUnif, &params[0]);
406 			expectError(GL_INVALID_OPERATION);
407 			m_log << TestLog::EndSection;
408 
409 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
410 			glGetUniformiv (programEmpty, vUnif, &params[0]);
411 			expectError(GL_INVALID_OPERATION);
412 			m_log << TestLog::EndSection;
413 
414 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
415 			glGetUniformiv (program.getProgram(), de::max(vUnif, fUnif)+1, &params[0]);
416 			expectError(GL_INVALID_OPERATION);
417 			m_log << TestLog::EndSection;
418 
419 			glDeleteShader(shader);
420 			glDeleteProgram(programEmpty);
421 		});
422 	ES2F_ADD_API_CASE(get_vertex_attribfv, "Invalid glGetVertexAttribfv() usage",
423 		{
424 			GLfloat params[1];
425 
426 			deMemset(&params[0], 0, sizeof(params));
427 
428 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
429 			glGetVertexAttribfv(0, -1, &params[0]);
430 			expectError(GL_INVALID_ENUM);
431 			m_log << TestLog::EndSection;
432 
433 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
434 			GLint maxVertexAttribs;
435 			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
436 			glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params[0]);
437 			expectError(GL_INVALID_VALUE);
438 			m_log << TestLog::EndSection;
439 		});
440 	ES2F_ADD_API_CASE(get_vertex_attribiv, "Invalid glGetVertexAttribiv() usage",
441 		{
442 			GLint params[1];
443 
444 			deMemset(&params[0], 0, sizeof(params));
445 
446 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
447 			glGetVertexAttribiv(0, -1, &params[0]);
448 			expectError(GL_INVALID_ENUM);
449 			m_log << TestLog::EndSection;
450 
451 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
452 			GLint maxVertexAttribs;
453 			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
454 			glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params[0]);
455 			expectError(GL_INVALID_VALUE);
456 			m_log << TestLog::EndSection;
457 		});
458 	ES2F_ADD_API_CASE(get_vertex_attrib_pointerv, "Invalid glGetVertexAttribPointerv() usage",
459 		{
460 			GLvoid* ptr[1] = { DE_NULL };
461 
462 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
463 			glGetVertexAttribPointerv(0, -1, &ptr[0]);
464 			expectError(GL_INVALID_ENUM);
465 			m_log << TestLog::EndSection;
466 
467 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
468 			GLint maxVertexAttribs;
469 			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
470 			glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
471 			expectError(GL_INVALID_VALUE);
472 			m_log << TestLog::EndSection;
473 		});
474 
475 	// Enumerated state queries: Buffers
476 
477 	ES2F_ADD_API_CASE(get_buffer_parameteriv, "Invalid glGetBufferParameteriv() usage",
478 		{
479 			GLint params[1];
480 			GLuint buf;
481 			glGenBuffers(1, &buf);
482 			glBindBuffer(GL_ARRAY_BUFFER, buf);
483 
484 			deMemset(&params[0], 0, sizeof(params));
485 
486 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or value is not an accepted value.");
487 			glGetBufferParameteriv(-1, GL_BUFFER_SIZE, &params[0]);
488 			expectError(GL_INVALID_ENUM);
489 			glGetBufferParameteriv(GL_ARRAY_BUFFER , -1, &params[0]);
490 			expectError(GL_INVALID_ENUM);
491 			glGetBufferParameteriv(-1, -1, &params[0]);
492 			expectError(GL_INVALID_ENUM);
493 			m_log << TestLog::EndSection;
494 
495 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
496 			glBindBuffer(GL_ARRAY_BUFFER, 0);
497 			glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &params[0]);
498 			expectError(GL_INVALID_OPERATION);
499 			m_log << TestLog::EndSection;
500 
501 			glDeleteBuffers(1, &buf);
502 		});
503 	ES2F_ADD_API_CASE(get_framebuffer_attachment_parameteriv, "Invalid glGetFramebufferAttachmentParameteriv() usage",
504 		{
505 			GLint params[1] = { -1 };
506 			GLuint fbo;
507 			glGenFramebuffers(1, &fbo);
508 			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
509 
510 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
511 			glGetFramebufferAttachmentParameteriv(-1, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &params[0]);
512 			expectError(GL_INVALID_ENUM);
513 			m_log << TestLog::EndSection;
514 
515 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if there is no attached object at the named attachment point and pname is not GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
516 			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);
517 			expectError(GL_INVALID_ENUM);
518 			m_log << TestLog::EndSection;
519 
520 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if the attached object at the named attachment point is incompatible with pname.");
521 			GLint attachmentObjectType = -1;
522 			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentObjectType);
523 			expectError(GL_NO_ERROR);
524 
525 			if (attachmentObjectType == GL_RENDERBUFFER)
526 				glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &params[0]);
527 			else if (attachmentObjectType == GL_TEXTURE)
528 				glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, &params[0]);
529 			else if (attachmentObjectType == GL_NONE)
530 				glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);
531 			else
532 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid return value from glGetFramebufferAttachmentParameteriv()");
533 
534 			expectError(GL_INVALID_ENUM);
535 			m_log << TestLog::EndSection;
536 
537 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default framebuffer object name 0 is bound.");
538 			glBindFramebuffer(GL_FRAMEBUFFER, 0);
539 			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &params[0]);
540 			expectError(GL_INVALID_OPERATION);
541 			m_log << TestLog::EndSection;
542 
543 			glDeleteFramebuffers(1, &fbo);
544 		});
545 	ES2F_ADD_API_CASE(get_renderbuffer_parameteriv, "Invalid glGetRenderbufferParameteriv() usage",
546 		{
547 			GLint params[1];
548 			GLuint rbo;
549 			glGenRenderbuffers(1, &rbo);
550 			glBindRenderbuffer(GL_RENDERBUFFER, rbo);
551 
552 			deMemset(&params[0], 0, sizeof(params));
553 
554 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
555 			glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, &params[0]);
556 			expectError(GL_INVALID_ENUM);
557 			m_log << TestLog::EndSection;
558 
559 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
560 			glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, &params[0]);
561 			expectError(GL_INVALID_ENUM);
562 			m_log << TestLog::EndSection;
563 
564 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved renderbuffer object name 0 is bound.");
565 			glBindRenderbuffer(GL_RENDERBUFFER, 0);
566 			glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &params[0]);
567 			expectError(GL_INVALID_OPERATION);
568 			m_log << TestLog::EndSection;
569 
570 			glDeleteRenderbuffers(1, &rbo);
571 		});
572 
573 	// Enumerated boolean state queries
574 
575 	ES2F_ADD_API_CASE(get_is_enabled, "Invalid glIsEnabled() usage",
576 		{
577 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not an accepted value.");
578 			glIsEnabled(-1);
579 			expectError(GL_INVALID_ENUM);
580 			glIsEnabled(GL_TRIANGLES);
581 			expectError(GL_INVALID_ENUM);
582 			m_log << TestLog::EndSection;
583 		});
584 
585 	// Hints
586 
587 	ES2F_ADD_API_CASE(hint, "Invalid glHint() usage",
588 		{
589 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
590 			glHint(GL_GENERATE_MIPMAP_HINT, -1);
591 			expectError(GL_INVALID_ENUM);
592 			glHint(-1, GL_FASTEST);
593 			expectError(GL_INVALID_ENUM);
594 			glHint(-1, -1);
595 			expectError(GL_INVALID_ENUM);
596 			m_log << TestLog::EndSection;
597 		});
598 
599 	// Named object usage
600 
601 	ES2F_ADD_API_CASE(is_buffer, "Invalid glIsBuffer() usage",
602 		{
603 			GLuint		buffer = 0;
604 			GLboolean	isBuffer;
605 
606 			m_log << TestLog::Section("", "A name returned by glGenBuffers, but not yet associated with a buffer object by calling glBindBuffer, is not the name of a buffer object.");
607 			isBuffer		= glIsBuffer(buffer);
608 			checkBooleans	(isBuffer, GL_FALSE);
609 
610 			glGenBuffers	(1, &buffer);
611 			isBuffer		= glIsBuffer(buffer);
612 			checkBooleans	(isBuffer, GL_FALSE);
613 
614 			glBindBuffer	(GL_ARRAY_BUFFER, buffer);
615 			isBuffer		= glIsBuffer(buffer);
616 			checkBooleans	(isBuffer, GL_TRUE);
617 
618 			glBindBuffer	(GL_ARRAY_BUFFER, 0);
619 			glDeleteBuffers	(1, &buffer);
620 			isBuffer		= glIsBuffer(buffer);
621 			checkBooleans	(isBuffer, GL_FALSE);
622 			m_log << TestLog::EndSection;
623 
624 			expectError			(GL_NO_ERROR);
625 		});
626 	ES2F_ADD_API_CASE(is_framebuffer, "Invalid glIsFramebuffer() usage",
627 		{
628 			GLuint		fbo = 0;
629 			GLboolean	isFbo;
630 
631 			m_log << TestLog::Section("", "A name returned by glGenFramebuffers, but not yet bound through a call to glBindFramebuffer is not the name of a framebuffer object.");
632 			isFbo				= glIsFramebuffer(fbo);
633 			checkBooleans		(isFbo, GL_FALSE);
634 
635 			glGenFramebuffers	(1, &fbo);
636 			isFbo				= glIsFramebuffer(fbo);
637 			checkBooleans		(isFbo, GL_FALSE);
638 
639 			glBindFramebuffer	(GL_FRAMEBUFFER, fbo);
640 			isFbo				= glIsFramebuffer(fbo);
641 			checkBooleans		(isFbo, GL_TRUE);
642 
643 			glBindFramebuffer	(GL_FRAMEBUFFER, 0);
644 			glDeleteFramebuffers(1, &fbo);
645 			isFbo				= glIsFramebuffer(fbo);
646 			checkBooleans		(isFbo, GL_FALSE);
647 			m_log << TestLog::EndSection;
648 
649 			expectError			(GL_NO_ERROR);
650 		});
651 	ES2F_ADD_API_CASE(is_program, "Invalid glIsProgram() usage",
652 		{
653 			GLuint		program = 0;
654 			GLboolean	isProgram;
655 
656 			m_log << TestLog::Section("", "A name created with glCreateProgram, and not yet deleted with glDeleteProgram is a name of a program object.");
657 			isProgram			= glIsProgram(program);
658 			checkBooleans		(isProgram, GL_FALSE);
659 
660 			program				= glCreateProgram();
661 			isProgram			= glIsProgram(program);
662 			checkBooleans		(isProgram, GL_TRUE);
663 
664 			glDeleteProgram		(program);
665 			isProgram			= glIsProgram(program);
666 			checkBooleans		(isProgram, GL_FALSE);
667 			m_log << TestLog::EndSection;
668 
669 			expectError			(GL_NO_ERROR);
670 		});
671 	ES2F_ADD_API_CASE(is_renderbuffer, "Invalid glIsRenderbuffer() usage",
672 		{
673 			GLuint		rbo = 0;
674 			GLboolean	isRbo;
675 
676 			m_log << TestLog::Section("", "A name returned by glGenRenderbuffers, but not yet bound through a call to glBindRenderbuffer or glFramebufferRenderbuffer is not the name of a renderbuffer object.");
677 			isRbo					= glIsRenderbuffer(rbo);
678 			checkBooleans			(isRbo, GL_FALSE);
679 
680 			glGenRenderbuffers		(1, &rbo);
681 			isRbo					= glIsRenderbuffer(rbo);
682 			checkBooleans			(isRbo, GL_FALSE);
683 
684 			glBindRenderbuffer		(GL_RENDERBUFFER, rbo);
685 			isRbo					= glIsRenderbuffer(rbo);
686 			checkBooleans			(isRbo, GL_TRUE);
687 
688 			glBindRenderbuffer		(GL_RENDERBUFFER, 0);
689 			glDeleteRenderbuffers	(1, &rbo);
690 			isRbo					= glIsRenderbuffer(rbo);
691 			checkBooleans			(isRbo, GL_FALSE);
692 			m_log << TestLog::EndSection;
693 
694 			expectError			(GL_NO_ERROR);
695 		});
696 	ES2F_ADD_API_CASE(is_shader, "Invalid glIsShader() usage",
697 		{
698 			GLuint		shader = 0;
699 			GLboolean	isShader;
700 
701 			m_log << TestLog::Section("", "A name created with glCreateShader, and not yet deleted with glDeleteShader is a name of a shader object.");
702 			isShader			= glIsProgram(shader);
703 			checkBooleans		(isShader, GL_FALSE);
704 
705 			shader				= glCreateShader(GL_VERTEX_SHADER);
706 			isShader			= glIsShader(shader);
707 			checkBooleans		(isShader, GL_TRUE);
708 
709 			glDeleteShader		(shader);
710 			isShader			= glIsShader(shader);
711 			checkBooleans		(isShader, GL_FALSE);
712 			m_log << TestLog::EndSection;
713 
714 			expectError			(GL_NO_ERROR);
715 		});
716 	ES2F_ADD_API_CASE(is_texture, "Invalid glIsTexture() usage",
717 		{
718 			GLuint		texture = 0;
719 			GLboolean	isTexture;
720 
721 			m_log << TestLog::Section("", "A name returned by glGenTextures, but not yet bound through a call to glBindTexture is not the name of a texture.");
722 			isTexture			= glIsTexture(texture);
723 			checkBooleans		(isTexture, GL_FALSE);
724 
725 			glGenTextures		(1, &texture);
726 			isTexture			= glIsTexture(texture);
727 			checkBooleans		(isTexture, GL_FALSE);
728 
729 			glBindTexture		(GL_TEXTURE_2D, texture);
730 			isTexture			= glIsTexture(texture);
731 			checkBooleans		(isTexture, GL_TRUE);
732 
733 			glBindTexture		(GL_TEXTURE_2D, 0);
734 			glDeleteTextures	(1, &texture);
735 			isTexture			= glIsTexture(texture);
736 			checkBooleans		(isTexture, GL_FALSE);
737 			m_log << TestLog::EndSection;
738 
739 			expectError			(GL_NO_ERROR);
740 		});
741 }
742 
743 } // Functional
744 } // gles2
745 } // deqp
746