summaryrefslogtreecommitdiff
path: root/src/tests/eio/eio_test_manager_xattr.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-08-26 16:52:11 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-09-08 15:16:42 -0700
commit8e8c50e7a187ecef73c20e0e368351e7751100f9 (patch)
tree97a12c893083b50a9eecc417a7c366ed949a4140 /src/tests/eio/eio_test_manager_xattr.c
parent52c63190d5b9906698b5e1872ce6448185218d91 (diff)
eio: fix manager tests.
Diffstat (limited to '')
-rw-r--r--src/tests/eio/eio_test_manager_xattr.c96
1 files changed, 46 insertions, 50 deletions
diff --git a/src/tests/eio/eio_test_manager_xattr.c b/src/tests/eio/eio_test_manager_xattr.c
index acee0b4707..180a080c94 100644
--- a/src/tests/eio/eio_test_manager_xattr.c
+++ b/src/tests/eio/eio_test_manager_xattr.c
@@ -36,17 +36,10 @@ static const char *attr_data[] =
36int total_attributes = sizeof(attribute)/sizeof(attribute[0]); 36int total_attributes = sizeof(attribute)/sizeof(attribute[0]);
37 37
38static void 38static void
39_filter_cb(void *data EINA_UNUSED, const Efl_Event *event) 39_main_cb(void *data, const Efl_Event *ev)
40{ 40{
41 Eio_Filter_Name_Data *event_info = event->info; 41 Efl_Future_Event_Success *success = ev->info;
42 42 const char* attr = success->value;
43 event_info->filter = EINA_TRUE;
44}
45
46static void
47_main_cb(void *data, void *v)
48{
49 const char* attr = v;
50 int *num_of_attr = (int *)data; 43 int *num_of_attr = (int *)data;
51 unsigned int i; 44 unsigned int i;
52 45
@@ -56,11 +49,10 @@ _main_cb(void *data, void *v)
56 (*num_of_attr)++; 49 (*num_of_attr)++;
57 break; 50 break;
58 } 51 }
59
60} 52}
61 53
62static void 54static void
63_done_cb(void *data, void *value EINA_UNUSED) 55_done_cb(void *data, const Efl_Event *ev EINA_UNUSED)
64 56
65{ 57{
66 int *num_of_attr = (int *)data; 58 int *num_of_attr = (int *)data;
@@ -71,16 +63,19 @@ _done_cb(void *data, void *value EINA_UNUSED)
71} 63}
72 64
73static void 65static void
74_done_get_cb(void *data EINA_UNUSED, void* v) 66_done_get_cb(void *data EINA_UNUSED, const Efl_Event *ev)
75{ 67{
76 Eina_Iterator** it = (Eina_Iterator**)v; 68 Efl_Future_Event_Success *success = ev->info;
69 Eina_Accessor *ac = success->value;
77 int i = 0; 70 int i = 0;
78 Eio_Xattr_Data *get_data; 71 Eina_Binbuf *buf;
79 72
80 while (eina_iterator_next((*it), (void**)&get_data)) 73 EINA_ACCESSOR_FOREACH(ac, i, buf)
81 { 74 {
82 fail_if(!get_data); 75 fail_if(!buf);
83 fail_if(strcmp(get_data->data, attr_data[i]) != 0); 76 fail_if(strcmp((const char*) eina_binbuf_string_get(buf),
77 attr_data[i]) != 0);
78
84 i++; 79 i++;
85 } 80 }
86 81
@@ -90,12 +85,15 @@ _done_get_cb(void *data EINA_UNUSED, void* v)
90} 85}
91 86
92static void 87static void
93_done_set_cb(void *data, void* v) 88_done_set_cb(void *data, const Efl_Event *ev)
94{ 89{
95 Eina_Iterator** it = (Eina_Iterator**)v; 90 Efl_Future_Event_Success *success = ev->info;
91 Eina_Accessor *ac = success->value;
96 int *placeholder; 92 int *placeholder;
97 int *num_of_attr = data; 93 int *num_of_attr = data;
98 while(eina_iterator_next((*it), (void**)&placeholder)) 94 int i = 0;
95
96 EINA_ACCESSOR_FOREACH(ac, i, placeholder)
99 *num_of_attr += 1; 97 *num_of_attr += 1;
100 98
101 fail_if(*num_of_attr != total_attributes); 99 fail_if(*num_of_attr != total_attributes);
@@ -104,10 +102,11 @@ _done_set_cb(void *data, void* v)
104} 102}
105 103
106static void 104static void
107_error_cb(void *data EINA_UNUSED, Eina_Error error) 105_error_cb(void *data EINA_UNUSED, const Efl_Event *ev)
108
109{ 106{
110 fprintf(stderr, "Something has gone wrong:%s\n", eina_error_msg_get(error)); 107 Efl_Future_Event_Failure *failure = ev->info;
108
109 fprintf(stderr, "Something has gone wrong:%s\n", eina_error_msg_get(failure->error));
111 abort(); 110 abort();
112 111
113 ecore_main_loop_quit(); 112 ecore_main_loop_quit();
@@ -120,16 +119,14 @@ START_TEST(eio_test_job_xattr_set)
120 int num_of_attr = 0, fd; 119 int num_of_attr = 0, fd;
121 unsigned int i; 120 unsigned int i;
122 Eo *job; 121 Eo *job;
123 Eina_Promise *list_promise = NULL; 122 Efl_Future *ls = NULL;
124 Eina_Promise **attrib_promises = NULL; 123 Efl_Future **futures = NULL;
125 124
126 ecore_init(); 125 ecore_init();
127 eina_init(); 126 eina_init();
128 eio_init(); 127 eio_init();
129 128
130 fprintf(stderr, "eio_test_job_xattr_set\n"); fflush(stderr); 129 job = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get());
131
132 job = efl_add(EFL_IO_MANAGER_CLASS, NULL);
133 130
134 test_file_path = get_full_path(XATTR_TEST_DIR, filename); 131 test_file_path = get_full_path(XATTR_TEST_DIR, filename);
135 fd = open(test_file_path, 132 fd = open(test_file_path,
@@ -137,52 +134,51 @@ START_TEST(eio_test_job_xattr_set)
137 S_IRWXU | S_IRWXG | S_IRWXO); 134 S_IRWXU | S_IRWXG | S_IRWXO);
138 fail_if(fd == 0); 135 fail_if(fd == 0);
139 136
140 attrib_promises = (Eina_Promise**)calloc(total_attributes + 1, sizeof(Eina_Promise*)); 137 futures = calloc(total_attributes + 1, sizeof(Efl_Future*));
141 attrib_promises[total_attributes] = NULL; 138 futures[total_attributes] = NULL;
142 139
143 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i) 140 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i)
144 { 141 {
145 attrib_promises[i] = efl_io_manager_file_xattr_set 142 Eina_Binbuf *buf;
146 (job, test_file_path, attribute[i], 143
147 attr_data[i], strlen(attr_data[i]), 144 buf = eina_binbuf_manage_new((const unsigned char*) attr_data[i], strlen(attr_data[i]), EINA_TRUE);
148 EINA_XATTR_INSERT); 145 futures[i] = efl_io_manager_xattr_set(job, test_file_path, attribute[i], buf, EINA_XATTR_INSERT);
146 eina_binbuf_free(buf);
149 147
150 fail_if(num_of_attr != 0); // test asynchronous 148 fail_if(num_of_attr != 0); // test asynchronous
151 } 149 }
152 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void**)attrib_promises)), 150 efl_future_then(efl_future_iterator_all(eina_carray_iterator_new((void**) futures)),
153 &_done_set_cb, _error_cb, &num_of_attr); 151 _done_set_cb, _error_cb, NULL, &num_of_attr);
154 152
155 ecore_main_loop_begin(); 153 ecore_main_loop_begin();
156 154
157 free(attrib_promises); 155 free(futures);
158 156
159 num_of_attr = 0; 157 num_of_attr = 0;
160 158
161 attrib_promises = (Eina_Promise**)calloc(total_attributes + 1, sizeof(Eina_Promise*)); 159 futures = calloc(total_attributes + 1, sizeof(Eina_Promise*));
162 attrib_promises[total_attributes] = NULL; 160 futures[total_attributes] = NULL;
163 161
164 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i) 162 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i)
165 { 163 {
166 attrib_promises[i] = efl_io_manager_file_xattr_get(job, test_file_path, attribute[i]); 164 futures[i] = efl_io_manager_xattr_get(job, test_file_path, attribute[i]);
167 } 165 }
168 166
169 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void**)attrib_promises)), 167 efl_future_then(efl_future_iterator_all(eina_carray_iterator_new((void**)futures)),
170 _done_get_cb, _error_cb, &num_of_attr); 168 _done_get_cb, _error_cb, NULL, &num_of_attr);
171 169
172 ecore_main_loop_begin(); 170 ecore_main_loop_begin();
173 171
174 num_of_attr = 0; 172 num_of_attr = 0;
175 173
176 efl_event_callback_add(job, EFL_IO_MANAGER_EVENT_XATTR, _filter_cb, NULL); 174 efl_future_use(&ls, efl_io_manager_xattr_ls(job, test_file_path));
177 list_promise = efl_io_manager_file_xattr_list_get(job, test_file_path); 175 efl_future_then(ls, _done_cb, _error_cb, _main_cb, &num_of_attr);
178 eina_promise_progress_cb_add(list_promise, _main_cb, &num_of_attr, NULL);
179 eina_promise_then(list_promise, _done_cb, _error_cb, &num_of_attr);
180 176
181 fail_if(num_of_attr != 0); 177 fail_if(num_of_attr != 0);
182 178
183 ecore_main_loop_begin(); 179 ecore_main_loop_begin();
184 180
185 free(attrib_promises); 181 free(futures);
186 182
187 efl_unref(job); 183 efl_unref(job);
188 close(fd); 184 close(fd);