summaryrefslogtreecommitdiff
path: root/src/tests/emile
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2015-03-17 08:49:57 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-17 09:58:17 +0100
commit0b04186a7fd530bc36dccfd27930a18506313ee4 (patch)
tree302dd8d493f7a1b97bdae48b934ded99894c6997 /src/tests/emile
parent0f13052b6ae3e65c7a9fd99bbdb11d240147adbb (diff)
emile: initial introduction of Emile.
The intent of Emile is to be the common layer for serialisation, compression and ciphering. It will expose the library we currently use internally to an easier use from the outside (like gcrypt and lz4). It should improve portability. Instead of pushing JSON, XML and what's not to Eina, I do think that they will fit better in Emile. As for the naming of Emile, you will need to be French and say : "Un quoi ?" "Un serializer !" Regarding why it is put there in the stack. Right now there is two users of compression (eet and terminology), two users of cipher library (eet and ecore_con) and a few handful of user for serialization (eina, eet, efreet, ecore_con, ...). So the choice was quite simple, it needed to be below Eet. Now it could have been on top of Eo or integrated into Eina. One of the use case I am thinking of, is to compress Eo object when a canvas get hidden/minized. For that it require Eo to use that library and it can't be a higher level object. And with current implementation of Eo it is perfectly possible to implement such idea. So not at Eo level. As for Eina, I am starting to think it is getting to much things in its namespace. I do believe that infact Eina_Simple_XML and Eina_File should after all have landed in their own library. That's why I am putting the current logic in a new library. It is going to expand, I want it to provide an few SAX like parser for JSON, Eet_Data and protobuf with also an API like Eet_Data to directly feed those value into a C structure without using a DOM at all. It would also be the right place to experiment and benchmark for a new Eet_Data format that could be more efficient to use. So at the end, and due to how I see things going and being used, I do think it is better of in its own library.
Diffstat (limited to 'src/tests/emile')
-rw-r--r--src/tests/emile/emile_suite.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/tests/emile/emile_suite.c b/src/tests/emile/emile_suite.c
new file mode 100644
index 0000000000..2663bceaff
--- /dev/null
+++ b/src/tests/emile/emile_suite.c
@@ -0,0 +1,102 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <check.h>
9
10#include <Eina.h>
11#include <Emile.h>
12
13START_TEST(emile_test_init)
14{
15 fail_if(emile_init() <= 0);
16 fail_if(emile_shutdown() != 0);
17}
18END_TEST
19
20static void
21emile_base_test(TCase *tc)
22{
23 tcase_add_test(tc, emile_test_init);
24}
25
26static const struct {
27 const char *name;
28 void (*build)(TCase *tc);
29} tests[] = {
30 { "Emile_Base", emile_base_test }
31};
32
33static void
34_list_tests(void)
35{
36 unsigned int i;
37
38 fputs("Available tests cases :\n", stderr);
39 for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
40 fprintf(stderr, "\t%s\n", tests[i].name);
41}
42
43static Eina_Bool
44_use_test(const char *name, int argc, char *argv[])
45{
46 argc--; argv--;
47
48 if (argc < 1) return EINA_TRUE;
49
50 for (; argc > 1; argc--, argv++)
51 if (strcmp(name, *argv) == 0)
52 return EINA_TRUE;
53 return EINA_FALSE;
54}
55
56int
57main(int argc, char *argv[])
58{
59 SRunner *sr;
60 Suite *s;
61 unsigned int i;
62 int failed_count;
63 int j;
64
65 for (j = 1; j < argc; j++)
66 if ((strcmp(argv[j], "-h") == 0) ||
67 (strcmp(argv[j], "--help") == 0))
68 {
69 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
70 argv[0]);
71 _list_tests();
72 return 0;
73 }
74 else if ((strcmp(argv[j], "-l") == 0) ||
75 (strcmp(argv[j], "--list") == 0))
76 {
77 _list_tests();
78 return 0;
79 }
80
81 s = suite_create("Emile");
82
83 for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
84 {
85 TCase *tc;
86
87 if (!_use_test(tests[i].name, argc, argv)) continue ;
88
89 tc = tcase_create(tests[i].name);
90 tests[i].build(tc);
91 suite_add_tcase(s, tc);
92 tcase_set_timeout(tc, 0);
93 }
94
95 sr = srunner_create(s);
96 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
97 srunner_run_all(sr, CK_ENV);
98 failed_count = srunner_ntests_failed(sr);
99 srunner_free(sr);
100
101 return (failed_count == 0) ? 0 : 255;
102}