diff options
Diffstat (limited to 'lib/igt_core.h')
-rw-r--r-- | lib/igt_core.h | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h index 44634e0f..cd89921e 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -250,23 +250,38 @@ void __igt_subtest_group_restore(int); __igt_subtest_group_restore(igt_tokencat(__save,__LINE__) )) /** - * igt_main: - * - * This is a magic control flow block used instead of a main() function for - * tests with subtests. Open-coding the main() function is only recommended if - * the test needs to parse additional command line arguments of its own. - */ -#define igt_main \ + * igt_main_args: + * @extra_short_opts: getopt_long() compliant list with additional short options + * @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 is a magic control flow block used instead of a main() + * function for tests with subtests, along with custom command line + * arguments. The macro parameters are passed directly to + * #igt_subtest_init_parse_opts. + */ +#define igt_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \ 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, NULL); \ + igt_subtest_init_parse_opts(&argc, argv, \ + short_opts, long_opts, help_str, \ + opt_handler, handler_data); \ igt_tokencat(__real_main, __LINE__)(); \ igt_exit(); \ } \ static void igt_tokencat(__real_main, __LINE__)(void) \ +/** + * igt_main: + * + * This is a magic control flow block used instead of a main() function for + * tests with subtests. Open-coding the main() function is not recommended. + */ +#define igt_main igt_main_args(NULL, NULL, NULL, NULL, NULL) + const char *igt_test_name(void); void igt_simple_init_parse_opts(int *argc, char **argv, const char *extra_short_opts, @@ -289,23 +304,40 @@ void igt_simple_init_parse_opts(int *argc, char **argv, #define igt_simple_init(argc, argv) \ igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL, NULL); + /** - * igt_simple_main: + * igt_simple_main_args: + * @extra_short_opts: getopt_long() compliant list with additional short options + * @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 is a magic control flow block used instead of a main() function for - * simple tests. Open-coding the main() function is only recommended if - * the test needs to parse additional command line arguments of its own. + * This is a magic control flow block used instead of a main() + * function for simple tests with custom command line arguments. The + * macro parameters are passed directly to + * #igt_simple_init_parse_opts. */ -#define igt_simple_main \ +#define igt_simple_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \ 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, NULL); \ + igt_simple_init_parse_opts(&argc, argv, \ + short_opts, long_opts, help_str, \ + opt_handler, handler_data); \ igt_tokencat(__real_main, __LINE__)(); \ igt_exit(); \ } \ static void igt_tokencat(__real_main, __LINE__)(void) \ + +/** + * igt_simple_main: + * + * This is a magic control flow block used instead of a main() function for + * simple tests. Open-coding the main() function is not recommended. + */ +#define igt_simple_main igt_simple_main_args(NULL, NULL, NULL, NULL, NULL) + /** * igt_constructor: * |