1/*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.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 "es3fNegativeStateApiTests.hpp"
25#include "es3fApiCase.hpp"
26#include "gluShaderProgram.hpp"
27#include "deMemory.h"
28
29#include "glwDefs.hpp"
30#include "glwEnums.hpp"
31
32using namespace glw; // GL types
33
34namespace deqp
35{
36namespace gles3
37{
38namespace Functional
39{
40
41using tcu::TestLog;
42
43static const char* uniformTestVertSource	=	"#version 300 es\n"
44												"uniform mediump vec4 vUnif_vec4;\n"
45												"in mediump vec4 attr;"
46												"layout(shared) uniform Block { mediump vec4 blockVar; };\n"
47												"void main (void)\n"
48												"{\n"
49												"	gl_Position = vUnif_vec4 + blockVar + attr;\n"
50												"}\n\0";
51static const char* uniformTestFragSource	=	"#version 300 es\n"
52												"uniform mediump ivec4 fUnif_ivec4;\n"
53												"uniform mediump uvec4 fUnif_uvec4;\n"
54												"layout(location = 0) out mediump vec4 fragColor;"
55												"void main (void)\n"
56												"{\n"
57												"	fragColor = vec4(vec4(fUnif_ivec4) + vec4(fUnif_uvec4));\n"
58												"}\n\0";
59
60NegativeStateApiTests::NegativeStateApiTests (Context& context)
61	: TestCaseGroup(context, "state", "Negative GL State API Cases")
62{
63}
64
65NegativeStateApiTests::~NegativeStateApiTests (void)
66{
67}
68
69void NegativeStateApiTests::init (void)
70{
71	// Enabling & disabling states
72
73	ES3F_ADD_API_CASE(enable, "Invalid glEnable() usage",
74		{
75			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
76			glEnable(-1);
77			expectError(GL_INVALID_ENUM);
78			m_log << TestLog::EndSection;
79		});
80	ES3F_ADD_API_CASE(disable, "Invalid glDisable() usage",
81		{
82			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
83			glDisable(-1);
84			expectError(GL_INVALID_ENUM);
85			m_log << TestLog::EndSection;
86		});
87
88	// Simple state queries
89
90	ES3F_ADD_API_CASE(get_booleanv, "Invalid glGetBooleanv() usage",
91		{
92			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
93			GLboolean params = GL_FALSE;
94			glGetBooleanv(-1, &params);
95			expectError(GL_INVALID_ENUM);
96			m_log << TestLog::EndSection;
97		});
98	ES3F_ADD_API_CASE(get_floatv, "Invalid glGetFloatv() usage",
99		{
100			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
101			GLfloat params = 0.0f;
102			glGetFloatv(-1, &params);
103			expectError(GL_INVALID_ENUM);
104			m_log << TestLog::EndSection;
105		});
106	ES3F_ADD_API_CASE(get_integerv, "Invalid glGetIntegerv() usage",
107		{
108			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
109			GLint params = -1;
110			glGetIntegerv(-1, &params);
111			expectError(GL_INVALID_ENUM);
112			m_log << TestLog::EndSection;
113		});
114	ES3F_ADD_API_CASE(get_integer64v, "Invalid glGetInteger64v() usage",
115		{
116			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
117			GLint64 params = -1;
118			glGetInteger64v(-1, &params);
119			expectError(GL_INVALID_ENUM);
120			m_log << TestLog::EndSection;
121		});
122	ES3F_ADD_API_CASE(get_integeri_v, "Invalid glGetIntegeri_v() usage",
123		{
124			GLint data = -1;
125			GLint maxUniformBufferBindings;
126
127			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
128			glGetIntegeri_v(-1, 0, &data);
129			expectError(GL_INVALID_ENUM);
130			m_log << TestLog::EndSection;
131
132			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
133			glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
134			expectError(GL_NO_ERROR);
135			glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
136			expectError(GL_INVALID_VALUE);
137			m_log << TestLog::EndSection;
138		});
139	ES3F_ADD_API_CASE(get_integer64i_v, "Invalid glGetInteger64i_v() usage",
140		{
141			GLint64 data = (GLint64)-1;;
142			GLint maxUniformBufferBindings;
143
144			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
145			glGetInteger64i_v(-1, 0, &data);
146			expectError(GL_INVALID_ENUM);
147			m_log << TestLog::EndSection;
148
149			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
150			glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
151			expectError(GL_NO_ERROR);
152			glGetInteger64i_v(GL_UNIFORM_BUFFER_START, maxUniformBufferBindings, &data);
153			expectError(GL_INVALID_VALUE);
154			m_log << TestLog::EndSection;
155		});
156	ES3F_ADD_API_CASE(get_string, "Invalid glGetString() usage",
157		{
158			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
159			glGetString(-1);
160			expectError(GL_INVALID_ENUM);
161			m_log << TestLog::EndSection;
162		});
163	ES3F_ADD_API_CASE(get_stringi, "Invalid glGetStringi() usage",
164		{
165			GLint numExtensions;
166
167			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
168			glGetStringi(-1, 0);
169			expectError(GL_INVALID_ENUM);
170			m_log << TestLog::EndSection;
171
172			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is outside the valid range for indexed state name.");
173			glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
174			glGetStringi(GL_EXTENSIONS, numExtensions);
175			expectError(GL_INVALID_VALUE);
176			m_log << TestLog::EndSection;
177		});
178
179	// Enumerated state queries: Shaders
180
181	ES3F_ADD_API_CASE(get_attached_shaders, "Invalid glGetAttachedShaders() usage",
182		{
183			GLuint shaders[1];
184			GLuint shaderObject = glCreateShader(GL_VERTEX_SHADER);
185			GLuint program		= glCreateProgram();
186			GLsizei count[1];
187
188			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
189			glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
190			expectError(GL_INVALID_VALUE);
191			m_log << TestLog::EndSection;
192
193			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
194			glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
195			expectError(GL_INVALID_OPERATION);
196			m_log << TestLog::EndSection;
197
198			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxCount is less than 0.");
199			glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
200			expectError(GL_INVALID_VALUE);
201			m_log << TestLog::EndSection;
202
203			glDeleteShader(shaderObject);
204			glDeleteProgram(program);
205		});
206	ES3F_ADD_API_CASE(get_shaderiv, "Invalid glGetShaderiv() usage",
207		{
208			GLboolean shaderCompilerSupported;
209			glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
210			m_log << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
211
212			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
213			GLuint program	= glCreateProgram();
214			GLint param[1]	= { -1 };
215
216			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
217			glGetShaderiv(shader, -1, &param[0]);
218			expectError(GL_INVALID_ENUM);
219			m_log << TestLog::EndSection;
220
221			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
222			glGetShaderiv(-1, GL_SHADER_TYPE, &param[0]);
223			expectError(GL_INVALID_VALUE);
224			m_log << TestLog::EndSection;
225
226			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
227			glGetShaderiv(program, GL_SHADER_TYPE, &param[0]);
228			expectError(GL_INVALID_OPERATION);
229			m_log << TestLog::EndSection;
230
231			glDeleteShader(shader);
232			glDeleteProgram(program);
233		});
234	ES3F_ADD_API_CASE(get_shader_info_log, "Invalid glGetShaderInfoLog() usage",
235		{
236			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
237			GLuint program	= glCreateProgram();
238			GLsizei length[1];
239			char infoLog[128];
240
241			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
242			glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
243			expectError(GL_INVALID_VALUE);
244			m_log << TestLog::EndSection;
245
246			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
247			glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
248			expectError(GL_INVALID_OPERATION);
249			m_log << TestLog::EndSection;
250
251			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
252			glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
253			expectError(GL_INVALID_VALUE);
254			m_log << TestLog::EndSection;
255
256			glDeleteShader(shader);
257			glDeleteProgram(program);
258		});
259	ES3F_ADD_API_CASE(get_shader_precision_format, "Invalid glGetShaderPrecisionFormat() usage",
260		{
261			GLboolean shaderCompilerSupported;
262			glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
263			m_log << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
264
265			GLint range[2];
266			GLint precision[1];
267
268			deMemset(&range[0], 0xcd, sizeof(range));
269			deMemset(&precision[0], 0xcd, sizeof(precision));
270
271			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
272			glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
273			expectError(GL_INVALID_ENUM);
274			glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
275			expectError(GL_INVALID_ENUM);
276			glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]);
277			expectError(GL_INVALID_ENUM);
278			m_log << TestLog::EndSection;
279		});
280	ES3F_ADD_API_CASE(get_shader_source, "Invalid glGetShaderSource() usage",
281		{
282			GLsizei length[1];
283			char source[1];
284			GLuint program	= glCreateProgram();
285			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
286
287			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
288			glGetShaderSource(-1, 1, &length[0], &source[0]);
289			expectError(GL_INVALID_VALUE);
290			m_log << TestLog::EndSection;
291
292			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
293			glGetShaderSource(program, 1, &length[0], &source[0]);
294			expectError(GL_INVALID_OPERATION);
295			m_log << TestLog::EndSection;
296
297			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
298			glGetShaderSource(shader, -1, &length[0], &source[0]);
299			expectError(GL_INVALID_VALUE);
300			m_log << TestLog::EndSection;
301
302			glDeleteProgram(program);
303			glDeleteShader(shader);
304		});
305
306	// Enumerated state queries: Programs
307
308	ES3F_ADD_API_CASE(get_programiv, "Invalid glGetProgramiv() usage",
309		{
310			GLuint program	= glCreateProgram();
311			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
312			GLint params[1]	= { -1 };
313
314			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
315			glGetProgramiv(program, -1, &params[0]);
316			expectError(GL_INVALID_ENUM);
317			m_log << TestLog::EndSection;
318
319			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
320			glGetProgramiv(-1, GL_LINK_STATUS, &params[0]);
321			expectError(GL_INVALID_VALUE);
322			m_log << TestLog::EndSection;
323
324			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program does not refer to a program object.");
325			glGetProgramiv(shader, GL_LINK_STATUS, &params[0]);
326			expectError(GL_INVALID_OPERATION);
327			m_log << TestLog::EndSection;
328
329			glDeleteProgram(program);
330			glDeleteShader(shader);
331		});
332	ES3F_ADD_API_CASE(get_program_info_log, "Invalid glGetProgramInfoLog() usage",
333		{
334			GLuint program	= glCreateProgram();
335			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
336			GLsizei length[1];
337			char infoLog[1];
338
339			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
340			glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]);
341			expectError(GL_INVALID_VALUE);
342			m_log << TestLog::EndSection;
343
344			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
345			glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]);
346			expectError(GL_INVALID_OPERATION);
347			m_log << TestLog::EndSection;
348
349			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
350			glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]);
351			expectError(GL_INVALID_VALUE);
352			m_log << TestLog::EndSection;
353
354			glDeleteProgram(program);
355			glDeleteShader(shader);
356		});
357
358	// Enumerated state queries: Shader variables
359
360	ES3F_ADD_API_CASE(get_tex_parameterfv, "Invalid glGetTexParameterfv() usage",
361		{
362			GLfloat params[1];
363
364			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
365			glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
366			expectError(GL_INVALID_ENUM);
367			glGetTexParameterfv (GL_TEXTURE_2D, -1, &params[0]);
368			expectError(GL_INVALID_ENUM);
369			glGetTexParameterfv (-1, -1, &params[0]);
370			expectError(GL_INVALID_ENUM);
371			m_log << TestLog::EndSection;
372		});
373	ES3F_ADD_API_CASE(get_tex_parameteriv, "Invalid glGetTexParameteriv() usage",
374		{
375			GLint params[1];
376
377			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
378			glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
379			expectError(GL_INVALID_ENUM);
380			glGetTexParameteriv (GL_TEXTURE_2D, -1, &params[0]);
381			expectError(GL_INVALID_ENUM);
382			glGetTexParameteriv (-1, -1, &params[0]);
383			expectError(GL_INVALID_ENUM);
384			m_log << TestLog::EndSection;
385		});
386	ES3F_ADD_API_CASE(get_uniformfv, "Invalid glGetUniformfv() usage",
387		{
388			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
389			glUseProgram(program.getProgram());
390
391			GLint unif = glGetUniformLocation(program.getProgram(), "vUnif_vec4");	// vec4
392			if (unif == -1)
393				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
394
395			GLuint shader		= glCreateShader(GL_VERTEX_SHADER);
396			GLuint programEmpty = glCreateProgram();
397			GLfloat params[4];
398
399			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
400			glGetUniformfv (-1, unif, &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			glGetUniformfv (shader, unif, &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			glGetUniformfv (programEmpty, unif, &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			glGetUniformfv (program.getProgram(), -1, &params[0]);
416			expectError(GL_INVALID_OPERATION);
417			m_log << TestLog::EndSection;
418
419			glDeleteShader(shader);
420			glDeleteProgram(programEmpty);
421		});
422	ES3F_ADD_API_CASE(get_uniformiv, "Invalid glGetUniformiv() usage",
423		{
424			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
425			glUseProgram(program.getProgram());
426
427			GLint unif = glGetUniformLocation(program.getProgram(), "fUnif_ivec4");	// ivec4
428			if (unif == -1)
429				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
430
431			GLuint shader		= glCreateShader(GL_VERTEX_SHADER);
432			GLuint programEmpty = glCreateProgram();
433			GLint params[4];
434
435			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
436			glGetUniformiv (-1, unif, &params[0]);
437			expectError(GL_INVALID_VALUE);
438			m_log << TestLog::EndSection;
439
440			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
441			glGetUniformiv (shader, unif, &params[0]);
442			expectError(GL_INVALID_OPERATION);
443			m_log << TestLog::EndSection;
444
445			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
446			glGetUniformiv (programEmpty, unif, &params[0]);
447			expectError(GL_INVALID_OPERATION);
448			m_log << TestLog::EndSection;
449
450			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.");
451			glGetUniformiv (program.getProgram(), -1, &params[0]);
452			expectError(GL_INVALID_OPERATION);
453			m_log << TestLog::EndSection;
454
455			glDeleteShader(shader);
456			glDeleteProgram(programEmpty);
457		});
458	ES3F_ADD_API_CASE(get_uniformuiv, "Invalid glGetUniformuiv() usage",
459		{
460			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
461			glUseProgram(program.getProgram());
462
463			GLint unif = glGetUniformLocation(program.getProgram(), "fUnif_uvec4");	// uvec4
464			if (unif == -1)
465				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
466
467			GLuint shader		= glCreateShader(GL_VERTEX_SHADER);
468			GLuint programEmpty = glCreateProgram();
469			GLuint params[4];
470
471			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
472			glGetUniformuiv (-1, unif, &params[0]);
473			expectError(GL_INVALID_VALUE);
474			m_log << TestLog::EndSection;
475
476			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
477			glGetUniformuiv (shader, unif, &params[0]);
478			expectError(GL_INVALID_OPERATION);
479			m_log << TestLog::EndSection;
480
481			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
482			glGetUniformuiv (programEmpty, unif, &params[0]);
483			expectError(GL_INVALID_OPERATION);
484			m_log << TestLog::EndSection;
485
486			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.");
487			glGetUniformuiv (program.getProgram(), -1, &params[0]);
488			expectError(GL_INVALID_OPERATION);
489			m_log << TestLog::EndSection;
490
491			glDeleteShader(shader);
492			glDeleteProgram(programEmpty);
493		});
494	ES3F_ADD_API_CASE(get_active_uniform, "Invalid glGetActiveUniform() usage",
495		{
496			GLuint				shader				= glCreateShader(GL_VERTEX_SHADER);
497			glu::ShaderProgram	program				(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
498			GLint				numActiveUniforms	= -1;
499
500			glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS,	&numActiveUniforms);
501			m_log << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
502
503			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
504			glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0);
505			expectError(GL_INVALID_VALUE);
506			m_log << TestLog::EndSection;
507
508			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
509			glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0);
510			expectError(GL_INVALID_OPERATION);
511			m_log << TestLog::EndSection;
512
513			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to the number of active uniform variables in program.");
514			glUseProgram(program.getProgram());
515			glGetActiveUniform(program.getProgram(), numActiveUniforms, 0, 0, 0, 0, 0);
516			expectError(GL_INVALID_VALUE);
517			m_log << TestLog::EndSection;
518
519			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
520			glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0);
521			expectError(GL_INVALID_VALUE);
522			m_log << TestLog::EndSection;
523
524			glUseProgram(0);
525			glDeleteShader(shader);
526		});
527	ES3F_ADD_API_CASE(get_active_uniformsiv, "Invalid glGetActiveUniformsiv() usage",
528		{
529			GLuint					shader				= glCreateShader(GL_VERTEX_SHADER);
530			glu::ShaderProgram		program				(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
531			GLuint					dummyUniformIndex	= 1;
532			GLint					dummyParamDst		= -1;
533			GLint					numActiveUniforms	= -1;
534
535			glUseProgram(program.getProgram());
536
537			glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
538			m_log << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
539
540			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
541			glGetActiveUniformsiv(-1, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
542			expectError(GL_INVALID_VALUE);
543			m_log << TestLog::EndSection;
544
545			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
546			glGetActiveUniformsiv(shader, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
547			expectError(GL_INVALID_OPERATION);
548			m_log << TestLog::EndSection;
549
550			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if any value in uniformIndices is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program.");
551			for (int excess = 0; excess <= 2; excess++)
552			{
553				std::vector<GLuint> invalidUniformIndices;
554				invalidUniformIndices.push_back(1);
555				invalidUniformIndices.push_back(numActiveUniforms-1+excess);
556				invalidUniformIndices.push_back(1);
557
558				std::vector<GLint> dummyParamsDst(invalidUniformIndices.size());
559				glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[0]);
560				expectError(excess == 0 ? GL_NO_ERROR : GL_INVALID_VALUE);
561			}
562			m_log << TestLog::EndSection;
563
564			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted token.");
565			glGetActiveUniformsiv(program.getProgram(), 1, &dummyUniformIndex, -1, &dummyParamDst);
566			expectError(GL_INVALID_ENUM);
567			m_log << TestLog::EndSection;
568
569			glUseProgram(0);
570			glDeleteShader(shader);
571		});
572	ES3F_ADD_API_CASE(get_active_uniform_blockiv, "Invalid glGetActiveUniformBlockiv() usage",
573		{
574			glu::ShaderProgram	program			(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
575			GLint				params			= -1;
576			GLint				numActiveBlocks	= -1;
577
578			glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
579			m_log << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
580			expectError		(GL_NO_ERROR);
581
582			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program.");
583			glUseProgram(program.getProgram());
584			expectError(GL_NO_ERROR);
585			glGetActiveUniformBlockiv(program.getProgram(), numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, &params);
586			expectError(GL_INVALID_VALUE);
587			m_log << TestLog::EndSection;
588
589			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
590			glGetActiveUniformBlockiv(program.getProgram(), 0, -1, &params);
591			expectError(GL_INVALID_ENUM);
592			m_log << TestLog::EndSection;
593
594			glUseProgram(0);
595		});
596	ES3F_ADD_API_CASE(get_active_uniform_block_name, "Invalid glGetActiveUniformBlockName() usage",
597		{
598			glu::ShaderProgram	program			(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
599			GLsizei				length			= -1;
600			GLint				numActiveBlocks	= -1;
601			GLchar				uniformBlockName[128];
602
603			deMemset(&uniformBlockName[0], 0, sizeof(uniformBlockName));
604
605			glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
606			m_log << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
607			expectError		(GL_NO_ERROR);
608
609			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program.");
610			glUseProgram(program.getProgram());
611			expectError(GL_NO_ERROR);
612			glGetActiveUniformBlockName(program.getProgram(), numActiveBlocks, (int)sizeof(uniformBlockName), &length, &uniformBlockName[0]);
613			expectError(GL_INVALID_VALUE);
614			m_log << TestLog::EndSection;
615
616			glUseProgram(0);
617		});
618	ES3F_ADD_API_CASE(get_active_attrib, "Invalid glGetActiveAttrib() usage",
619		{
620			GLuint				shader				= glCreateShader(GL_VERTEX_SHADER);
621			glu::ShaderProgram	program				(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
622			GLint				numActiveAttributes	= -1;
623
624			GLsizei				length				= -1;
625			GLint				size				= -1;
626			GLenum				type				= -1;
627			GLchar				name[32];
628
629			deMemset(&name[0], 0, sizeof(name));
630
631			glGetProgramiv	(program.getProgram(), GL_ACTIVE_ATTRIBUTES,	&numActiveAttributes);
632			m_log << TestLog::Message << "// GL_ACTIVE_ATTRIBUTES = " << numActiveAttributes << " (expected 1)." << TestLog::EndMessage;
633
634			glUseProgram(program.getProgram());
635
636			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
637			glGetActiveAttrib(-1, 0, 32, &length, &size, &type, &name[0]);
638			expectError(GL_INVALID_VALUE);
639			m_log << TestLog::EndSection;
640
641			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
642			glGetActiveAttrib(shader, 0, 32, &length, &size, &type, &name[0]);
643			expectError(GL_INVALID_OPERATION);
644			m_log << TestLog::EndSection;
645
646			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_ACTIVE_ATTRIBUTES.");
647			glGetActiveAttrib(program.getProgram(), numActiveAttributes, (int)sizeof(name), &length, &size, &type, &name[0]);
648			expectError(GL_INVALID_VALUE);
649			m_log << TestLog::EndSection;
650
651			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
652			glGetActiveAttrib(program.getProgram(), 0, -1, &length, &size, &type, &name[0]);
653			expectError(GL_INVALID_VALUE);
654			m_log << TestLog::EndSection;
655
656			glUseProgram(0);
657			glDeleteShader(shader);
658		});
659	ES3F_ADD_API_CASE(get_uniform_indices, "Invalid glGetUniformIndices() usage",
660		{
661			GLuint shader			= glCreateShader(GL_VERTEX_SHADER);
662			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
663			GLint numActiveBlocks = -1;
664			const GLchar* uniformName =  "Block.blockVar";
665			GLuint uniformIndices = -1;
666
667			glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
668			m_log << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = "		<< numActiveBlocks			<< TestLog::EndMessage;
669			expectError		(GL_NO_ERROR);
670
671			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is a name of shader object.");
672			glGetUniformIndices(shader, 1, &uniformName, &uniformIndices);
673			expectError(GL_INVALID_OPERATION);
674			m_log << TestLog::EndSection;
675
676			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not name of program or shader object.");
677			GLuint invalid = -1;
678			glGetUniformIndices(invalid, 1, &uniformName, &uniformIndices);
679			expectError(GL_INVALID_VALUE);
680			m_log << TestLog::EndSection;
681
682			glUseProgram(0);
683			glDeleteShader(shader);
684		});
685	ES3F_ADD_API_CASE(get_vertex_attribfv, "Invalid glGetVertexAttribfv() usage",
686		{
687			GLfloat params = 0.0f;
688
689			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
690			glGetVertexAttribfv(0, -1, &params);
691			expectError(GL_INVALID_ENUM);
692			m_log << TestLog::EndSection;
693
694			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
695			GLint maxVertexAttribs;
696			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
697			glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
698			expectError(GL_INVALID_VALUE);
699			m_log << TestLog::EndSection;
700		});
701	ES3F_ADD_API_CASE(get_vertex_attribiv, "Invalid glGetVertexAttribiv() usage",
702		{
703			GLint params = -1;
704
705			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
706			glGetVertexAttribiv(0, -1, &params);
707			expectError(GL_INVALID_ENUM);
708			m_log << TestLog::EndSection;
709
710			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
711			GLint maxVertexAttribs;
712			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
713			glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
714			expectError(GL_INVALID_VALUE);
715			m_log << TestLog::EndSection;
716		});
717	ES3F_ADD_API_CASE(get_vertex_attribi_iv, "Invalid glGetVertexAttribIiv() usage",
718		{
719			GLint params = -1;
720
721			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
722			glGetVertexAttribIiv(0, -1, &params);
723			expectError(GL_INVALID_ENUM);
724			m_log << TestLog::EndSection;
725
726			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
727			GLint maxVertexAttribs;
728			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
729			glGetVertexAttribIiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
730			expectError(GL_INVALID_VALUE);
731			m_log << TestLog::EndSection;
732		});
733	ES3F_ADD_API_CASE(get_vertex_attribi_uiv, "Invalid glGetVertexAttribIuiv() usage",
734		{
735			GLuint params = (GLuint)-1;
736
737			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
738			glGetVertexAttribIuiv(0, -1, &params);
739			expectError(GL_INVALID_ENUM);
740			m_log << TestLog::EndSection;
741
742			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
743			GLint maxVertexAttribs;
744			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
745			glGetVertexAttribIuiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
746			expectError(GL_INVALID_VALUE);
747			m_log << TestLog::EndSection;
748		});
749	ES3F_ADD_API_CASE(get_vertex_attrib_pointerv, "Invalid glGetVertexAttribPointerv() usage",
750		{
751			GLvoid* ptr[1] = { DE_NULL };
752
753			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
754			glGetVertexAttribPointerv(0, -1, &ptr[0]);
755			expectError(GL_INVALID_ENUM);
756			m_log << TestLog::EndSection;
757
758			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
759			GLint maxVertexAttribs;
760			glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
761			glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
762			expectError(GL_INVALID_VALUE);
763			m_log << TestLog::EndSection;
764		});
765	ES3F_ADD_API_CASE(get_frag_data_location, "Invalid glGetFragDataLocation() usage",
766		{
767			GLuint shader	= glCreateShader(GL_VERTEX_SHADER);
768			GLuint program	= glCreateProgram();
769
770			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is the name of a shader object.");
771			glGetFragDataLocation(shader, "gl_FragColor");
772			expectError(GL_INVALID_OPERATION);
773			m_log << TestLog::EndSection;
774
775			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been linked.");
776			glGetFragDataLocation(program, "gl_FragColor");
777			expectError(GL_INVALID_OPERATION);
778			m_log << TestLog::EndSection;
779
780			glDeleteProgram(program);
781			glDeleteShader(shader);
782		});
783
784	// Enumerated state queries: Buffers
785
786	ES3F_ADD_API_CASE(get_buffer_parameteriv, "Invalid glGetBufferParameteriv() usage",
787		{
788			GLint params = -1;
789			GLuint buf;
790			glGenBuffers(1, &buf);
791			glBindBuffer(GL_ARRAY_BUFFER, buf);
792
793			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or value is not an accepted value.");
794			glGetBufferParameteriv(-1, GL_BUFFER_SIZE, &params);
795			expectError(GL_INVALID_ENUM);
796			glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, &params);
797			expectError(GL_INVALID_ENUM);
798			glGetBufferParameteriv(-1, -1, &params);
799			expectError(GL_INVALID_ENUM);
800			m_log << TestLog::EndSection;
801
802			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
803			glBindBuffer(GL_ARRAY_BUFFER, 0);
804			glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &params);
805			expectError(GL_INVALID_OPERATION);
806			m_log << TestLog::EndSection;
807
808			glDeleteBuffers(1, &buf);
809		});
810	ES3F_ADD_API_CASE(get_buffer_parameteri64v, "Invalid glGetBufferParameteri64v() usage",
811		{
812			GLint64 params = -1;
813			GLuint buf;
814			glGenBuffers(1, &buf);
815			glBindBuffer(GL_ARRAY_BUFFER, buf);
816
817			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or value is not an accepted value.");
818			glGetBufferParameteri64v(-1, GL_BUFFER_SIZE, &params);
819			expectError(GL_INVALID_ENUM);
820			glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, &params);
821			expectError(GL_INVALID_ENUM);
822			glGetBufferParameteri64v(-1, -1, &params);
823			expectError(GL_INVALID_ENUM);
824			m_log << TestLog::EndSection;
825
826			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
827			glBindBuffer(GL_ARRAY_BUFFER, 0);
828			glGetBufferParameteri64v(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &params);
829			expectError(GL_INVALID_OPERATION);
830			m_log << TestLog::EndSection;
831
832			glDeleteBuffers(1, &buf);
833		});
834	ES3F_ADD_API_CASE(get_buffer_pointerv, "Invalid glGetBufferPointerv() usage",
835		{
836			GLvoid* params = DE_NULL;
837			GLuint buf;
838			glGenBuffers(1, &buf);
839			glBindBuffer(GL_ARRAY_BUFFER, buf);
840
841			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
842			glGetBufferPointerv(GL_ARRAY_BUFFER, -1, &params);
843			expectError(GL_INVALID_ENUM);
844			glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, &params);
845			expectError(GL_INVALID_ENUM);
846			m_log << TestLog::EndSection;
847
848			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
849			glBindBuffer(GL_ARRAY_BUFFER, 0);
850			glGetBufferPointerv(GL_ARRAY_BUFFER, GL_BUFFER_MAP_POINTER, &params);
851			expectError(GL_INVALID_OPERATION);
852			m_log << TestLog::EndSection;
853
854			glDeleteBuffers(1, &buf);
855		});
856	ES3F_ADD_API_CASE(get_framebuffer_attachment_parameteriv, "Invalid glGetFramebufferAttachmentParameteriv() usage",
857		{
858			GLint params[1] = { -1 };
859			GLuint fbo;
860			GLuint rbo[2];
861
862			glGenFramebuffers			(1, &fbo);
863			glGenRenderbuffers			(2, rbo);
864
865			glBindFramebuffer			(GL_FRAMEBUFFER,	fbo);
866			glBindRenderbuffer			(GL_RENDERBUFFER,	rbo[0]);
867			glRenderbufferStorage		(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 16, 16);
868			glFramebufferRenderbuffer	(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
869			glBindRenderbuffer			(GL_RENDERBUFFER,	rbo[1]);
870			glRenderbufferStorage		(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 16, 16);
871			glFramebufferRenderbuffer	(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
872			glCheckFramebufferStatus	(GL_FRAMEBUFFER);
873			expectError					(GL_NO_ERROR);
874
875			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
876			glGetFramebufferAttachmentParameteriv(-1, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &params[0]);					// TYPE is GL_RENDERBUFFER
877			expectError(GL_INVALID_ENUM);
878			m_log << TestLog::EndSection;
879
880			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
881			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &params[0]);	// TYPE is GL_RENDERBUFFER
882			expectError(GL_INVALID_ENUM);
883			glBindFramebuffer(GL_FRAMEBUFFER, 0);
884			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);					// TYPE is GL_FRAMEBUFFER_DEFAULT
885			expectError(GL_INVALID_ENUM);
886			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
887			m_log << TestLog::EndSection;
888
889			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if attachment is GL_DEPTH_STENCIL_ATTACHMENT and different objects are bound to the depth and stencil attachment points of target.");
890			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);
891			expectError(GL_INVALID_OPERATION);
892			m_log << TestLog::EndSection;
893
894			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME.");
895			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);		// TYPE is GL_NONE
896			expectError(GL_NO_ERROR);
897			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, &params[0]);	// TYPE is GL_NONE
898			expectError(GL_INVALID_OPERATION);
899			m_log << TestLog::EndSection;
900
901			m_log << TestLog::Section("", "GL_INVALID_OPERATION or GL_INVALID_ENUM is generated if attachment is not one of the accepted values for the current binding of target.");
902			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);					// A FBO is bound so GL_BACK is invalid
903			expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
904			glBindFramebuffer(GL_FRAMEBUFFER, 0);
905			glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);		// Default framebuffer is bound so GL_COLOR_ATTACHMENT0 is invalid
906			expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
907			m_log << TestLog::EndSection;
908
909			glDeleteFramebuffers(1, &fbo);
910		});
911	ES3F_ADD_API_CASE(get_renderbuffer_parameteriv, "Invalid glGetRenderbufferParameteriv() usage",
912		{
913			GLint params[1] = { -1 };
914			GLuint rbo;
915			glGenRenderbuffers(1, &rbo);
916			glBindRenderbuffer(GL_RENDERBUFFER, rbo);
917
918			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
919			glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, &params[0]);
920			expectError(GL_INVALID_ENUM);
921			m_log << TestLog::EndSection;
922
923			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
924			glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, &params[0]);
925			expectError(GL_INVALID_ENUM);
926			m_log << TestLog::EndSection;
927
928			glDeleteRenderbuffers(1, &rbo);
929			glBindRenderbuffer(GL_RENDERBUFFER, 0);
930		});
931	ES3F_ADD_API_CASE(get_internalformativ, "Invalid glGetInternalformativ() usage",
932		{
933			GLint params[16];
934
935			deMemset(&params[0], 0xcd, sizeof(params));
936
937			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is negative.");
938			glGetInternalformativ	(GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, &params[0]);
939			expectError				(GL_INVALID_VALUE);
940			m_log << TestLog::EndSection;
941
942			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS.");
943			glGetInternalformativ	(GL_RENDERBUFFER, GL_RGBA8, -1, 16, &params[0]);
944			expectError				(GL_INVALID_ENUM);
945			m_log << TestLog::EndSection;
946
947			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable.");
948			glGetInternalformativ	(GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
949			expectError				(GL_INVALID_ENUM);
950			glGetInternalformativ	(GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
951			expectError				(GL_INVALID_ENUM);
952			m_log << TestLog::EndSection;
953
954			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
955			glGetInternalformativ	(-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
956			expectError				(GL_INVALID_ENUM);
957			glGetInternalformativ	(GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
958			expectError				(GL_INVALID_ENUM);
959			glGetInternalformativ	(GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
960			expectError				(GL_INVALID_ENUM);
961			m_log << TestLog::EndSection;
962		});
963
964	// Query object queries
965
966	ES3F_ADD_API_CASE(get_queryiv, "Invalid glGetQueryiv() usage",
967		{
968			GLint params = -1;
969
970			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
971			glGetQueryiv	(GL_ANY_SAMPLES_PASSED, -1, &params);
972			expectError		(GL_INVALID_ENUM);
973			glGetQueryiv	(-1, GL_CURRENT_QUERY, &params);
974			expectError		(GL_INVALID_ENUM);
975			glGetQueryiv	(-1, -1, &params);
976			expectError		(GL_INVALID_ENUM);
977			m_log << TestLog::EndSection;
978		});
979	ES3F_ADD_API_CASE(get_query_objectuiv, "Invalid glGetQueryObjectuiv() usage",
980		{
981			GLuint params	= -1;
982			GLuint id;
983			glGenQueries		(1, &id);
984
985			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is not the name of a query object.");
986			glGetQueryObjectuiv	(-1, GL_QUERY_RESULT_AVAILABLE, &params);
987			expectError			(GL_INVALID_OPERATION);
988			m_log << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage;
989			glGetQueryObjectuiv	(id, GL_QUERY_RESULT_AVAILABLE, &params);
990			expectError			(GL_INVALID_OPERATION);
991			m_log << TestLog::EndSection;
992
993			glBeginQuery		(GL_ANY_SAMPLES_PASSED, id);
994			glEndQuery			(GL_ANY_SAMPLES_PASSED);
995
996			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
997			glGetQueryObjectuiv	(id, -1, &params);
998			expectError			(GL_INVALID_ENUM);
999			m_log << TestLog::EndSection;
1000
1001			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is the name of a currently active query object.");
1002			glBeginQuery		(GL_ANY_SAMPLES_PASSED, id);
1003			expectError			(GL_NO_ERROR);
1004			glGetQueryObjectuiv	(id, GL_QUERY_RESULT_AVAILABLE, &params);
1005			expectError			(GL_INVALID_OPERATION);
1006			glEndQuery			(GL_ANY_SAMPLES_PASSED);
1007			expectError			(GL_NO_ERROR);
1008			m_log << TestLog::EndSection;
1009
1010			glDeleteQueries		(1, &id);
1011		});
1012
1013	// Sync object queries
1014
1015	ES3F_ADD_API_CASE(get_synciv, "Invalid glGetSynciv() usage",
1016		{
1017			GLsizei length	= -1;
1018			GLint	values[32];
1019			GLsync	sync;
1020
1021			deMemset(&values[0], 0xcd, sizeof(values));
1022
1023			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
1024			glGetSynciv	(0, GL_OBJECT_TYPE, 32, &length, &values[0]);
1025			expectError	(GL_INVALID_VALUE);
1026			m_log << TestLog::EndSection;
1027
1028			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1029			sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1030			expectError	(GL_NO_ERROR);
1031			glGetSynciv	(sync, -1, 32, &length, &values[0]);
1032			expectError	(GL_INVALID_ENUM);
1033			m_log << TestLog::EndSection;
1034		});
1035
1036	// Enumerated boolean state queries
1037
1038	ES3F_ADD_API_CASE(is_enabled, "Invalid glIsEnabled() usage",
1039		{
1040			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not an accepted value.");
1041			glIsEnabled(-1);
1042			expectError(GL_INVALID_ENUM);
1043			glIsEnabled(GL_TRIANGLES);
1044			expectError(GL_INVALID_ENUM);
1045			m_log << TestLog::EndSection;
1046		});
1047
1048	// Hints
1049
1050	ES3F_ADD_API_CASE(hint, "Invalid glHint() usage",
1051		{
1052			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
1053			glHint(GL_GENERATE_MIPMAP_HINT, -1);
1054			expectError(GL_INVALID_ENUM);
1055			glHint(-1, GL_FASTEST);
1056			expectError(GL_INVALID_ENUM);
1057			glHint(-1, -1);
1058			expectError(GL_INVALID_ENUM);
1059			m_log << TestLog::EndSection;
1060		});
1061
1062	// Named Object Usage
1063
1064	ES3F_ADD_API_CASE(is_buffer, "Invalid glIsBuffer() usage",
1065		{
1066			GLuint		buffer = 0;
1067			GLboolean	isBuffer;
1068
1069			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.");
1070			isBuffer		= glIsBuffer(buffer);
1071			checkBooleans	(isBuffer, GL_FALSE);
1072
1073			glGenBuffers	(1, &buffer);
1074			isBuffer		= glIsBuffer(buffer);
1075			checkBooleans	(isBuffer, GL_FALSE);
1076
1077			glBindBuffer	(GL_ARRAY_BUFFER, buffer);
1078			isBuffer		= glIsBuffer(buffer);
1079			checkBooleans	(isBuffer, GL_TRUE);
1080
1081			glBindBuffer	(GL_ARRAY_BUFFER, 0);
1082			glDeleteBuffers	(1, &buffer);
1083			isBuffer		= glIsBuffer(buffer);
1084			checkBooleans	(isBuffer, GL_FALSE);
1085			m_log << TestLog::EndSection;
1086
1087			expectError			(GL_NO_ERROR);
1088		});
1089	ES3F_ADD_API_CASE(is_framebuffer, "Invalid glIsFramebuffer() usage",
1090		{
1091			GLuint		fbo = 0;
1092			GLboolean	isFbo;
1093
1094			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.");
1095			isFbo				= glIsFramebuffer(fbo);
1096			checkBooleans		(isFbo, GL_FALSE);
1097
1098			glGenFramebuffers	(1, &fbo);
1099			isFbo				= glIsFramebuffer(fbo);
1100			checkBooleans		(isFbo, GL_FALSE);
1101
1102			glBindFramebuffer	(GL_FRAMEBUFFER, fbo);
1103			isFbo				= glIsFramebuffer(fbo);
1104			checkBooleans		(isFbo, GL_TRUE);
1105
1106			glBindFramebuffer	(GL_FRAMEBUFFER, 0);
1107			glDeleteFramebuffers(1, &fbo);
1108			isFbo				= glIsFramebuffer(fbo);
1109			checkBooleans		(isFbo, GL_FALSE);
1110			m_log << TestLog::EndSection;
1111
1112			expectError			(GL_NO_ERROR);
1113		});
1114	ES3F_ADD_API_CASE(is_program, "Invalid glIsProgram() usage",
1115		{
1116			GLuint		program = 0;
1117			GLboolean	isProgram;
1118
1119			m_log << TestLog::Section("", "A name created with glCreateProgram, and not yet deleted with glDeleteProgram is a name of a program object.");
1120			isProgram			= glIsProgram(program);
1121			checkBooleans		(isProgram, GL_FALSE);
1122
1123			program				= glCreateProgram();
1124			isProgram			= glIsProgram(program);
1125			checkBooleans		(isProgram, GL_TRUE);
1126
1127			glDeleteProgram		(program);
1128			isProgram			= glIsProgram(program);
1129			checkBooleans		(isProgram, GL_FALSE);
1130			m_log << TestLog::EndSection;
1131
1132			expectError			(GL_NO_ERROR);
1133		});
1134	ES3F_ADD_API_CASE(is_renderbuffer, "Invalid glIsRenderbuffer() usage",
1135		{
1136			GLuint		rbo = 0;
1137			GLboolean	isRbo;
1138
1139			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.");
1140			isRbo					= glIsRenderbuffer(rbo);
1141			checkBooleans			(isRbo, GL_FALSE);
1142
1143			glGenRenderbuffers		(1, &rbo);
1144			isRbo					= glIsRenderbuffer(rbo);
1145			checkBooleans			(isRbo, GL_FALSE);
1146
1147			glBindRenderbuffer		(GL_RENDERBUFFER, rbo);
1148			isRbo					= glIsRenderbuffer(rbo);
1149			checkBooleans			(isRbo, GL_TRUE);
1150
1151			glBindRenderbuffer		(GL_RENDERBUFFER, 0);
1152			glDeleteRenderbuffers	(1, &rbo);
1153			isRbo					= glIsRenderbuffer(rbo);
1154			checkBooleans			(isRbo, GL_FALSE);
1155			m_log << TestLog::EndSection;
1156
1157			expectError			(GL_NO_ERROR);
1158		});
1159	ES3F_ADD_API_CASE(is_shader, "Invalid glIsShader() usage",
1160		{
1161			GLuint		shader = 0;
1162			GLboolean	isShader;
1163
1164			m_log << TestLog::Section("", "A name created with glCreateShader, and not yet deleted with glDeleteShader is a name of a shader object.");
1165			isShader			= glIsProgram(shader);
1166			checkBooleans		(isShader, GL_FALSE);
1167
1168			shader				= glCreateShader(GL_VERTEX_SHADER);
1169			isShader			= glIsShader(shader);
1170			checkBooleans		(isShader, GL_TRUE);
1171
1172			glDeleteShader		(shader);
1173			isShader			= glIsShader(shader);
1174			checkBooleans		(isShader, GL_FALSE);
1175			m_log << TestLog::EndSection;
1176
1177			expectError			(GL_NO_ERROR);
1178		});
1179	ES3F_ADD_API_CASE(is_texture, "Invalid glIsTexture() usage",
1180		{
1181			GLuint		texture = 0;
1182			GLboolean	isTexture;
1183
1184			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.");
1185			isTexture			= glIsTexture(texture);
1186			checkBooleans		(isTexture, GL_FALSE);
1187
1188			glGenTextures		(1, &texture);
1189			isTexture			= glIsTexture(texture);
1190			checkBooleans		(isTexture, GL_FALSE);
1191
1192			glBindTexture		(GL_TEXTURE_2D, texture);
1193			isTexture			= glIsTexture(texture);
1194			checkBooleans		(isTexture, GL_TRUE);
1195
1196			glBindTexture		(GL_TEXTURE_2D, 0);
1197			glDeleteTextures	(1, &texture);
1198			isTexture			= glIsTexture(texture);
1199			checkBooleans		(isTexture, GL_FALSE);
1200			m_log << TestLog::EndSection;
1201
1202			expectError			(GL_NO_ERROR);
1203		});
1204	ES3F_ADD_API_CASE(is_query, "Invalid glIsQuery() usage",
1205		{
1206			GLuint		query = 0;
1207			GLboolean	isQuery;
1208
1209			m_log << TestLog::Section("", "A name returned by glGenQueries, but not yet associated with a query object by calling glBeginQuery, is not the name of a query object.");
1210			isQuery				= glIsQuery(query);
1211			checkBooleans		(isQuery, GL_FALSE);
1212
1213			glGenQueries		(1, &query);
1214			isQuery				= glIsQuery(query);
1215			checkBooleans		(isQuery, GL_FALSE);
1216
1217			glBeginQuery		(GL_ANY_SAMPLES_PASSED, query);
1218			isQuery				= glIsQuery(query);
1219			checkBooleans		(isQuery, GL_TRUE);
1220
1221			glEndQuery			(GL_ANY_SAMPLES_PASSED);
1222			glDeleteQueries		(1, &query);
1223			isQuery				= glIsQuery(query);
1224			checkBooleans		(isQuery, GL_FALSE);
1225			m_log << TestLog::EndSection;
1226
1227			expectError			(GL_NO_ERROR);
1228		});
1229	ES3F_ADD_API_CASE(is_sampler, "Invalid glIsSampler() usage",
1230		{
1231			GLuint		sampler = 0;
1232			GLboolean	isSampler;
1233
1234			m_log << TestLog::Section("", "A name returned by glGenSamplers is the name of a sampler object.");
1235			isSampler			= glIsSampler(sampler);
1236			checkBooleans		(isSampler, GL_FALSE);
1237
1238			glGenSamplers		(1, &sampler);
1239			isSampler			= glIsSampler(sampler);
1240			checkBooleans		(isSampler, GL_TRUE);
1241
1242			glBindSampler		(0, sampler);
1243			isSampler			= glIsSampler(sampler);
1244			checkBooleans		(isSampler, GL_TRUE);
1245
1246			glDeleteSamplers	(1, &sampler);
1247			isSampler			= glIsSampler(sampler);
1248			checkBooleans		(isSampler, GL_FALSE);
1249			m_log << TestLog::EndSection;
1250
1251			expectError			(GL_NO_ERROR);
1252		});
1253	ES3F_ADD_API_CASE(is_sync, "Invalid glIsSync() usage",
1254		{
1255			GLsync		sync = 0;
1256			GLboolean	isSync;
1257
1258			m_log << TestLog::Section("", "A name returned by glFenceSync is the name of a sync object.");
1259			isSync			= glIsSync(sync);
1260			checkBooleans	(isSync, GL_FALSE);
1261
1262			sync			= glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1263			isSync			= glIsSync(sync);
1264			checkBooleans	(isSync, GL_TRUE);
1265
1266			glDeleteSync	(sync);
1267			isSync			= glIsSync(sync);
1268			checkBooleans	(isSync, GL_FALSE);
1269			m_log << TestLog::EndSection;
1270
1271			expectError			(GL_NO_ERROR);
1272		});
1273	ES3F_ADD_API_CASE(is_transform_feedback, "Invalid glIsTransformFeedback() usage",
1274		{
1275			GLuint		tf = 0;
1276			GLboolean	isTF;
1277
1278			m_log << TestLog::Section("", "A name returned by glGenTransformFeedbacks, but not yet bound using glBindTransformFeedback, is not the name of a transform feedback object.");
1279			isTF						= glIsTransformFeedback(tf);
1280			checkBooleans				(isTF, GL_FALSE);
1281
1282			glGenTransformFeedbacks		(1, &tf);
1283			isTF						= glIsTransformFeedback(tf);
1284			checkBooleans				(isTF, GL_FALSE);
1285
1286			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tf);
1287			isTF						= glIsTransformFeedback(tf);
1288			checkBooleans				(isTF, GL_TRUE);
1289
1290			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, 0);
1291			glDeleteTransformFeedbacks	(1, &tf);
1292			isTF						= glIsTransformFeedback(tf);
1293			checkBooleans				(isTF, GL_FALSE);
1294			m_log << TestLog::EndSection;
1295
1296			expectError			(GL_NO_ERROR);
1297		});
1298	ES3F_ADD_API_CASE(is_vertex_array, "Invalid glIsVertexArray() usage",
1299		{
1300			GLuint		vao = 0;
1301			GLboolean	isVao;
1302
1303			m_log << TestLog::Section("", "A name returned by glGenVertexArrays, but not yet bound using glBindVertexArray, is not the name of a vertex array object.");
1304			isVao					= glIsVertexArray(vao);
1305			checkBooleans			(isVao, GL_FALSE);
1306
1307			glGenVertexArrays			(1, &vao);
1308			isVao					= glIsVertexArray(vao);
1309			checkBooleans			(isVao, GL_FALSE);
1310
1311			glBindVertexArray			(vao);
1312			isVao					= glIsVertexArray(vao);
1313			checkBooleans			(isVao, GL_TRUE);
1314
1315			glBindVertexArray		(0);
1316			glDeleteVertexArrays	(1, &vao);
1317			isVao					= glIsVertexArray(vao);
1318			checkBooleans			(isVao, GL_FALSE);
1319			m_log << TestLog::EndSection;
1320
1321			expectError			(GL_NO_ERROR);
1322		});
1323}
1324
1325} // Functional
1326} // gles3
1327} // deqp
1328