aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-05-18 22:25:06 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-05-18 22:25:06 +0200
commitf95157297e1c6dc0cf1fce12d3e10bb16fbf40f8 (patch)
treed0805c50f5af648abc204306009c2e555f263521
parent89993dd75713b68f4ffebf9a30d03b1991c25b15 (diff)
downloadlibssh-f95157297e1c6dc0cf1fce12d3e10bb16fbf40f8.tar.gz
libssh-f95157297e1c6dc0cf1fce12d3e10bb16fbf40f8.tar.xz
libssh-f95157297e1c6dc0cf1fce12d3e10bb16fbf40f8.zip
Factorize all the main functions in unit tests
-rw-r--r--tests/torture.c22
-rw-r--r--tests/torture.h6
-rw-r--r--tests/unittests/torture_algorithms.c25
-rw-r--r--tests/unittests/torture_init.c23
-rw-r--r--tests/unittests/torture_keyfiles.c25
-rw-r--r--tests/unittests/torture_knownhosts.c24
-rw-r--r--tests/unittests/torture_list.c26
-rw-r--r--tests/unittests/torture_misc.c25
-rw-r--r--tests/unittests/torture_options.c25
-rw-r--r--tests/unittests/torture_proxycommand.c26
10 files changed, 36 insertions, 191 deletions
diff --git a/tests/torture.c b/tests/torture.c
index 6fa4c45..6b7484e 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 542b275..2be4564 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 dcaca21..300fe05 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 8299cf6..8b09d36 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 7f57b5b..d99ac0a 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 2f38bfd..2a7cdab 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 8a82072..d954100 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 6904997..5996bd9 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 ec173f2..5a83a2f 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 8bc601c..3ee30a7 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;
-}
-