aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/tests/ecore_suite.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/tests/ecore_suite.c')
-rw-r--r--libraries/ecore/src/tests/ecore_suite.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/libraries/ecore/src/tests/ecore_suite.c b/libraries/ecore/src/tests/ecore_suite.c
new file mode 100644
index 0000000..fd51750
--- /dev/null
+++ b/libraries/ecore/src/tests/ecore_suite.c
@@ -0,0 +1,103 @@
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_suite.h"
11
12typedef struct _Ecore_Test_Case Ecore_Test_Case;
13
14struct _Ecore_Test_Case
15{
16 const char *test_case;
17 void (*build)(TCase *tc);
18};
19
20static const Ecore_Test_Case etc[] = {
21 { "Ecore", ecore_test_ecore },
22 { "Ecore_Con", ecore_test_ecore_con },
23 { "Ecore_X", ecore_test_ecore_x },
24 { NULL, NULL }
25};
26
27static void
28_list_tests(void)
29{
30 const Ecore_Test_Case *itr;
31
32 itr = etc;
33 fputs("Available Test Cases:\n", stderr);
34 for (; itr->test_case; itr++)
35 fprintf(stderr, "\t%s\n", itr->test_case);
36}
37static Eina_Bool
38_use_test(int argc, const char **argv, const char *test_case)
39{
40 if (argc < 1)
41 return 1;
42
43 for (; argc > 0; argc--, argv++)
44 if (strcmp(test_case, *argv) == 0)
45 return 1;
46 return 0;
47}
48
49static Suite *
50ecore_suite_build(int argc, const char **argv)
51{
52 TCase *tc;
53 Suite *s;
54 int i;
55
56 s = suite_create("Ecore");
57
58 for (i = 0; etc[i].test_case; ++i)
59 {
60 if (!_use_test(argc, argv, etc[i].test_case)) continue;
61 tc = tcase_create(etc[i].test_case);
62
63 etc[i].build(tc);
64
65 suite_add_tcase(s, tc);
66 tcase_set_timeout(tc, 0);
67 }
68
69 return s;
70}
71
72int
73main(int argc, char **argv)
74{
75 Suite *s;
76 SRunner *sr;
77 int i, failed_count;
78
79 for (i = 1; i < argc; i++)
80 if ((strcmp(argv[i], "-h") == 0) ||
81 (strcmp(argv[i], "--help") == 0))
82 {
83 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
84 argv[0]);
85 _list_tests();
86 return 0;
87 }
88 else if ((strcmp(argv[i], "-l") == 0) ||
89 (strcmp(argv[i], "--list") == 0))
90 {
91 _list_tests();
92 return 0;
93 }
94
95 s = ecore_suite_build(argc - 1, (const char **)argv + 1);
96 sr = srunner_create(s);
97
98 srunner_run_all(sr, CK_ENV);
99 failed_count = srunner_ntests_failed(sr);
100 srunner_free(sr);
101
102 return (failed_count == 0) ? 0 : 255;
103}