diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-05-18 22:25:06 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-05-18 22:25:06 +0200 |
commit | f95157297e1c6dc0cf1fce12d3e10bb16fbf40f8 (patch) | |
tree | d0805c50f5af648abc204306009c2e555f263521 /tests | |
parent | 89993dd75713b68f4ffebf9a30d03b1991c25b15 (diff) | |
download | libssh-f95157297e1c6dc0cf1fce12d3e10bb16fbf40f8.tar.gz libssh-f95157297e1c6dc0cf1fce12d3e10bb16fbf40f8.tar.xz libssh-f95157297e1c6dc0cf1fce12d3e10bb16fbf40f8.zip |
Factorize all the main functions in unit tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/torture.c | 22 | ||||
-rw-r--r-- | tests/torture.h | 6 | ||||
-rw-r--r-- | tests/unittests/torture_algorithms.c | 25 | ||||
-rw-r--r-- | tests/unittests/torture_init.c | 23 | ||||
-rw-r--r-- | tests/unittests/torture_keyfiles.c | 25 | ||||
-rw-r--r-- | tests/unittests/torture_knownhosts.c | 24 | ||||
-rw-r--r-- | tests/unittests/torture_list.c | 26 | ||||
-rw-r--r-- | tests/unittests/torture_misc.c | 25 | ||||
-rw-r--r-- | tests/unittests/torture_options.c | 25 | ||||
-rw-r--r-- | tests/unittests/torture_proxycommand.c | 26 |
10 files changed, 36 insertions, 191 deletions
diff --git a/tests/torture.c b/tests/torture.c index 6fa4c459..6b7484e9 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -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; +} diff --git a/tests/torture.h b/tests/torture.h index 542b2757..2be45644 100644 --- a/tests/torture.h +++ b/tests/torture.h @@ -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 */ diff --git a/tests/unittests/torture_algorithms.c b/tests/unittests/torture_algorithms.c index dcaca216..300fe054 100644 --- a/tests/unittests/torture_algorithms.c +++ b/tests/unittests/torture_algorithms.c @@ -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; -} diff --git a/tests/unittests/torture_init.c b/tests/unittests/torture_init.c index 8299cf67..8b09d36b 100644 --- a/tests/unittests/torture_init.c +++ b/tests/unittests/torture_init.c @@ -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; -} diff --git a/tests/unittests/torture_keyfiles.c b/tests/unittests/torture_keyfiles.c index 7f57b5bf..d99ac0a3 100644 --- a/tests/unittests/torture_keyfiles.c +++ b/tests/unittests/torture_keyfiles.c @@ -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; -} - diff --git a/tests/unittests/torture_knownhosts.c b/tests/unittests/torture_knownhosts.c index 2f38bfd2..2a7cdab9 100644 --- a/tests/unittests/torture_knownhosts.c +++ b/tests/unittests/torture_knownhosts.c @@ -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; -} diff --git a/tests/unittests/torture_list.c b/tests/unittests/torture_list.c index 8a82072a..d954100a 100644 --- a/tests/unittests/torture_list.c +++ b/tests/unittests/torture_list.c @@ -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; -} - diff --git a/tests/unittests/torture_misc.c b/tests/unittests/torture_misc.c index 6904997e..5996bd97 100644 --- a/tests/unittests/torture_misc.c +++ b/tests/unittests/torture_misc.c @@ -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; -} - diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c index ec173f24..5a83a2fd 100644 --- a/tests/unittests/torture_options.c +++ b/tests/unittests/torture_options.c @@ -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; -} - diff --git a/tests/unittests/torture_proxycommand.c b/tests/unittests/torture_proxycommand.c index 8bc601c3..3ee30a74 100644 --- a/tests/unittests/torture_proxycommand.c +++ b/tests/unittests/torture_proxycommand.c @@ -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; -} - |