Skip to content

Commit

Permalink
Add PIGLIT_STRIP_ARG() macro for extracting args during piglit config.
Browse files Browse the repository at this point in the history
v2: Fix update of *argc.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
  • Loading branch information
stereotype441 committed Aug 17, 2013
1 parent d0b6c69 commit de912ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/util/piglit-framework-gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions tests/util/piglit-framework-gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit de912ef

Please sign in to comment.