gl-3.0-vertexattribipointer: add argv support for running single tests

Submitted by Brian Paul on June 16, 2014, 7:16 p.m.

Details

Message ID 1402946166-4921-1-git-send-email-brianp@vmware.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Brian Paul June 16, 2014, 7:16 p.m.
---
 tests/spec/gl-3.0/vertexattribipointer.c |   43 +++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/spec/gl-3.0/vertexattribipointer.c b/tests/spec/gl-3.0/vertexattribipointer.c
index b69e731..633b881 100644
--- a/tests/spec/gl-3.0/vertexattribipointer.c
+++ b/tests/spec/gl-3.0/vertexattribipointer.c
@@ -63,8 +63,16 @@  static const char *fragShaderText =
 	"   gl_FragColor = color; \n"
 	"} \n";
 
+static const GLenum types[] = {
+	GL_BYTE,
+	GL_UNSIGNED_BYTE,
+	GL_SHORT,
+	GL_UNSIGNED_SHORT,
+	GL_INT,
+	GL_UNSIGNED_INT
+};
 
-static const GLubyte ubyte4_data[] = { 100, 0, 200, 255 };
+static const GLubyte ubyte4_data[] = { 100, 40, 200, 255 };
 static const GLbyte byte4_data[] = { 50, 0, -25, -50 };
 static const GLushort ushort4_data[] = { 16000, 0, 32000, 65535 };
 static const GLshort short4_data[] = { 2000, 0, -4000, -32010 };
@@ -198,14 +206,6 @@  test_array(GLenum type, GLuint size)
 enum piglit_result
 piglit_display(void)
 {
-	static const GLenum types[] = {
-		GL_BYTE,
-		GL_UNSIGNED_BYTE,
-		GL_SHORT,
-		GL_UNSIGNED_SHORT,
-		GL_INT,
-		GL_UNSIGNED_INT
-	};
 	bool pass = true;
 	int t, size;
 
@@ -236,4 +236,29 @@  piglit_init(int argc, char **argv)
 	Attr_u = glGetAttribLocation(Prog, "attr_u");
 	ExpectedUniform_i = glGetUniformLocation(Prog, "expected_i");
 	ExpectedUniform_u = glGetUniformLocation(Prog, "expected_u");
+
+	if (argc == 3) {
+		/* Look for type and size on command line to run one
+		 * individual test case.  For example:
+		 * vertexattribipointer GL_BYTE 3
+		 */
+		GLenum type = 0;
+		GLint size = 0;
+		int i;
+		bool p;
+		for (i = 0; i < ARRAY_SIZE(types); i++) {
+			if (strcmp(argv[1],
+				   piglit_get_gl_enum_name(types[i])) == 0) {
+				type = types[i];
+				break;
+			}
+		}
+		assert(type);
+		size = atoi(argv[2]);
+		assert(size >= 1);
+		assert(size <= 4);
+		printf("Testing %s %d\n", argv[1], size);
+		p = test_array(type, size);
+		piglit_report_result(p ? PIGLIT_PASS : PIGLIT_FAIL);
+	}
 }