[Piglit] [PATCH 1/6] Add PIGLIT_STRIP_ARG() macro for extracting args during piglit config.

Paul Berry stereotype441 at gmail.com
Wed Aug 7 13:28:38 PDT 2013


---
 tests/util/piglit-framework-gl.c | 18 ++++++++++++++++++
 tests/util/piglit-framework-gl.h |  8 ++++++++
 2 files changed, 26 insertions(+)

diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c
index 46325eb..1ce3a07 100644
--- a/tests/util/piglit-framework-gl.c
+++ b/tests/util/piglit-framework-gl.c
@@ -176,3 +176,21 @@ piglit_set_reshape_func(void (*func)(int w, int h))
 	if (!gl_fw->set_reshape_func)
 		gl_fw->set_reshape_func(gl_fw, func);
 }
+
+
+/**
+ * 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);
+			return true;
+		}
+	}
+	return false;
+}
diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index f8f73ad..57b6325 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -249,5 +249,13 @@ 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
+ * piglit_init() or between PIGLIT_GL_TEST_CONFIG_BEGIN and
+ * PIGLIT_GL_TEST_CONFIG_END.
+ */
+#define PIGLIT_STRIP_ARG(arg) piglit_strip_arg(&argc, argv, arg)
 
 #endif /* PIGLIT_FRAMEWORK_H */
-- 
1.8.3.4



More information about the Piglit mailing list