[Piglit] [PATCH 1/4] minmax: Detect cases where errors are generated or values not written
Ian Romanick
idr at freedesktop.org
Fri Jan 10 14:05:54 PST 2014
From: Ian Romanick <ian.d.romanick at intel.com>
Any minmax test should fail if the query either generates an error or
doesn't write a value to the destination. To facilitate this, the
storage location is initialized to a value that is unlikely to be
generated by the GL (0xDEADBEEF) instead of 9999.
This caused some additional failures arb_viewport_array-minmax to be
flagged while the extension was being developed.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
tests/util/minmax-test.c | 66 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 48 insertions(+), 18 deletions(-)
diff --git a/tests/util/minmax-test.c b/tests/util/minmax-test.c
index 1cb8ab9..ef98a8f 100644
--- a/tests/util/minmax-test.c
+++ b/tests/util/minmax-test.c
@@ -99,30 +99,42 @@ piglit_report_float(const char *name, GLfloat limit, GLfloat val, bool pass)
}
}
+#define SENTINEL 0xDEADBEEF
+
static void
piglit_test_int(GLenum token, GLint limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
- GLint val = 9999;
+ GLint val = SENTINEL;
+ bool pass;
glGetIntegerv(token, &val);
+ pass = piglit_check_gl_error(GL_NO_ERROR);
+
piglit_report_int(name, limit, val,
- (max && val <= limit) ||
- (!max && val >= limit));
+ pass &&
+ val != SENTINEL &&
+ ((max && val <= limit) ||
+ (!max && val >= limit)));
}
static void
piglit_test_uint(GLenum token, GLuint limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
- GLuint val = 9999;
+ GLuint val = SENTINEL;
+ bool pass;
glGetIntegerv(token, (GLint*) &val);
+ pass = piglit_check_gl_error(GL_NO_ERROR);
+
piglit_report_uint(name, limit, val,
- (max && val <= limit) ||
- (!max && val >= limit));
+ pass &&
+ val != SENTINEL &&
+ ((max && val <= limit) ||
+ (!max && val >= limit)));
}
#if !defined(PIGLIT_USE_OPENGL_ES2)
@@ -130,20 +142,26 @@ static void
piglit_test_int64(GLenum token, GLint64 limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
- GLint64 val = 9999;
+ GLint64 val = SENTINEL;
+ bool pass;
glGetInteger64v(token, &val);
+ pass = piglit_check_gl_error(GL_NO_ERROR);
+
piglit_report_int64(name, limit, val,
- (max && val <= limit) ||
- (!max && val >= limit));
+ pass &&
+ val != SENTINEL &&
+ ((max && val <= limit) ||
+ (!max && val >= limit)));
}
static void
piglit_test_uint64(GLenum token, GLuint64 limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
- GLuint64 val;
+ GLuint64 val = SENTINEL;
+ bool pass;
/* To obtain GLuint64 values, we must use glGetInteger64v.
* Justification is found in the GL_ARB_sync spec:
@@ -160,9 +178,13 @@ piglit_test_uint64(GLenum token, GLuint64 limit, bool max)
glGetInteger64v(token, (GLint64*) &val);
+ pass = piglit_check_gl_error(GL_NO_ERROR);
+
piglit_report_uint64(name, limit, val,
- (max && val <= limit) ||
- (!max && val >= limit));
+ pass &&
+ val != SENTINEL &&
+ ((max && val <= limit) ||
+ (!max && val >= limit)));
}
#endif /* !PIGLIT_USE_OPENGL_ES2 */
@@ -212,13 +234,18 @@ static void
piglit_test_float(GLenum token, GLfloat limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
- GLfloat val = -9999;
+ GLfloat val = -SENTINEL;
+ bool pass;
glGetFloatv(token, &val);
+ pass = piglit_check_gl_error(GL_NO_ERROR);
+
piglit_report_float(name, limit, val,
- (max && val <= limit) ||
- (!max && val >= limit));
+ pass &&
+ val != SENTINEL &&
+ ((max && val <= limit) ||
+ (!max && val >= limit)));
}
void piglit_test_min_float(GLenum token, GLfloat min)
@@ -236,16 +263,19 @@ void piglit_test_range_float(GLenum token, GLfloat low, GLfloat high)
{
const char *name = piglit_get_gl_enum_name(token);
char *temp;
- GLfloat vals[2] = {9999, 9999};
+ GLfloat vals[2] = {SENTINEL, SENTINEL};
+ bool pass;
glGetFloatv(token, vals);
+ pass = piglit_check_gl_error(GL_NO_ERROR);
+
asprintf(&temp, "%s[0]", name);
- piglit_report_float(temp, low, vals[0], vals[0] <= low);
+ piglit_report_float(temp, low, vals[0], pass && vals[0] <= low);
free(temp);
asprintf(&temp, "%s[1]", name);
- piglit_report_float(temp, high, vals[1], vals[1] >= high);
+ piglit_report_float(temp, high, vals[1], pass && vals[1] >= high);
free(temp);
}
--
1.8.1.4
More information about the Piglit
mailing list