[Piglit] [PATCH 13/15] tests: enumerate subtests in degenerate-prims

Dylan Baker dylan at pnwbakers.com
Tue Jan 23 01:22:14 UTC 2018


---
 tests/general/degenerate-prims.c | 59 ++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 18 deletions(-)

diff --git a/tests/general/degenerate-prims.c b/tests/general/degenerate-prims.c
index d2bb7d6..6a73b65 100644
--- a/tests/general/degenerate-prims.c
+++ b/tests/general/degenerate-prims.c
@@ -35,10 +35,44 @@
 
 #include "piglit-util-gl.h"
 
+static const float verts2[2][2] = { {-1, -1}, {1, 1} };
+static const float verts3[3][2] = { {-1, -1}, {1, -1}, {0, 1} };
+static const float verts4[4][2] = { {-1, -1}, {1, -1}, {1, 1}, {-1, 1} };
+
+struct test_config
+{
+	GLenum prim;
+	unsigned numVerts;
+	const void *verts;
+};
+
+static const struct test_config tests[] = {
+	{ GL_POINTS, 0, verts2 },
+	{ GL_LINES, 1, verts2 },
+	{ GL_LINE_STRIP, 1, verts2 },
+	{ GL_LINE_LOOP, 1, verts2 },
+	{ GL_TRIANGLES, 2, verts3 },
+	{ GL_TRIANGLE_STRIP, 2, verts3 },
+	{ GL_TRIANGLE_FAN, 2, verts3 },
+	{ GL_QUADS, 3, verts4 },
+	{ GL_QUAD_STRIP, 3, verts4 },
+	{ GL_POLYGON, 2, verts4 },
+	{ 0 }
+};
+
+
 PIGLIT_GL_TEST_CONFIG_BEGIN
 	config.supports_gl_compat_version = 10;
 	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 	config.khr_no_error_support = PIGLIT_NO_ERRORS;
+
+	const char *subtests[ARRAY_SIZE(tests) - 1];
+	for (int i = 0; tests[i].verts; i++) {
+		subtests[i] = piglit_get_prim_name(tests[i].prim);
+	}
+	subtests[ARRAY_SIZE(tests) - 1] = NULL;
+	config.all_subtests = subtests;
+
 PIGLIT_GL_TEST_CONFIG_END
 
 
@@ -47,16 +81,16 @@ PIGLIT_GL_TEST_CONFIG_END
  * The expected outcome is that nothing will be drawn.
  */
 static bool
-test_prim(GLenum prim, unsigned numVerts, const void *verts)
+test_prim(const struct test_config *config)
 {
 	static const float black[] = {0, 0, 0, 0};
 	bool pass;
 
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	glVertexPointer(2, GL_FLOAT, 0, verts);
+	glVertexPointer(2, GL_FLOAT, 0, config->verts);
 	glEnable(GL_VERTEX_ARRAY);
-	glDrawArrays(prim, 0, numVerts);
+	glDrawArrays(config->prim, 0, config->numVerts);
 
 	/* Nothing should have been drawn / look for all black */
 	pass = piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, black);
@@ -64,7 +98,7 @@ test_prim(GLenum prim, unsigned numVerts, const void *verts)
 	piglit_present_results();
 
 	piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
-			             "Primitive: %s", piglit_get_prim_name(prim));
+			             "Primitive: %s", piglit_get_prim_name(config->prim));
 
 	return pass;
 }
@@ -73,10 +107,6 @@ test_prim(GLenum prim, unsigned numVerts, const void *verts)
 enum piglit_result
 piglit_display(void)
 {
-	static const float
-		verts2[2][2] = { {-1, -1}, {1, 1} },
-		verts3[3][2] = { {-1, -1}, {1, -1}, {0, 1} },
-		verts4[4][2] = { {-1, -1}, {1, -1}, {1, 1}, {-1, 1} };
 	bool pass = true;
 
 	glMatrixMode(GL_PROJECTION);
@@ -85,16 +115,9 @@ piglit_display(void)
 
 	glColor3f(1, 1, 1);
 
-	pass = test_prim(GL_POINTS, 0, verts2) && pass;
-	pass = test_prim(GL_LINES, 1, verts2) && pass;
-	pass = test_prim(GL_LINE_STRIP, 1, verts2) && pass;
-	pass = test_prim(GL_LINE_LOOP, 1, verts2) && pass;
-	pass = test_prim(GL_TRIANGLES, 2, verts3) && pass;
-	pass = test_prim(GL_TRIANGLE_STRIP, 2, verts3) && pass;
-	pass = test_prim(GL_TRIANGLE_FAN, 2, verts3) && pass;
-	pass = test_prim(GL_QUADS, 3, verts4) && pass;
-	pass = test_prim(GL_QUAD_STRIP, 3, verts4) && pass;
-	pass = test_prim(GL_POLYGON, 2, verts4) && pass;
+	for (int i = 0; tests[i].verts; i++) {
+		pass = test_prim(&tests[i]) && pass;
+	}
 
 	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
 }
-- 
git-series 0.9.1


More information about the Piglit mailing list