summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2015-04-22 14:52:55 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-22 15:10:20 +0200
commitd86ed2a46c5f6a7a76fceff7d33ed934f87bb714 (patch)
tree605f702d6fdac6db4ab87a1c77cac71cf0a491a4 /src/tests/eio
parentf4453bc00b9c27eb4d32b683dde9af000674dd9b (diff)
eio: add testcases for various eio_xattr types set and get functions.
Summary: Added test cases for eio_file_xattr_string_set, eio_file_xattr_string_get, eio_file_xattr_int_set, eio_file_xattr_int_get, eio_file_xattr_double_get, eio_file_xattr_double set functions Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D2380 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/eio_test_xattr.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/tests/eio/eio_test_xattr.c b/src/tests/eio/eio_test_xattr.c
index a9a3582f06..f28d04f680 100644
--- a/src/tests/eio/eio_test_xattr.c
+++ b/src/tests/eio/eio_test_xattr.c
@@ -13,6 +13,13 @@
13 13
14#include "eio_suite.h" 14#include "eio_suite.h"
15 15
16static char *str_attr = "user.name";
17static char *str_data = "Vivek Ellur";
18static char *int_attr = "user.id";
19static int int_data = 1234;
20static char *double_attr = "user.size";
21static double double_data = 123.456;
22
16const char *attribute[] = 23const char *attribute[] =
17 { 24 {
18 "user.comment1", 25 "user.comment1",
@@ -85,6 +92,30 @@ _done_get_cb(void *data, Eio_File *handler EINA_UNUSED, const char *name, unsign
85} 92}
86 93
87static void 94static void
95_done_string_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const char *xattr_string)
96{
97 fail_if(strcmp(xattr_string, str_data) != 0);
98
99 ecore_main_loop_quit();
100}
101
102static void
103_done_int_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int xattr_int)
104{
105 fail_if(xattr_int != int_data);
106
107 ecore_main_loop_quit();
108}
109
110static void
111_done_double_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, double xattr_double)
112{
113 fail_if(xattr_double != double_data);
114
115 ecore_main_loop_quit();
116}
117
118static void
88_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error) 119_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error)
89 120
90{ 121{
@@ -152,12 +183,84 @@ START_TEST(eio_test_xattr_set)
152 ecore_shutdown(); 183 ecore_shutdown();
153} 184}
154END_TEST 185END_TEST
186
187START_TEST(eio_test_xattr_types_set)
188{
189 char *filename = "eio-tmpfile";
190
191 Eina_Tmpstr *test_file_path;
192 int fd, num_of_attr=0;
193 Eio_File *fp;
194
195 ecore_init();
196 eina_init();
197 eio_init();
198
199 test_file_path = get_file_path(XATTR_TEST_DIR, filename);
200 fd = open(test_file_path,
201 O_WRONLY | O_CREAT | O_TRUNC,
202 S_IRWXU | S_IRWXG | S_IRWXO);
203 fail_if(fd == 0);
204 fp = eio_file_xattr_string_set(test_file_path, str_attr,
205 str_data, EINA_XATTR_INSERT,
206 _done_once_cb, _error_cb, &num_of_attr);
207
208 fail_if(num_of_attr != 0); // test asynchronous
209 fail_if(!fp);
210
211 ecore_main_loop_begin();
212
213 fp = eio_file_xattr_string_get(test_file_path, str_attr,
214 _done_string_cb, _error_cb, NULL);
215 fail_if(!fp);
216
217 ecore_main_loop_begin();
218
219 fp = eio_file_xattr_int_set(test_file_path, int_attr,
220 int_data, EINA_XATTR_INSERT,
221 _done_once_cb, _error_cb, &num_of_attr);
222
223 fail_if(num_of_attr != 0); // test asynchronous
224 fail_if(!fp);
225
226 ecore_main_loop_begin();
227
228 fp = eio_file_xattr_int_get(test_file_path, int_attr,
229 _done_int_cb, _error_cb, NULL);
230 fail_if(!fp);
231
232 ecore_main_loop_begin();
233
234 fp = eio_file_xattr_double_set(test_file_path, double_attr,
235 double_data, EINA_XATTR_INSERT,
236 _done_once_cb, _error_cb, &num_of_attr);
237
238 fail_if(num_of_attr != 0); // test asynchronous
239 fail_if(!fp);
240
241 ecore_main_loop_begin();
242
243 fp = eio_file_xattr_double_get(test_file_path, double_attr,
244 _done_double_cb, _error_cb, NULL);
245 fail_if(!fp);
246
247 ecore_main_loop_begin();
248
249 close(fd);
250 unlink(test_file_path);
251 eina_tmpstr_del(test_file_path);
252 eio_shutdown();
253 eina_shutdown();
254 ecore_shutdown();
255}
256END_TEST
155#endif 257#endif
156 258
157void eio_test_xattr(TCase *tc) 259void eio_test_xattr(TCase *tc)
158{ 260{
159#ifdef XATTR_TEST_DIR 261#ifdef XATTR_TEST_DIR
160 tcase_add_test(tc, eio_test_xattr_set); 262 tcase_add_test(tc, eio_test_xattr_set);
263 tcase_add_test(tc, eio_test_xattr_types_set);
161#else 264#else
162 (void)tc; 265 (void)tc;
163#endif 266#endif