[Piglit] [PATCH 1/3] arb_texture_storage: Use piglit idoms

Ian Romanick idr at freedesktop.org
Wed Oct 16 23:14:20 CEST 2013


From: Ian Romanick <ian.d.romanick at intel.com>

This mostly reverts bd096a8a, but it keeps the subtest reporting.  The
non-idomatic way this test was implemented was causing confusion for at
least one new piglit developer.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Matt Turner <mattst88 at gmail.com>
Cc: Corey Richardson <corey at octayn.net>
Cc: Jon Ashburn <jon at lunarg.com>
---
 tests/spec/arb_texture_storage/texture-storage.c | 66 +++++++++++++-----------
 1 file changed, 37 insertions(+), 29 deletions(-)

diff --git a/tests/spec/arb_texture_storage/texture-storage.c b/tests/spec/arb_texture_storage/texture-storage.c
index 201929d..8d161d1 100644
--- a/tests/spec/arb_texture_storage/texture-storage.c
+++ b/tests/spec/arb_texture_storage/texture-storage.c
@@ -57,7 +57,7 @@ static GLubyte Colors[][4] = {
 /**
  * Do error-check tests for a non-mipmapped texture.
  */
-static enum piglit_result
+static bool
 test_one_level_errors(GLenum target)
 {
 	const GLint width = 64, height = 4, depth = 8;
@@ -86,14 +86,14 @@ test_one_level_errors(GLenum target)
 	glGetTexLevelParameteriv(target, 0, GL_TEXTURE_WIDTH, &v);
 	if (v != width) {
 		printf("%s: bad width: %d, should be %d\n", TestName, v, width);
-		return PIGLIT_FAIL;
+		return false;
 	}
 
 	if (target != GL_TEXTURE_1D) {
 		glGetTexLevelParameteriv(target, 0, GL_TEXTURE_HEIGHT, &v);
 		if (v != height) {
 			printf("%s: bad height: %d, should be %d\n", TestName, v, height);
-			return PIGLIT_FAIL;
+			return false;
 		}
 	}
 
@@ -101,7 +101,7 @@ test_one_level_errors(GLenum target)
 		glGetTexLevelParameteriv(target, 0, GL_TEXTURE_DEPTH, &v);
 		if (v != depth) {
 			printf("%s: bad depth: %d, should be %d\n", TestName, v, depth);
-			return PIGLIT_FAIL;
+			return false;
 		}
 	}
 
@@ -120,32 +120,32 @@ test_one_level_errors(GLenum target)
 			     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
 		if (glGetError() != GL_INVALID_OPERATION) {
 			printf("%s: glTexImage2D failed to generate error\n", TestName);
-			return PIGLIT_FAIL;
+			return false;
 		}
 
 		glTexStorage2D(target, 1, GL_RGBA8, width, height);
 		if (glGetError() != GL_INVALID_OPERATION) {
 			printf("%s: glTexStorage2D() failed to generate error\n", TestName);
-			return PIGLIT_FAIL;
+			return false;
 		}
 
 		glCopyTexImage2D(target, 0, GL_RGBA, 0, 0, width, height, 0);
 		if (glGetError() != GL_INVALID_OPERATION) {
 			printf("%s: glCopyTexImage2D() failed to generate error\n", TestName);
-			return PIGLIT_FAIL;
+			return false;
 		}
 	}
 
 	glDeleteTextures(1, &tex);
 
-	return PIGLIT_PASS;
+	return true;
 }
 
 
 /**
  * Do error-check tests for a mipmapped texture.
  */
-static enum piglit_result
+static bool
 test_mipmap_errors(GLenum target)
 {
 	GLint width = 128, height = 64, depth = 4, levels = 8;
@@ -178,7 +178,7 @@ test_mipmap_errors(GLenum target)
 	glGetTexParameteriv(target, GL_TEXTURE_IMMUTABLE_FORMAT, &v);
 	if (!v) {
 		printf("%s: %s GL_TEXTURE_IMMUTABLE_FORMAT query returned false\n",		       TestName, targetString);
-		return PIGLIT_FAIL;
+		return false;
 	}
 
 	for (l = 0; l < levels; l++) {
@@ -186,7 +186,7 @@ test_mipmap_errors(GLenum target)
 		if (v != width) {
 			printf("%s: %s level %d: bad width: %d, should be %d\n",
 			       TestName, targetString, l, v, width);
-			return PIGLIT_FAIL;
+			return false;
 		}
 
 		if (target != GL_TEXTURE_1D) {
@@ -194,7 +194,7 @@ test_mipmap_errors(GLenum target)
 			if (v != height) {
 				printf("%s: %s level %d: bad height: %d, should be %d\n",
 				       TestName, targetString, l, v, height);
-				return PIGLIT_FAIL;
+				return false;
 			}
 		}
 
@@ -203,7 +203,7 @@ test_mipmap_errors(GLenum target)
 			if (v != depth) {
 				printf("%s: %s level %d: bad depth: %d, should be %d\n",
 				       TestName, targetString, l, v, depth);
-				return PIGLIT_FAIL;
+				return false;
 			}
 		}
 
@@ -217,7 +217,7 @@ test_mipmap_errors(GLenum target)
 
 	glDeleteTextures(1, &tex);
 
-	return PIGLIT_PASS;
+	return true;
 }
 
 
@@ -242,7 +242,7 @@ create_image(GLint w, GLint h, const GLubyte color[4])
 /**
  * Test a mip-mapped texture w/ rendering.
  */
-static enum piglit_result
+static bool
 test_2d_mipmap_rendering(void)
 {
 	GLuint tex;
@@ -269,14 +269,14 @@ test_2d_mipmap_rendering(void)
 		if (v != width) {
 			printf("%s: level %d: bad width: %d, should be %d\n",
 					 TestName, l, v, width);
-			return PIGLIT_FAIL;
+			return false;
 		}
 
 		glGetTexLevelParameteriv(GL_TEXTURE_2D, l, GL_TEXTURE_HEIGHT, &v);
 		if (v != height) {
 			printf("%s: level %d: bad height: %d, should be %d\n",
 					 TestName, l, v, height);
-			return PIGLIT_FAIL;
+			return false;
 		}
 
 		if (width > 1)
@@ -297,7 +297,7 @@ test_2d_mipmap_rendering(void)
 		if (err == GL_NO_ERROR) {
 			printf("%s: glTexSubImage2D(illegal level) failed to generate an error.\n",
 			       TestName);
-			return PIGLIT_FAIL;
+			return false;
 		}
 
 		free(buf);
@@ -334,7 +334,7 @@ test_2d_mipmap_rendering(void)
 		if (!p) {
 			printf("%s: wrong color for mipmap level %d\n",
 			       TestName, l);
-			return PIGLIT_FAIL;
+			return false;
 		}
 	}
 
@@ -342,7 +342,7 @@ test_2d_mipmap_rendering(void)
 
 	glDeleteTextures(1, &tex);
 
-	return PIGLIT_PASS;
+	return true;
 }
 
 
@@ -353,7 +353,7 @@ test_2d_mipmap_rendering(void)
  * there are many extensions/versions that could effect the lists (ex:
  * integer formats, etc.)
  */
-static enum piglit_result
+static bool
 test_internal_formats(void)
 {
 	const GLenum target = GL_TEXTURE_2D;
@@ -425,10 +425,10 @@ test_internal_formats(void)
 		glDeleteTextures(1, &tex);
 	}
 
-	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+	return pass;
 }
 	
-static enum piglit_result
+static bool
 test_immutablity(GLenum target)
 {
 	GLuint tex;
@@ -466,15 +466,23 @@ test_immutablity(GLenum target)
 	/* Other immutable tests happen per-format above */
 
 	glDeleteTextures(1, &tex);
-	return pass == true ? PIGLIT_PASS : PIGLIT_FAIL;
+	return pass;
 }
 
+#define X(f, n)								\
+	do {								\
+		const bool subtest_pass = (f);				\
+		piglit_report_subtest_result(subtest_pass		\
+					     ? PIGLIT_PASS : PIGLIT_FAIL, \
+					     (n));			\
+		pass = pass && subtest_pass;				\
+	} while (0)
+
 enum piglit_result
 piglit_display(void)
 {
-	enum piglit_result pass = PIGLIT_PASS;
-	enum piglit_result tmp;
-#define X(f, n) tmp = (f); pass = tmp != PIGLIT_PASS ? PIGLIT_FAIL : pass; piglit_report_subtest_result(tmp, (n))
+	bool pass = true;
+
 	X(test_one_level_errors(GL_TEXTURE_1D), "1D non-mipmapped");
 	X(test_one_level_errors(GL_TEXTURE_2D), "2D non-mipmapped");
 	X(test_one_level_errors(GL_TEXTURE_3D), "3D non-mipmapped");
@@ -484,8 +492,8 @@ piglit_display(void)
 	X(test_2d_mipmap_rendering(), "2D mipmap rendering");
 	X(test_internal_formats(), "internal formats");
 	X(test_immutablity(GL_TEXTURE_2D), "immutability");
-#undef X
-	return pass;
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
 }
 
 
-- 
1.8.1.4



More information about the Piglit mailing list