lib: use defines for igt_simple_init and igt_subtest_init

Using defines removes an extra function call and prepares for changes
to the command line argument handling.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
Thomas Wood 2015-02-17 15:10:13 +00:00
parent efddb93680
commit 55cc132b32
2 changed files with 32 additions and 38 deletions

View File

@ -695,40 +695,6 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
enum igt_log_level igt_log_level = IGT_LOG_INFO;
/**
* igt_subtest_init:
* @argc: argc from the test's main()
* @argv: argv from the test's main()
*
* This initializes the for tests with subtests without the need for additional
* cmdline options. It is just a simplified version of
* igt_subtest_init_parse_opts().
*
* If there's not a reason to the contrary it's less error prone to just use an
* #igt_main block instead of stitching the tests's main() function together
* manually.
*/
void igt_subtest_init(int argc, char **argv)
{
igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
}
/**
* igt_simple_init:
* @argc: argc from the test's main()
* @argv: argv from the test's main()
*
* This initializes a simple test without any support for subtests.
*
* If there's not a reason to the contrary it's less error prone to just use an
* #igt_simple_main block instead of stitching the tests's main() function together
* manually.
*/
void igt_simple_init(int argc, char **argv)
{
common_init(argc, argv, NULL, NULL, NULL, NULL);
}
/**
* igt_simple_init_parse_opts:
* @argc: argc from the test's main()

View File

@ -106,7 +106,6 @@ void __igt_fixture_end(void) __attribute__((noreturn));
/* subtest infrastructure */
jmp_buf igt_subtest_jmpbuf;
void igt_subtest_init(int argc, char **argv);
typedef int (*igt_opt_handler_t)(int opt, int opt_index);
#ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
struct option;
@ -117,6 +116,22 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
const char *help_str,
igt_opt_handler_t extra_opt_handler);
/**
* igt_subtest_init:
* @argc: argc from the test's main()
* @argv: argv from the test's main()
*
* This initializes the for tests with subtests without the need for additional
* cmdline options. It is just a simplified version of
* igt_subtest_init_parse_opts().
*
* If there's not a reason to the contrary it's less error prone to just use an
* #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);
bool __igt_run_subtest(const char *subtest_name);
#define __igt_tokencat2(x, y) x ## y
@ -180,19 +195,32 @@ 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(argc, argv); \
igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
igt_tokencat(__real_main, __LINE__)(); \
igt_exit(); \
} \
static void igt_tokencat(__real_main, __LINE__)(void) \
void igt_simple_init(int argc, char **argv);
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_simple_init:
* @argc: argc from the test's main()
* @argv: argv from the test's main()
*
* This initializes a simple test without any support for subtests.
*
* If there's not a reason to the contrary it's less error prone to just use an
* #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);
/**
* igt_simple_main:
*
@ -203,7 +231,7 @@ 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(argc, argv); \
igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
igt_tokencat(__real_main, __LINE__)(); \
igt_exit(); \
} \