[Piglit] [PATCH 1/2] util/egl: Change piglit_expect_egl_error to return a bool
Chad Versace
chad.versace at linux.intel.com
Fri Nov 9 11:45:46 PST 2012
Previously, piglit_expect_egl_error() would terminate the test an
unexpecgted error occurred. However, there are many cases when we would
prefer to simply report the error and continue testing.
Commit 83c8ef80 made an analagous change to piglit_check_gl_error(). For
consistency with that function, this commit also renames
piglit_expect_egl_error to piglit_check_egl_error.
In all cases, I replaced
piglit_expect_egl_error(err, PIGLIT_FAIL)
with
if (!piglit_check_egl_error(err))
piglit_report_result(PIGLIT_FAIL)
or some equivalent.
CC: Ian Romanick <idr at freedesktop.org>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
tests/egl/egl-query-surface.c | 15 +++++++++++----
tests/egl/spec/egl_khr_create_context/core-profile.c | 12 ++++++------
.../spec/egl_khr_create_context/invalid-attribute-gl.c | 3 ++-
.../spec/egl_khr_create_context/invalid-attribute-gles.c | 3 ++-
tests/egl/spec/egl_khr_create_context/invalid-flag-gl.c | 3 ++-
tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c | 3 ++-
.../egl/spec/egl_khr_create_context/invalid-gl-version.c | 3 ++-
tests/egl/spec/egl_khr_create_context/invalid-profile.c | 3 ++-
.../valid-flag-forward-compatible-gl.c | 4 ++--
tests/util/piglit-util-egl.c | 7 ++++---
tests/util/piglit-util-egl.h | 7 ++++---
11 files changed, 39 insertions(+), 24 deletions(-)
diff --git a/tests/egl/egl-query-surface.c b/tests/egl/egl-query-surface.c
index c61ab5e..d6424e4 100644
--- a/tests/egl/egl-query-surface.c
+++ b/tests/egl/egl-query-surface.c
@@ -64,7 +64,9 @@ query_width(struct egl_state *state)
assert(state->width == window_width);
ok = eglQuerySurface(state->egl_dpy, state->surf, EGL_WIDTH, &width);
- piglit_expect_egl_error(EGL_SUCCESS, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_SUCCESS)) {
+ piglit_report_result(PIGLIT_FAIL);
+ }
if (!ok) {
fprintf(stderr, "error: eglQuerySurface() failed\n");
return PIGLIT_FAIL;
@@ -86,7 +88,9 @@ query_height(struct egl_state *state)
assert(state->height == window_height);
ok = eglQuerySurface(state->egl_dpy, state->surf, EGL_HEIGHT, &height);
- piglit_expect_egl_error(EGL_SUCCESS, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_SUCCESS)) {
+ piglit_report_result(PIGLIT_FAIL);
+ }
if (!ok) {
fprintf(stderr, "error: eglQuerySurface() failed\n");
return PIGLIT_FAIL;
@@ -112,7 +116,9 @@ query_bad_surface(struct egl_state *state)
"error: eglQuerySurface(surface=0) succeeded\n");
return PIGLIT_FAIL;
}
- piglit_expect_egl_error(EGL_BAD_SURFACE, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_SURFACE)) {
+ piglit_report_result(PIGLIT_FAIL);
+ }
return PIGLIT_PASS;
}
@@ -130,7 +136,8 @@ query_bad_parameter(struct egl_state *state)
"succeeded\n");
return PIGLIT_FAIL;
}
- piglit_expect_egl_error(EGL_BAD_ATTRIBUTE, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE))
+ piglit_report_result(PIGLIT_FAIL);
return PIGLIT_PASS;
}
diff --git a/tests/egl/spec/egl_khr_create_context/core-profile.c b/tests/egl/spec/egl_khr_create_context/core-profile.c
index c63993a..85f4d2a 100644
--- a/tests/egl/spec/egl_khr_create_context/core-profile.c
+++ b/tests/egl/spec/egl_khr_create_context/core-profile.c
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
if (ctx != EGL_NO_CONTEXT) {
eglDestroyContext(egl_dpy, ctx);
got_core_with_profile = true;
- } else {
+ } else if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
/* The EGL_KHR_create_context spec says:
*
* "* If <config> does not support a client API context
@@ -84,7 +84,7 @@ int main(int argc, char **argv)
* are supported), then an EGL_BAD_MATCH error is
* generated."
*/
- piglit_expect_egl_error(EGL_BAD_MATCH, PIGLIT_FAIL);
+ piglit_report_result(PIGLIT_FAIL);
}
/* The EGL_KHR_create_context spec says:
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
if (ctx != EGL_NO_CONTEXT) {
eglDestroyContext(egl_dpy, ctx);
got_core_without_profile = true;
- } else {
+ } else if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
/* The EGL_KHR_create_context spec says:
*
* "* If <config> does not support a client API context
@@ -107,7 +107,7 @@ int main(int argc, char **argv)
* are supported), then an EGL_BAD_MATCH error is
* generated."
*/
- piglit_expect_egl_error(EGL_BAD_MATCH, PIGLIT_FAIL);
+ piglit_report_result(PIGLIT_FAIL);
}
ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, compatibility_attribs);
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
if (ctx != EGL_NO_CONTEXT) {
eglDestroyContext(egl_dpy, ctx);
got_compatibility = true;
- } else {
+ } else if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
/* The EGL_KHR_create_context spec says:
*
* "* If <config> does not support a client API context
@@ -125,7 +125,7 @@ int main(int argc, char **argv)
* are supported), then an EGL_BAD_MATCH error is
* generated."
*/
- piglit_expect_egl_error(EGL_BAD_MATCH, PIGLIT_FAIL);
+ piglit_report_result(PIGLIT_FAIL);
}
EGL_KHR_create_context_teardown();
diff --git a/tests/egl/spec/egl_khr_create_context/invalid-attribute-gl.c b/tests/egl/spec/egl_khr_create_context/invalid-attribute-gl.c
index b99dee8..d1c99ab 100644
--- a/tests/egl/spec/egl_khr_create_context/invalid-attribute-gl.c
+++ b/tests/egl/spec/egl_khr_create_context/invalid-attribute-gl.c
@@ -47,7 +47,8 @@ static bool try_attribute(int attribute)
* recognized (including unrecognized bits in bitmask attributes),
* then an EGL_BAD_ATTRIBUTE error is generated."
*/
- piglit_expect_egl_error(EGL_BAD_ATTRIBUTE, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE))
+ piglit_report_result(PIGLIT_FAIL);
return pass;
}
diff --git a/tests/egl/spec/egl_khr_create_context/invalid-attribute-gles.c b/tests/egl/spec/egl_khr_create_context/invalid-attribute-gles.c
index d3e030c..0ee24de 100644
--- a/tests/egl/spec/egl_khr_create_context/invalid-attribute-gles.c
+++ b/tests/egl/spec/egl_khr_create_context/invalid-attribute-gles.c
@@ -56,7 +56,8 @@ static bool try_attribute(int attribute)
* recognized (including unrecognized bits in bitmask attributes),
* then an EGL_BAD_ATTRIBUTE error is generated."
*/
- piglit_expect_egl_error(EGL_BAD_ATTRIBUTE, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE))
+ piglit_report_result(PIGLIT_FAIL);
return pass;
}
diff --git a/tests/egl/spec/egl_khr_create_context/invalid-flag-gl.c b/tests/egl/spec/egl_khr_create_context/invalid-flag-gl.c
index 1aac646..ce4fe2d 100644
--- a/tests/egl/spec/egl_khr_create_context/invalid-flag-gl.c
+++ b/tests/egl/spec/egl_khr_create_context/invalid-flag-gl.c
@@ -47,7 +47,8 @@ static bool try_flag(uint32_t flag)
* recognized (including unrecognized bits in bitmask attributes),
* then an EGL_BAD_ATTRIBUTE error is generated."
*/
- piglit_expect_egl_error(EGL_BAD_ATTRIBUTE, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE))
+ piglit_report_result(PIGLIT_FAIL);
return pass;
}
diff --git a/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c b/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c
index 3618a91..b12db20 100644
--- a/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c
+++ b/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c
@@ -47,7 +47,8 @@ static bool try_flag(uint32_t flag)
* recognized (including unrecognized bits in bitmask attributes),
* then an EGL_BAD_ATTRIBUTE error is generated."
*/
- piglit_expect_egl_error(EGL_BAD_ATTRIBUTE, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE))
+ piglit_report_result(PIGLIT_FAIL);
return pass;
}
diff --git a/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c b/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c
index ee33fb9..680b70b 100644
--- a/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c
+++ b/tests/egl/spec/egl_khr_create_context/invalid-gl-version.c
@@ -50,7 +50,8 @@ static bool try_version(int major, int minor)
* version and feature set that are not defined, than an
* EGL_BAD_MATCH error is generated."
*/
- piglit_expect_egl_error(EGL_BAD_MATCH, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_MATCH))
+ piglit_report_result(PIGLIT_FAIL);
return pass;
}
diff --git a/tests/egl/spec/egl_khr_create_context/invalid-profile.c b/tests/egl/spec/egl_khr_create_context/invalid-profile.c
index d7aece8..fe4f429 100644
--- a/tests/egl/spec/egl_khr_create_context/invalid-profile.c
+++ b/tests/egl/spec/egl_khr_create_context/invalid-profile.c
@@ -59,7 +59,8 @@ static bool try_profile(int profile)
* support the requested profile, then an EGL_BAD_MATCH error is
* generated."
*/
- piglit_expect_egl_error(EGL_BAD_MATCH, PIGLIT_FAIL);
+ if (!piglit_check_egl_error(EGL_BAD_MATCH))
+ piglit_report_result(PIGLIT_FAIL);
return pass;
}
diff --git a/tests/egl/spec/egl_khr_create_context/valid-flag-forward-compatible-gl.c b/tests/egl/spec/egl_khr_create_context/valid-flag-forward-compatible-gl.c
index b41fda0..2f2c0a7 100644
--- a/tests/egl/spec/egl_khr_create_context/valid-flag-forward-compatible-gl.c
+++ b/tests/egl/spec/egl_khr_create_context/valid-flag-forward-compatible-gl.c
@@ -48,7 +48,7 @@ static bool try_flag(int flag)
gl_version = piglit_get_gl_version();
}
eglDestroyContext(egl_dpy, ctx);
- } else {
+ } else if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
/* The EGL_KHR_create_context spec says:
*
* "* If <config> does not support a client API context compatible
@@ -57,7 +57,7 @@ static bool try_flag(int flag)
* where these attributes are supported), then an EGL_BAD_MATCH
* error is generated.
*/
- piglit_expect_egl_error(EGL_BAD_MATCH, PIGLIT_FAIL);
+ piglit_report_result(PIGLIT_FAIL);
}
return true;
diff --git a/tests/util/piglit-util-egl.c b/tests/util/piglit-util-egl.c
index a7d37e5..1087429 100644
--- a/tests/util/piglit-util-egl.c
+++ b/tests/util/piglit-util-egl.c
@@ -48,13 +48,14 @@ const char* piglit_get_egl_error_name(EGLint error) {
#undef CASE
}
-void piglit_expect_egl_error(EGLint expected_error, enum piglit_result result)
+bool
+piglit_check_egl_error(EGLint expected_error)
{
EGLint actual_error;
actual_error = eglGetError();
if (actual_error == expected_error) {
- return;
+ return true;
}
/*
@@ -72,7 +73,7 @@ void piglit_expect_egl_error(EGLint expected_error, enum piglit_result result)
piglit_get_egl_error_name(expected_error), expected_error);
}
- piglit_report_result(result);
+ return false;
}
bool
diff --git a/tests/util/piglit-util-egl.h b/tests/util/piglit-util-egl.h
index db94eeb..7faccf4 100644
--- a/tests/util/piglit-util-egl.h
+++ b/tests/util/piglit-util-egl.h
@@ -41,14 +41,15 @@ extern "C" {
const char* piglit_get_egl_error_name(EGLint error);
/**
- * \brief Check for unexpected EGL errors and possibly terminate the test.
+ * \brief Check for unexpected EGL errors.
*
* If eglGetError() returns an error other than \c expected_error, then
- * print a diagnostic and terminate the test with the given result.
+ * print a diagnostic and return false.
*
* If you expect no error, then set \code expected_error = EGL_SUCCESS \endcode.
*/
-void piglit_expect_egl_error(EGLint expected_error, enum piglit_result result);
+bool
+piglit_check_egl_error(EGLint expected_error);
/**
* \brief Checks whether an EGL extension is supported.
--
1.7.11.7
More information about the Piglit
mailing list