[Piglit] [PATCH 4/5] texwrap: Refactor getting the test vector for a name

Ian Romanick idr at freedesktop.org
Wed Dec 2 08:43:55 PST 2015


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

The indentation was getting a bit out of hand, and the next patch was
going to make it even worse.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/texturing/texwrap.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/tests/texturing/texwrap.c b/tests/texturing/texwrap.c
index 60ffa73..b88f410 100644
--- a/tests/texturing/texwrap.c
+++ b/tests/texturing/texwrap.c
@@ -1711,6 +1711,29 @@ static const char *fp_offset =
 	"   } \n"
 	"} \n";
 
+static bool
+get_test_by_name(const char *name, const struct test_desc **t)
+{
+	unsigned i;
+
+	for (i = 0; test_sets[i].name; i++) {
+		if (strcmp(name, test_sets[i].name) == 0) {
+			int j;
+			for (j = 0; j < ARRAY_SIZE(test_sets[i].ext); j++) {
+				if (test_sets[i].ext[j]) {
+					piglit_require_extension(test_sets[i].ext[j]);
+				}
+			}
+
+			printf("Testing %s.\n", test_sets[i].name);
+			*t = &test_sets[i];
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void piglit_init(int argc, char **argv)
 {
 	unsigned i, p, fp;
@@ -1780,19 +1803,8 @@ void piglit_init(int argc, char **argv)
 			continue;
 		}
 
-		for (i = 0; test_sets[i].name; i++) {
-			if (strcmp(argv[p], test_sets[i].name) == 0) {
-				int j;
-				for (j = 0; j < ARRAY_SIZE(test_sets[i].ext); j++) {
-					if (test_sets[i].ext[j]) {
-						piglit_require_extension(test_sets[i].ext[j]);
-					}
-				}
-				test = &test_sets[i];
-				printf("Testing %s.\n", test->name);
-				goto outer_continue;
-			}
-		}
+		if (get_test_by_name(argv[p], &test))
+			continue;
 
 		if (test) {
 			/* Formats. */
-- 
2.5.0



More information about the Piglit mailing list