diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c index 46325eb79..85dcac02c 100644 --- a/tests/util/piglit-framework-gl.c +++ b/tests/util/piglit-framework-gl.c @@ -176,3 +176,22 @@ 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); + *argc -= 1; + return true; + } + } + return false; +} diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h index f8f73ad3e..57b6325cd 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 */