aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/tests/eina_suite.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/tests/eina_suite.c')
-rw-r--r--libraries/eina/src/tests/eina_suite.c182
1 files changed, 0 insertions, 182 deletions
diff --git a/libraries/eina/src/tests/eina_suite.c b/libraries/eina/src/tests/eina_suite.c
deleted file mode 100644
index b34d016..0000000
--- a/libraries/eina/src/tests/eina_suite.c
+++ /dev/null
@@ -1,182 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include "eina_suite.h"
24#include "Eina.h"
25#include <stdio.h>
26#include <string.h>
27
28typedef struct _Eina_Test_Case Eina_Test_Case;
29struct _Eina_Test_Case
30{
31 const char *test_case;
32 void (*build)(TCase *tc);
33};
34
35static const Eina_Test_Case etc[] = {
36 { "FixedPoint", eina_test_fp },
37 { "Inarray", eina_test_inarray },
38 { "Array", eina_test_array },
39 { "Binary Share", eina_test_binshare },
40 { "String Share", eina_test_stringshare },
41 { "UString Share", eina_test_ustringshare },
42 { "Log", eina_test_log },
43 { "Error", eina_test_error },
44 { "Magic", eina_test_magic },
45 { "Inlist", eina_test_inlist },
46 { "Lazy alloc", eina_test_lalloc },
47 { "Main", eina_test_main },
48 { "Counter", eina_test_counter },
49 { "Hash", eina_test_hash },
50 { "List", eina_test_list },
51 { "CList", eina_test_clist },
52 { "Iterator", eina_test_iterator },
53 { "Accessor", eina_test_accessor },
54 { "Module", eina_test_module },
55 { "Convert", eina_test_convert },
56 { "Rbtree", eina_test_rbtree },
57 { "File", eina_test_file },
58 { "Benchmark", eina_test_benchmark },
59 { "Mempool", eina_test_mempool },
60 { "Rectangle", eina_test_rectangle },
61 { "Matrix Sparse", eina_test_matrixsparse },
62 { "Eina Tiler", eina_test_tiler },
63 { "Eina Strbuf", eina_test_strbuf },
64 { "Eina Binbuf", eina_test_binbuf },
65 { "String", eina_test_str },
66 { "Unicode String", eina_test_ustr },
67 { "QuadTree", eina_test_quadtree },
68 { "Sched", eina_test_sched },
69 { "Simple Xml Parser", eina_test_simple_xml_parser},
70 { "Value", eina_test_value },
71 { "Model", eina_test_model },
72 { NULL, NULL }
73};
74
75static void
76_list_tests(void)
77{
78 const Eina_Test_Case *itr = etc;
79 fputs("Available Test Cases:\n", stderr);
80 for (; itr->test_case; itr++)
81 fprintf(stderr, "\t%s\n", itr->test_case);
82}
83
84static Eina_Bool
85_use_test(int argc, const char **argv, const char *test_case)
86{
87 if (argc < 1)
88 return 1;
89
90 for (; argc > 0; argc--, argv++)
91 if (strcmp(test_case, *argv) == 0)
92 return 1;
93
94 return 0;
95}
96
97Suite *
98eina_build_suite(int argc, const char **argv)
99{
100 TCase *tc;
101 Suite *s;
102 int i;
103
104 s = suite_create("Eina");
105
106 for (i = 0; etc[i].test_case; ++i)
107 {
108 if (!_use_test(argc, argv, etc[i].test_case))
109 continue;
110
111 tc = tcase_create(etc[i].test_case);
112
113 etc[i].build(tc);
114
115 suite_add_tcase(s, tc);
116 tcase_set_timeout(tc, 0);
117 }
118
119 return s;
120}
121
122/* FIXME this is a copy from eina_test_mempool
123 * we should remove the duplication
124 */
125static Eina_Array *_modules;
126static void _mempool_init(void)
127{
128 eina_init();
129 /* force modules to be loaded in case they are not installed */
130 _modules = eina_module_list_get(NULL,
131 PACKAGE_BUILD_DIR "/src/modules",
132 EINA_TRUE,
133 NULL,
134 NULL);
135 eina_module_list_load(_modules);
136}
137
138static void _mempool_shutdown(void)
139{
140 eina_module_list_free(_modules);
141 if (_modules)
142 eina_array_free(_modules);
143 /* TODO delete the list */
144 eina_shutdown();
145}
146
147int
148main(int argc, char **argv)
149{
150 Suite *s;
151 SRunner *sr;
152 int i, failed_count;
153
154 for (i = 1; i < argc; i++)
155 if ((strcmp(argv[i], "-h") == 0) ||
156 (strcmp(argv[i], "--help") == 0))
157 {
158 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
159 argv[0]);
160 _list_tests();
161 return 0;
162 }
163 else if ((strcmp(argv[i], "-l") == 0) ||
164 (strcmp(argv[i], "--list") == 0))
165 {
166 _list_tests();
167 return 0;
168 }
169
170 s = eina_build_suite(argc - 1, (const char **)argv + 1);
171 sr = srunner_create(s);
172
173 _mempool_init();
174
175 srunner_run_all(sr, CK_ENV);
176 failed_count = srunner_ntests_failed(sr);
177 srunner_free(sr);
178
179 _mempool_shutdown();
180
181 return (failed_count == 0) ? 0 : 255;
182}