[Piglit] [PATCH 08/10] GL_ARB_ubo/getuniformindices: Add missing test for bad uniform names.

Eric Anholt eric at anholt.net
Thu Aug 9 09:22:14 PDT 2012


As I've been trimming down my "todo" copy of the spec, I noticed this
case wasn't tested where it should have been.
---
 .../arb_uniform_buffer_object/getuniformindices.c     |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tests/spec/arb_uniform_buffer_object/getuniformindices.c b/tests/spec/arb_uniform_buffer_object/getuniformindices.c
index 9819c6d..646002e 100644
--- a/tests/spec/arb_uniform_buffer_object/getuniformindices.c
+++ b/tests/spec/arb_uniform_buffer_object/getuniformindices.c
@@ -24,7 +24,7 @@
 /** @file getuniformindices.c
  *
  * Tests the glGetUniformIndices API: not writing on error conditions,
- * and consecutive indices starting from 0.
+ * invalid uniform names, and consecutive indices starting from 0.
  */
 
 #include "piglit-util-gl-common.h"
@@ -54,6 +54,7 @@ piglit_init(int argc, char **argv)
 	GLuint fs;
 	GLuint save_index = 0xaaaaaaaa;
 	const GLchar *one_uniform = "a";
+	const GLchar *bad_uniform = "d";
 	const GLchar *uniform_names[] = {"a", "b", "c"};
 	bool found_index[3] = {false, false, false};
 	GLuint indices[3], index;
@@ -121,6 +122,20 @@ piglit_init(int argc, char **argv)
 		found_index[indices[i]] = true;
 	}
 
+	/*     "If a string in <uniformNames> is not the name of an
+	 *      active uniform, the value INVALID_INDEX will be
+	 *      written to the corresponding element of
+	 *      <uniformIndices>."
+	 */
+	glGetUniformIndices(prog, 1, &bad_uniform, &index);
+	if (!piglit_check_gl_error(0)) {
+		pass = false;
+	} else if (index != GL_INVALID_INDEX) {
+		printf("Bad uniform index for %s: 0x%08x\n", bad_uniform, index);
+		printf("  Expected 0x%08x\n", GL_INVALID_INDEX);
+		pass = false;
+	}
+
 	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
 
-- 
1.7.10.4



More information about the Piglit mailing list