[Piglit] [PATCH 2/3] util: Move piglit_strip_arg()

Chad Versace chad.versace at linux.intel.com
Tue Nov 26 12:46:35 PST 2013


Move it from piglit-framework-gl.h to piglit-util.h. This is a generic
utility that should not be restricted GL tests.

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 tests/util/piglit-framework-gl.c | 18 ------------------
 tests/util/piglit-framework-gl.h |  1 -
 tests/util/piglit-util.c         | 21 +++++++++++++++++++++
 tests/util/piglit-util.h         |  3 +++
 4 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c
index ce8b552..a0ccbe0 100644
--- a/tests/util/piglit-framework-gl.c
+++ b/tests/util/piglit-framework-gl.c
@@ -228,24 +228,6 @@ piglit_set_reshape_func(void (*func)(int w, int h))
 }
 
 
-/**
- * Search for an argument with the given name in the argument list.
- * If it is found, remove it and return true.
- */
-bool
-piglit_strip_arg(int *argc, char *argv[], const char *arg)
-{
-	int i;
-	for (i = 1; i < *argc; i++) {
-		if (!strcmp(argv[i], arg)) {
-			delete_arg(argv, *argc, i);
-			*argc -= 1;
-			return true;
-		}
-	}
-	return false;
-}
-
 enum piglit_result
 piglit_create_dma_buf(unsigned w, unsigned h, unsigned cpp,
 		      const void *src_data, unsigned src_stride,
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index fa61d08..c2de123 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -308,7 +308,6 @@ void piglit_present_results();
 void piglit_post_redisplay(void);
 void piglit_set_keyboard_func(void (*func)(unsigned char key, int x, int y));
 void piglit_set_reshape_func(void (*func)(int w, int h));
-bool piglit_strip_arg(int *argc, char *argv[], const char *arg);
 
 /**
  * Convenience macro for invoking piglit_strip_arg() from within
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 6ddc4ee..1c7f118 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -512,3 +512,24 @@ piglit_get_microseconds(void)
 #endif
 }
 
+/**
+ * Search for an argument with the given name in the argument list.
+ * If it is found, remove it and return true.
+ */
+bool
+piglit_strip_arg(int *argc, char *argv[], const char *arg)
+{
+        int i;
+        for (i = 1; i < *argc; i++) {
+                if (strcmp(argv[i], arg) != 0)
+                	continue;
+
+                for (i += 1; i < *argc; ++i)
+			argv[i-1] = argv[i];
+
+		*argc -= 1;
+		return true;
+	}
+
+        return false;
+}
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 9409507..4535fad 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -187,6 +187,9 @@ piglit_get_microseconds(void);
 const char**
 piglit_split_string_to_array(const char *string, const char *separators);
 
+bool
+piglit_strip_arg(int *argc, char *argv[], const char *arg);
+
 #ifdef __cplusplus
 } /* end extern "C" */
 #endif
-- 
1.8.4



More information about the Piglit mailing list