1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-29 13:01:13 +03:00

Factorize all the main functions in unit tests

This commit is contained in:
Aris Adamantiadis
2010-05-18 22:25:06 +02:00
parent 89993dd757
commit f95157297e
10 changed files with 36 additions and 191 deletions

View File

@ -24,3 +24,25 @@ void torture_create_case_timeout(Suite *s, const char *name, TFun function, int
tcase_add_test(tc_new, function); tcase_add_test(tc_new, function);
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
memset(&arguments,0,sizeof(struct argument_s));
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -31,4 +31,10 @@ void torture_create_case_fixture(Suite *s, const char *name, TFun function,
void torture_create_case_timeout(Suite *s, const char *name, TFun function, void torture_create_case_timeout(Suite *s, const char *name, TFun function,
int timeout); int timeout);
/*
* This function must be defined in every unit test file.
*/
Suite *torture_make_suite(void);
#endif /* _TORTURE_H */ #endif /* _TORTURE_H */

View File

@ -119,7 +119,7 @@ START_TEST (torture_algorithms_zlib)
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_algorithms"); Suite *s = suite_create("libssh_algorithms");
torture_create_case_fixture(s, "torture_algorithms_aes128-cbc", torture_create_case_fixture(s, "torture_algorithms_aes128-cbc",
@ -142,26 +142,3 @@ static Suite *torture_make_suite(void) {
torture_algorithms_zlib, setup, teardown); torture_algorithms_zlib, setup, teardown);
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -13,7 +13,7 @@ START_TEST (torture_ssh_init)
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_init"); Suite *s = suite_create("libssh_init");
torture_create_case(s, "torture_ssh_init", torture_ssh_init); torture_create_case(s, "torture_ssh_init", torture_ssh_init);
@ -21,26 +21,5 @@ static Suite *torture_make_suite(void) {
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -223,7 +223,7 @@ START_TEST(torture_privatekey_from_file_passphrase){
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_keyfiles"); Suite *s = suite_create("libssh_keyfiles");
torture_create_case_fixture(s, "torture_pubkey_from_file", torture_create_case_fixture(s, "torture_pubkey_from_file",
@ -238,26 +238,3 @@ static Suite *torture_make_suite(void) {
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -76,7 +76,7 @@ START_TEST (torture_knownhosts_port)
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_knownhosts"); Suite *s = suite_create("libssh_knownhosts");
torture_create_case_fixture(s, "torture_knownhosts_port", torture_create_case_fixture(s, "torture_knownhosts_port",
@ -84,25 +84,3 @@ static Suite *torture_make_suite(void) {
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -76,7 +76,7 @@ START_TEST(torture_ssh_list_prepend)
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_list"); Suite *s = suite_create("libssh_list");
torture_create_case(s, "torture_ssh_list_new", torture_ssh_list_new); torture_create_case(s, "torture_ssh_list_new", torture_ssh_list_new);
@ -85,27 +85,3 @@ static Suite *torture_make_suite(void) {
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -117,7 +117,7 @@ START_TEST (torture_path_expand_escape)
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_misc"); Suite *s = suite_create("libssh_misc");
torture_create_case(s, "torture_get_user_home_dir", torture_get_user_home_dir); torture_create_case(s, "torture_get_user_home_dir", torture_get_user_home_dir);
@ -131,26 +131,3 @@ static Suite *torture_make_suite(void) {
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -119,7 +119,7 @@ START_TEST (torture_options_set_identity)
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_options"); Suite *s = suite_create("libssh_options");
torture_create_case_fixture(s, "torture_options_set_host", torture_create_case_fixture(s, "torture_options_set_host",
@ -136,26 +136,3 @@ static Suite *torture_make_suite(void) {
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -41,7 +41,7 @@ START_TEST (torture_options_set_proxycommand_notexist)
} }
END_TEST END_TEST
static Suite *torture_make_suite(void) { Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_proxycommand"); Suite *s = suite_create("libssh_proxycommand");
torture_create_case_fixture(s, "torture_options_set_proxycommand", torture_create_case_fixture(s, "torture_options_set_proxycommand",
@ -52,27 +52,3 @@ static Suite *torture_make_suite(void) {
return s; return s;
} }
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
torture_cmdline_parse(argc, argv, &arguments);
s = torture_make_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}