summaryrefslogtreecommitdiff
path: root/src/tests/ecore_con/ecore_con_suite.c
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-04-06 15:59:10 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-06 16:37:53 +0200
commit4b0e8795919d146b66f14b64d70dbb5a2796b8b9 (patch)
tree480abf25d22b0c2ddba73b2497e0487c2a6d3611 /src/tests/ecore_con/ecore_con_suite.c
parent39432aa0f2ff65510c423c264818999f2d12ea84 (diff)
ecore_con: Split ecore_con test suite from ecore.
Summary: Have created ecore_con test suite. Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric, Sergeant_Whitespace, stefan_schmidt Subscribers: stefan_schmidt, Sergeant_Whitespace, cedric Maniphest Tasks: T2235 Differential Revision: https://phab.enlightenment.org/D2269
Diffstat (limited to 'src/tests/ecore_con/ecore_con_suite.c')
-rw-r--r--src/tests/ecore_con/ecore_con_suite.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/tests/ecore_con/ecore_con_suite.c b/src/tests/ecore_con/ecore_con_suite.c
new file mode 100644
index 0000000000..b695873e5e
--- /dev/null
+++ b/src/tests/ecore_con/ecore_con_suite.c
@@ -0,0 +1,106 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include "Ecore.h"
9
10#include "ecore_con_suite.h"
11
12typedef struct _Ecore_Con_Test_Case Ecore_Con_Test_Case;
13
14struct _Ecore_Con_Test_Case
15{
16 const char *test_case;
17 void (*build)(TCase *tc);
18};
19
20static const Ecore_Con_Test_Case etc[] = {
21 { "Ecore_Con", ecore_con_test_ecore_con },
22 { "Ecore_Con_Url", ecore_con_test_ecore_con_url },
23 { NULL, NULL }
24};
25
26static void
27_list_tests(void)
28{
29 const Ecore_Con_Test_Case *itr;
30
31 itr = etc;
32 fputs("Available Test Cases:\n", stderr);
33 for (; itr->test_case; itr++)
34 fprintf(stderr, "\t%s\n", itr->test_case);
35}
36static Eina_Bool
37_use_test(int argc, const char **argv, const char *test_case)
38{
39 if (argc < 1)
40 return 1;
41
42 for (; argc > 0; argc--, argv++)
43 if (strcmp(test_case, *argv) == 0)
44 return 1;
45 return 0;
46}
47
48static Suite *
49ecore_con_suite_build(int argc, const char **argv)
50{
51 TCase *tc;
52 Suite *s;
53 int i;
54
55 s = suite_create("Ecore_Con");
56
57 for (i = 0; etc[i].test_case; ++i)
58 {
59 if (!_use_test(argc, argv, etc[i].test_case)) continue;
60 tc = tcase_create(etc[i].test_case);
61
62 etc[i].build(tc);
63
64 suite_add_tcase(s, tc);
65 tcase_set_timeout(tc, 0);
66 }
67
68 return s;
69}
70
71int
72main(int argc, char **argv)
73{
74 Suite *s;
75 SRunner *sr;
76 int i, failed_count;
77
78 for (i = 1; i < argc; i++)
79 if ((strcmp(argv[i], "-h") == 0) ||
80 (strcmp(argv[i], "--help") == 0))
81 {
82 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
83 argv[0]);
84 _list_tests();
85 return 0;
86 }
87 else if ((strcmp(argv[i], "-l") == 0) ||
88 (strcmp(argv[i], "--list") == 0))
89 {
90 _list_tests();
91 return 0;
92 }
93
94 putenv("EFL_RUN_IN_TREE=1");
95
96 s = ecore_con_suite_build(argc - 1, (const char **)argv + 1);
97 sr = srunner_create(s);
98
99 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
100
101 srunner_run_all(sr, CK_ENV);
102 failed_count = srunner_ntests_failed(sr);
103 srunner_free(sr);
104
105 return (failed_count == 0) ? 0 : 255;
106}