From: Lucas De Marchi Date: Tue, 7 Feb 2012 12:09:20 +0000 (-0200) Subject: testsuite: macronify main function X-Git-Tag: v6~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e9fa9de3c9fa60f85baddee6fc07229b2c48b2f9;p=thirdparty%2Fkmod.git testsuite: macronify main function --- diff --git a/testsuite/test-alias.c b/testsuite/test-alias.c index b7afd718..2e84e6b3 100644 --- a/testsuite/test-alias.c +++ b/testsuite/test-alias.c @@ -74,30 +74,4 @@ static const struct test *tests[] = { NULL, }; -int main(int argc, char *argv[]) -{ - const struct test *t; - int arg; - size_t i; - - arg = test_init(argc, argv, tests); - if (arg == 0) - return 0; - - if (arg < argc) { - t = test_find(tests, argv[arg]); - if (t == NULL) { - fprintf(stderr, "could not find test %s\n", argv[arg]); - exit(EXIT_FAILURE); - } - - return test_run(t); - } - - for (i = 0; tests[i] != NULL; i++) { - if (test_run(tests[i]) != 0) - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} +TESTSUITE_MAIN(tests); diff --git a/testsuite/test-init.c b/testsuite/test-init.c index 0b636eba..d6e1e5c8 100644 --- a/testsuite/test-init.c +++ b/testsuite/test-init.c @@ -125,30 +125,4 @@ static const struct test *tests[] = { NULL, }; -int main(int argc, char *argv[]) -{ - const struct test *t; - int arg; - size_t i; - - arg = test_init(argc, argv, tests); - if (arg == 0) - return 0; - - if (arg < argc) { - t = test_find(tests, argv[arg]); - if (t == NULL) { - fprintf(stderr, "could not find test %s\n", argv[arg]); - exit(EXIT_FAILURE); - } - - return test_run(t); - } - - for (i = 0; tests[i] != NULL; i++) { - if (test_run(tests[i]) != 0) - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} +TESTSUITE_MAIN(tests); diff --git a/testsuite/test-loaded.c b/testsuite/test-loaded.c index 070351c1..cfeb1b49 100644 --- a/testsuite/test-loaded.c +++ b/testsuite/test-loaded.c @@ -95,30 +95,4 @@ static const struct test *tests[] = { NULL, }; -int main(int argc, char *argv[]) -{ - const struct test *t; - int arg; - size_t i; - - arg = test_init(argc, argv, tests); - if (arg == 0) - return 0; - - if (arg < argc) { - t = test_find(tests, argv[arg]); - if (t == NULL) { - fprintf(stderr, "could not find test %s\n", argv[arg]); - exit(EXIT_FAILURE); - } - - return test_run(t); - } - - for (i = 0; tests[i] != NULL; i++) { - if (test_run(tests[i]) != 0) - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} +TESTSUITE_MAIN(tests); diff --git a/testsuite/test-modinfo.c b/testsuite/test-modinfo.c index 1b09bf28..3047d269 100644 --- a/testsuite/test-modinfo.c +++ b/testsuite/test-modinfo.c @@ -55,30 +55,4 @@ static const struct test *tests[] = { NULL, }; -int main(int argc, char *argv[]) -{ - const struct test *t; - int arg; - size_t i; - - arg = test_init(argc, argv, tests); - if (arg == 0) - return 0; - - if (arg < argc) { - t = test_find(tests, argv[arg]); - if (t == NULL) { - fprintf(stderr, "could not find test %s\n", argv[arg]); - exit(EXIT_FAILURE); - } - - return test_run(t); - } - - for (i = 0; tests[i] != NULL; i++) { - if (test_run(tests[i]) != 0) - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} +TESTSUITE_MAIN(tests); diff --git a/testsuite/test-new-module.c b/testsuite/test-new-module.c index 1aa8ec9f..117d9788 100644 --- a/testsuite/test-new-module.c +++ b/testsuite/test-new-module.c @@ -127,30 +127,4 @@ static const struct test *tests[] = { NULL, }; -int main(int argc, char *argv[]) -{ - const struct test *t; - int arg; - size_t i; - - arg = test_init(argc, argv, tests); - if (arg == 0) - return 0; - - if (arg < argc) { - t = test_find(tests, argv[arg]); - if (t == NULL) { - fprintf(stderr, "could not find test %s\n", argv[arg]); - exit(EXIT_FAILURE); - } - - return test_run(t); - } - - for (i = 0; tests[i] != NULL; i++) { - if (test_run(tests[i]) != 0) - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} +TESTSUITE_MAIN(tests); diff --git a/testsuite/test-testsuite.c b/testsuite/test-testsuite.c index 83ba0030..6967b748 100644 --- a/testsuite/test-testsuite.c +++ b/testsuite/test-testsuite.c @@ -181,30 +181,4 @@ static const struct test *tests[] = { NULL, }; -int main(int argc, char *argv[]) -{ - const struct test *t; - int arg; - size_t i; - - arg = test_init(argc, argv, tests); - if (arg == 0) - return 0; - - if (arg < argc) { - t = test_find(tests, argv[arg]); - if (t == NULL) { - fprintf(stderr, "could not find test %s\n", argv[arg]); - exit(EXIT_FAILURE); - } - - return test_run(t); - } - - for (i = 0; tests[i] != NULL; i++) { - if (test_run(tests[i]) != 0) - exit(EXIT_FAILURE); - } - - exit(EXIT_SUCCESS); -} +TESTSUITE_MAIN(tests); diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h index 012e5103..8bb0fa7a 100644 --- a/testsuite/testsuite.h +++ b/testsuite/testsuite.h @@ -107,4 +107,33 @@ int test_run(const struct test *t); .func = _name, \ } +#define TESTSUITE_MAIN(_tests) \ + int main(int argc, char *argv[]) \ + { \ + const struct test *t; \ + int arg; \ + size_t i; \ + \ + arg = test_init(argc, argv, tests); \ + if (arg == 0) \ + return 0; \ + \ + if (arg < argc) { \ + t = test_find(tests, argv[arg]); \ + if (t == NULL) { \ + fprintf(stderr, "could not find test %s\n", argv[arg]);\ + exit(EXIT_FAILURE); \ + } \ + \ + return test_run(t); \ + } \ + \ + for (i = 0; tests[i] != NULL; i++) { \ + if (test_run(tests[i]) != 0) \ + exit(EXIT_FAILURE); \ + } \ + \ + exit(EXIT_SUCCESS); \ + } \ + #endif