testsuite: macronify main function

This commit is contained in:
Lucas De Marchi 2012-02-07 10:09:20 -02:00
parent d35e8832a6
commit e9fa9de3c9
7 changed files with 35 additions and 162 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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