summaryrefslogtreecommitdiff
path: root/lib/igt_core.h
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2015-05-14 14:19:01 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2015-05-15 12:22:14 +0100
commitfd6846c99f00e265f558cf0106c833b96caf977f (patch)
tree44831be4a5e81f6cbbea73e6734dbaf68b99ad14 /lib/igt_core.h
parent7a5e1c6f0aebcfabecc3db96cb87add894530326 (diff)
lib: Add a user data pointer to the argument parsing functions
It can be useful to have one of those to carry state between the handler parsing the options and the rest of the test. Right now the only thing we can do is to use global variables for that. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib/igt_core.h')
-rw-r--r--lib/igt_core.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h
index b15d9ffe..d79f6d29 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -113,7 +113,7 @@ void __igt_fixture_end(void) __attribute__((noreturn));
/* subtest infrastructure */
jmp_buf igt_subtest_jmpbuf;
-typedef int (*igt_opt_handler_t)(int opt, int opt_index);
+typedef int (*igt_opt_handler_t)(int opt, int opt_index, void *data);
#ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
struct option;
#endif
@@ -121,7 +121,8 @@ int igt_subtest_init_parse_opts(int *argc, char **argv,
const char *extra_short_opts,
struct option *extra_long_opts,
const char *help_str,
- igt_opt_handler_t extra_opt_handler);
+ igt_opt_handler_t extra_opt_handler,
+ void *handler_data);
/**
@@ -137,7 +138,8 @@ int igt_subtest_init_parse_opts(int *argc, char **argv,
* #igt_main block instead of stitching the test's main() function together
* manually.
*/
-#define igt_subtest_init(argc, argv) igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL);
+#define igt_subtest_init(argc, argv) \
+ igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL, NULL);
bool __igt_run_subtest(const char *subtest_name);
#define __igt_tokencat2(x, y) x ## y
@@ -202,7 +204,8 @@ bool igt_only_list_subtests(void);
#define igt_main \
static void igt_tokencat(__real_main, __LINE__)(void); \
int main(int argc, char **argv) { \
- igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL); \
+ igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, \
+ NULL, NULL); \
igt_tokencat(__real_main, __LINE__)(); \
igt_exit(); \
} \
@@ -214,7 +217,8 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
const char *extra_short_opts,
struct option *extra_long_opts,
const char *help_str,
- igt_opt_handler_t extra_opt_handler);
+ igt_opt_handler_t extra_opt_handler,
+ void *handler_data);
/**
* igt_simple_init:
@@ -227,7 +231,8 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
* #igt_simple_main block instead of stitching the test's main() function together
* manually.
*/
-#define igt_simple_init(argc, argv) igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL);
+#define igt_simple_init(argc, argv) \
+ igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL, NULL);
/**
* igt_simple_main:
@@ -239,7 +244,8 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
#define igt_simple_main \
static void igt_tokencat(__real_main, __LINE__)(void); \
int main(int argc, char **argv) { \
- igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL); \
+ igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, \
+ NULL, NULL); \
igt_tokencat(__real_main, __LINE__)(); \
igt_exit(); \
} \