summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_core.c17
-rw-r--r--lib/igt_core.h20
2 files changed, 24 insertions, 13 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249f..6dd7af39 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -501,7 +501,8 @@ static int common_init(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)
{
int c, option_index = 0, i, x;
static struct option long_options[] = {
@@ -627,7 +628,7 @@ static int common_init(int *argc, char **argv,
ret = -2;
goto out;
default:
- ret = extra_opt_handler(c, option_index);
+ ret = extra_opt_handler(c, option_index, handler_data);
if (ret)
goto out;
}
@@ -683,6 +684,7 @@ out:
* @extra_long_opts: getopt_long() compliant list with additional long options
* @help_str: help string for the additional options
* @extra_opt_handler: handler for the additional options
+ * @handler_data: user data given to @extra_opt_handler when invoked
*
* This function handles the subtest related cmdline options and allows an
* arbitrary set of additional options. This is useful for tests which have
@@ -698,13 +700,14 @@ 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)
{
int ret;
test_with_subtests = true;
ret = common_init(argc, argv, extra_short_opts, extra_long_opts,
- help_str, extra_opt_handler);
+ help_str, extra_opt_handler, handler_data);
return ret;
}
@@ -719,6 +722,7 @@ enum igt_log_level igt_log_level = IGT_LOG_INFO;
* @extra_long_opts: getopt_long() compliant list with additional long options
* @help_str: help string for the additional options
* @extra_opt_handler: handler for the additional options
+ * @handler_data: user data given to @extra_opt_handler when invoked
*
* This initializes a simple test without any support for subtests and allows
* an arbitrary set of additional options.
@@ -727,10 +731,11 @@ 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)
{
common_init(argc, argv, extra_short_opts, extra_long_opts, help_str,
- extra_opt_handler);
+ extra_opt_handler, handler_data);
}
/*
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(); \
} \