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:
@ -24,3 +24,25 @@ void torture_create_case_timeout(Suite *s, const char *name, TFun function, int
|
||||
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;
|
||||
}
|
||||
|
@ -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,
|
||||
int timeout);
|
||||
|
||||
/*
|
||||
* This function must be defined in every unit test file.
|
||||
*/
|
||||
Suite *torture_make_suite(void);
|
||||
|
||||
|
||||
#endif /* _TORTURE_H */
|
||||
|
@ -119,7 +119,7 @@ START_TEST (torture_algorithms_zlib)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_algorithms");
|
||||
|
||||
torture_create_case_fixture(s, "torture_algorithms_aes128-cbc",
|
||||
@ -142,26 +142,3 @@ static Suite *torture_make_suite(void) {
|
||||
torture_algorithms_zlib, setup, teardown);
|
||||
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;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ START_TEST (torture_ssh_init)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_init");
|
||||
|
||||
torture_create_case(s, "torture_ssh_init", torture_ssh_init);
|
||||
@ -21,26 +21,5 @@ static Suite *torture_make_suite(void) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ START_TEST(torture_privatekey_from_file_passphrase){
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_keyfiles");
|
||||
|
||||
torture_create_case_fixture(s, "torture_pubkey_from_file",
|
||||
@ -238,26 +238,3 @@ static Suite *torture_make_suite(void) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ START_TEST (torture_knownhosts_port)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_knownhosts");
|
||||
|
||||
torture_create_case_fixture(s, "torture_knownhosts_port",
|
||||
@ -84,25 +84,3 @@ static Suite *torture_make_suite(void) {
|
||||
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;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ START_TEST(torture_ssh_list_prepend)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_list");
|
||||
|
||||
torture_create_case(s, "torture_ssh_list_new", torture_ssh_list_new);
|
||||
@ -85,27 +85,3 @@ static Suite *torture_make_suite(void) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ START_TEST (torture_path_expand_escape)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_misc");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ START_TEST (torture_options_set_identity)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_options");
|
||||
|
||||
torture_create_case_fixture(s, "torture_options_set_host",
|
||||
@ -136,26 +136,3 @@ static Suite *torture_make_suite(void) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ START_TEST (torture_options_set_proxycommand_notexist)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *torture_make_suite(void) {
|
||||
Suite *torture_make_suite(void) {
|
||||
Suite *s = suite_create("libssh_proxycommand");
|
||||
|
||||
torture_create_case_fixture(s, "torture_options_set_proxycommand",
|
||||
@ -52,27 +52,3 @@ static Suite *torture_make_suite(void) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user