[Piglit] [PATCH] Use piglit_check_gl_error() instead of block with [f]printf.

Chris Forbes chrisf at ijw.co.nz
Mon Oct 1 13:54:49 PDT 2012


Generated from the following semantic patch.

@@
expression RET, MSG;
@@

-	RET = glGetError();
-	if (RET != 0) {
+	if (!piglit_check_gl_error(GL_NO_ERROR))
(
-		printf(MSG,RET);
|
-		fprintf(stderr,MSG,RET);
)
		piglit_report_result(PIGLIT_FAIL);
-	}

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 tests/fbo/fbo-blit-d24s8.c                                |  5 +----
 tests/fbo/fbo-drawbuffers-maxtargets.c                    |  5 +----
 tests/fbo/fbo-getframebufferattachmentparameter-01.c      |  5 +----
 tests/fbo/fbo-incomplete-texture-01.c                     | 10 ++--------
 tests/fbo/fbo-incomplete-texture-02.c                     | 10 ++--------
 tests/fbo/fbo-incomplete-texture-03.c                     | 10 ++--------
 tests/fbo/fbo-incomplete-texture-04.c                     | 15 +++------------
 tests/fbo/fbo-scissor-bitmap.c                            |  5 +----
 .../arb_es2_compatibility/fbo-missing-attachment-clear.c  | 10 ++--------
 9 files changed, 15 insertions(+), 60 deletions(-)

diff --git a/tests/fbo/fbo-blit-d24s8.c b/tests/fbo/fbo-blit-d24s8.c
index cb44990..732e164 100644
--- a/tests/fbo/fbo-blit-d24s8.c
+++ b/tests/fbo/fbo-blit-d24s8.c
@@ -213,11 +213,8 @@ run_test(void)
 	     x0, y1, x0 + SIZE, y1 + SIZE,
 	     GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 
-	err = glGetError();
-	if (err != GL_NO_ERROR) {
-		printf("Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	/* WIN(bottom) -> FBO(middle) */
 	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
diff --git a/tests/fbo/fbo-drawbuffers-maxtargets.c b/tests/fbo/fbo-drawbuffers-maxtargets.c
index b3227bf..f4a57a6 100644
--- a/tests/fbo/fbo-drawbuffers-maxtargets.c
+++ b/tests/fbo/fbo-drawbuffers-maxtargets.c
@@ -118,11 +118,8 @@ generate_and_display_drawbuffers(int count)
 	prog = piglit_link_simple_program(vs, fs);
 	glUseProgram(prog);
 
-	error = glGetError();
-	if (error) {
-		fprintf(stderr, "glUseProgram error: 0x%x\n", error);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	/* Now render to all the color buffers. */
 	piglit_draw_rect(-1, -1, 2, 2);
diff --git a/tests/fbo/fbo-getframebufferattachmentparameter-01.c b/tests/fbo/fbo-getframebufferattachmentparameter-01.c
index 8bb8bf1..db17e77 100644
--- a/tests/fbo/fbo-getframebufferattachmentparameter-01.c
+++ b/tests/fbo/fbo-getframebufferattachmentparameter-01.c
@@ -100,11 +100,8 @@ piglit_init(int argc, char **argv)
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 				  GL_TEXTURE_2D, tex, 0);
 
-	err = glGetError();
-	if (err != 0) {
-		printf("Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER);
 	if (status != GL_FRAMEBUFFER_COMPLETE) {
diff --git a/tests/fbo/fbo-incomplete-texture-01.c b/tests/fbo/fbo-incomplete-texture-01.c
index 5112f10..87a4ac2 100644
--- a/tests/fbo/fbo-incomplete-texture-01.c
+++ b/tests/fbo/fbo-incomplete-texture-01.c
@@ -76,11 +76,8 @@ piglit_init(int argc, char **argv)
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 			       GL_TEXTURE_2D, tex, 0);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 	if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -92,11 +89,8 @@ piglit_init(int argc, char **argv)
 	glClearColor(color[0], color[1], color[2], color[3]);
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_2D, 0, 0, 0, 32, 32,
 					  color)) {
diff --git a/tests/fbo/fbo-incomplete-texture-02.c b/tests/fbo/fbo-incomplete-texture-02.c
index 1f3a005..c8123bf 100644
--- a/tests/fbo/fbo-incomplete-texture-02.c
+++ b/tests/fbo/fbo-incomplete-texture-02.c
@@ -83,11 +83,8 @@ piglit_init(int argc, char **argv)
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 			       GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex, 0);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 	if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -99,11 +96,8 @@ piglit_init(int argc, char **argv)
 	glClearColor(color[0], color[1], color[2], color[3]);
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0,
 					 0, 0, 32, 32, color)) {
diff --git a/tests/fbo/fbo-incomplete-texture-03.c b/tests/fbo/fbo-incomplete-texture-03.c
index 335a1ed..33f4505 100644
--- a/tests/fbo/fbo-incomplete-texture-03.c
+++ b/tests/fbo/fbo-incomplete-texture-03.c
@@ -84,11 +84,8 @@ piglit_init(int argc, char **argv)
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 			       GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex, 0);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 	if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -100,11 +97,8 @@ piglit_init(int argc, char **argv)
 	glClearColor(color[0], color[1], color[2], color[3]);
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0,
 					  0, 0, 32, 32, color)) {
diff --git a/tests/fbo/fbo-incomplete-texture-04.c b/tests/fbo/fbo-incomplete-texture-04.c
index 9063b7b..418655f 100644
--- a/tests/fbo/fbo-incomplete-texture-04.c
+++ b/tests/fbo/fbo-incomplete-texture-04.c
@@ -75,11 +75,8 @@ piglit_init(int argc, char **argv)
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 			       GL_TEXTURE_2D, tex, 2);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	/* Since texture level 2 does not exist, the FBO should be incomplete.
 	 */
@@ -101,11 +98,8 @@ piglit_init(int argc, char **argv)
 	glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 8, 8, 0,
 		     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
 
-	err = glGetError();
-	if (err != 0) {
-		printf("Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 	if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -116,11 +110,8 @@ piglit_init(int argc, char **argv)
 	glClearColor(color[0], color[1], color[2], color[3]);
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_2D, 2, 0, 0, 8, 8,
 					  color)) {
diff --git a/tests/fbo/fbo-scissor-bitmap.c b/tests/fbo/fbo-scissor-bitmap.c
index 58eb6f9..97248b6 100644
--- a/tests/fbo/fbo-scissor-bitmap.c
+++ b/tests/fbo/fbo-scissor-bitmap.c
@@ -174,11 +174,8 @@ draw_and_test(const char *destination, int drawable_width, int drawable_height)
 	/* Clear to black */
 	glClearColor(0, 0, 0, 0);
 	glClear(GL_COLOR_BUFFER_BIT);
-	error = glGetError();
-	if (error) {
-		fprintf(stderr, "glClear error: 0x%x\n", error);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	glColor4fv(red);
 	/* Center: full image */
diff --git a/tests/spec/arb_es2_compatibility/fbo-missing-attachment-clear.c b/tests/spec/arb_es2_compatibility/fbo-missing-attachment-clear.c
index e9df4be..84c40d4 100644
--- a/tests/spec/arb_es2_compatibility/fbo-missing-attachment-clear.c
+++ b/tests/spec/arb_es2_compatibility/fbo-missing-attachment-clear.c
@@ -78,11 +78,8 @@ piglit_init(int argc, char **argv)
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
 			       GL_TEXTURE_2D, tex, 0);
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 	if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -106,11 +103,8 @@ piglit_init(int argc, char **argv)
 	pass = piglit_probe_rect_depth(0, 0, piglit_width, piglit_height, 0.5)
 		&& pass;
 
-	err = glGetError();
-	if (err != 0) {
-		fprintf(stderr, "Unexpected GL error state 0x%04x\n", err);
+	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
-	}
 
 	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
-- 
1.7.12.2



More information about the Piglit mailing list