summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2015-09-16 10:01:47 -0400
committerIan Romanick <ian.d.romanick@intel.com>2019-06-26 08:31:49 -0700
commitf0dbd94b2939461cdab9e9bf32c5e84a2a4cd96e (patch)
treeb79a1bb5b29cb9d79522a3862cabd4011783ee9f
parent4f44a9d3a9f990ebdb6e515bce26ea1e2a97217b (diff)
degenerate-prims: Add the ability for tests to expect some drawing
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r--tests/general/degenerate-prims.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/tests/general/degenerate-prims.c b/tests/general/degenerate-prims.c
index 4e8d761ec..e46d5c2be 100644
--- a/tests/general/degenerate-prims.c
+++ b/tests/general/degenerate-prims.c
@@ -45,17 +45,23 @@ struct test_data {
GLenum prim;
unsigned numVerts;
const void *verts;
+
+ /** Select whether or not anything is expected to be drawn. */
+ bool expect_no_drawing;
};
/**
* Test a specific degenerate primitive.
- * The expected outcome is that nothing will be drawn.
+ *
+ * \param expect_no_drawing Select whether or not anything is expected to be
+ * drawn.
*/
static enum piglit_result
test_prim(void *_data)
{
struct test_data *data = _data;
static const float black[] = {0, 0, 0, 0};
+ bool nothing_drawn;
bool pass;
glClear(GL_COLOR_BUFFER_BIT);
@@ -64,8 +70,18 @@ test_prim(void *_data)
glEnable(GL_VERTEX_ARRAY);
glDrawArrays(data->prim, 0, data->numVerts);
- /* Nothing should have been drawn / look for all black */
- pass = piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, black);
+ /* Check the color in the window. If the test expected that nothing
+ * would be drawn and the while window is black, the test passes. If
+ * the test expected that something would be drawn and at least part
+ * of the window is not black, the test passes.
+ */
+ if (!data->expect_no_drawing)
+ printf("This subtest should report a color mismatch.\n");
+
+ nothing_drawn = piglit_probe_rect_rgb(0, 0,
+ piglit_width, piglit_height,
+ black);
+ pass = nothing_drawn == data->expect_no_drawing;
piglit_present_results();
@@ -89,16 +105,16 @@ piglit_display(void)
glColor3f(1, 1, 1);
struct test_data data[] = {
- { 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 },
+ { GL_POINTS, 0, verts2, true },
+ { GL_LINES, 1, verts2, true },
+ { GL_LINE_STRIP, 1, verts2, true },
+ { GL_LINE_LOOP, 1, verts2, true },
+ { GL_TRIANGLES, 2, verts3, true },
+ { GL_TRIANGLE_STRIP, 2, verts3, true },
+ { GL_TRIANGLE_FAN, 2, verts3, true },
+ { GL_QUADS, 3, verts4, true },
+ { GL_QUAD_STRIP, 3, verts4, true },
+ { GL_POLYGON, 2, verts4, true },
};
struct piglit_subtest tests[ARRAY_SIZE(data) + 1];