summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-30 15:54:01 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-30 15:54:01 -0300
commitad0166f7929f054ba6b72093f8d9e2fb760f9a34 (patch)
tree0be3b17c431afdb1113162f5fcd294fda1d515fa /src/tests/eio
parentab23a5309490d726fe6299b3c4a24c4938baf75f (diff)
eio: Fix eio_test_job_xattr test
Test wasn't enabled when modifications to function prototypes to eio_job_file_xattr_list and eio_job_file_xattr properties were made, so it got pushed inadvertidly without the necessary changes to user code.
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/eio_suite.c18
-rw-r--r--src/tests/eio/eio_test_job_xattr.c61
2 files changed, 40 insertions, 39 deletions
diff --git a/src/tests/eio/eio_suite.c b/src/tests/eio/eio_suite.c
index 022a31423b..10ff27d531 100644
--- a/src/tests/eio/eio_suite.c
+++ b/src/tests/eio/eio_suite.c
@@ -6,16 +6,16 @@
6#include "../efl_check.h" 6#include "../efl_check.h"
7 7
8static const Efl_Test_Case etc[] = { 8static const Efl_Test_Case etc[] = {
9 /* {"Eio_Monitor", eio_test_monitor}, */ 9 {"Eio_Monitor", eio_test_monitor},
10 /* {"Eio_Sentry", eio_test_sentry}, */ 10 {"Eio_Sentry", eio_test_sentry},
11 /* {"Eio Model", eio_model_test_file}, */ 11 {"Eio Model", eio_model_test_file},
12 /* {"Eio Model Monitor", eio_model_test_monitor_add}, */ 12 {"Eio Model Monitor", eio_model_test_monitor_add},
13 /* {"Eio File", eio_test_file}, */ 13 {"Eio File", eio_test_file},
14 {"Eio Job", eio_test_job}, 14 {"Eio Job", eio_test_job},
15/* #ifdef XATTR_TEST_DIR */ 15#ifdef XATTR_TEST_DIR
16/* {"Eio_Xattr", eio_test_xattr}, */ 16 {"Eio_Xattr", eio_test_xattr},
17/* {"Eio Job Xattr", eio_test_job_xattr}, */ 17 {"Eio Job Xattr", eio_test_job_xattr},
18/* #endif */ 18#endif
19 {NULL, NULL} 19 {NULL, NULL}
20}; 20};
21 21
diff --git a/src/tests/eio/eio_test_job_xattr.c b/src/tests/eio/eio_test_job_xattr.c
index 0cf5aca0fe..d47fb50da0 100644
--- a/src/tests/eio/eio_test_job_xattr.c
+++ b/src/tests/eio/eio_test_job_xattr.c
@@ -15,7 +15,10 @@
15#include "eio_test_common.h" 15#include "eio_test_common.h"
16 16
17 17
18#ifdef XATTR_TEST_DIR 18#ifndef XATTR_TEST_DIR
19#define DISABLE_XATTR_TEST
20#define XATTR_TEST_DIR ""
21#endif
19 22
20static const char *attribute[] = 23static const char *attribute[] =
21 { 24 {
@@ -30,12 +33,6 @@ static const char *attr_data[] =
30 "This file has extra attributes" 33 "This file has extra attributes"
31 }; 34 };
32 35
33struct eina_iterator
34{
35 Eina_Iterator* success_iterator;
36 Eina_Iterator* failure_iterator;
37};
38
39int total_attributes = sizeof(attribute)/sizeof(attribute[0]); 36int total_attributes = sizeof(attribute)/sizeof(attribute[0]);
40 37
41static Eina_Bool 38static Eina_Bool
@@ -47,8 +44,9 @@ _filter_cb(void *data EINA_UNUSED, const Eo_Event *event)
47} 44}
48 45
49static void 46static void
50_main_cb(void *data, const char *attr) 47_main_cb(void *data, void *v)
51{ 48{
49 const char* attr = v;
52 int *num_of_attr = (int *)data; 50 int *num_of_attr = (int *)data;
53 unsigned int i; 51 unsigned int i;
54 52
@@ -62,7 +60,7 @@ _main_cb(void *data, const char *attr)
62} 60}
63 61
64static void 62static void
65_done_cb(void *data, void *value EINA_UNUSED) 63_done_cb(void *data, void *value EINA_UNUSED, Eina_Promise* promise EINA_UNUSED)
66 64
67{ 65{
68 int *num_of_attr = (int *)data; 66 int *num_of_attr = (int *)data;
@@ -73,12 +71,13 @@ _done_cb(void *data, void *value EINA_UNUSED)
73} 71}
74 72
75static void 73static void
76_done_get_cb(void *data EINA_UNUSED, struct eina_iterator* it) 74_done_get_cb(void *data EINA_UNUSED, void* v, Eina_Promise* promise EINA_UNUSED)
77{ 75{
76 Eina_Iterator** it = (Eina_Iterator**)v;
78 int i = 0; 77 int i = 0;
79 Eio_Xattr_Data *get_data; 78 Eio_Xattr_Data *get_data;
80 79
81 while (eina_iterator_next(it->success_iterator, (void**)&get_data)) 80 while (eina_iterator_next((*it), (void**)&get_data))
82 { 81 {
83 fail_if(!get_data); 82 fail_if(!get_data);
84 fail_if(strcmp(get_data->data, attr_data[i]) != 0); 83 fail_if(strcmp(get_data->data, attr_data[i]) != 0);
@@ -91,11 +90,12 @@ _done_get_cb(void *data EINA_UNUSED, struct eina_iterator* it)
91} 90}
92 91
93static void 92static void
94_done_set_cb(void *data, struct eina_iterator* it) 93_done_set_cb(void *data, void* v, Eina_Promise* promise EINA_UNUSED)
95{ 94{
95 Eina_Iterator** it = (Eina_Iterator**)v;
96 int *placeholder; 96 int *placeholder;
97 int *num_of_attr = data; 97 int *num_of_attr = data;
98 while(eina_iterator_next(it->success_iterator, (void**)&placeholder)) 98 while(eina_iterator_next((*it), (void**)&placeholder))
99 *num_of_attr += 1; 99 *num_of_attr += 1;
100 100
101 fail_if(*num_of_attr != total_attributes); 101 fail_if(*num_of_attr != total_attributes);
@@ -104,10 +104,10 @@ _done_set_cb(void *data, struct eina_iterator* it)
104} 104}
105 105
106static void 106static void
107_error_cb(void *data EINA_UNUSED, Eina_Error *error) 107_error_cb(void *data EINA_UNUSED, Eina_Error error, Eina_Promise* promise EINA_UNUSED)
108 108
109{ 109{
110 fprintf(stderr, "Something has gone wrong:%s\n", strerror(*error)); 110 fprintf(stderr, "Something has gone wrong:%s\n", eina_error_msg_get(error));
111 abort(); 111 abort();
112 112
113 ecore_main_loop_quit(); 113 ecore_main_loop_quit();
@@ -127,6 +127,8 @@ START_TEST(eio_test_job_xattr_set)
127 eina_init(); 127 eina_init();
128 eio_init(); 128 eio_init();
129 129
130 fprintf(stderr, "eio_test_job_xattr_set\n"); fflush(stderr);
131
130 job = eo_add(EIO_JOB_CLASS, NULL); 132 job = eo_add(EIO_JOB_CLASS, NULL);
131 133
132 test_file_path = get_full_path(XATTR_TEST_DIR, filename); 134 test_file_path = get_full_path(XATTR_TEST_DIR, filename);
@@ -135,20 +137,20 @@ START_TEST(eio_test_job_xattr_set)
135 S_IRWXU | S_IRWXG | S_IRWXO); 137 S_IRWXU | S_IRWXG | S_IRWXO);
136 fail_if(fd == 0); 138 fail_if(fd == 0);
137 139
138 attrib_promises = (Eina_Promise **)calloc(total_attributes + 1, sizeof(Eina_Promise*)); 140 attrib_promises = (Eina_Promise**)calloc(total_attributes + 1, sizeof(Eina_Promise*));
139 attrib_promises[total_attributes] = NULL; 141 attrib_promises[total_attributes] = NULL;
140 142
141 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i) 143 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i)
142 { 144 {
143 eio_job_file_xattr_set(job, test_file_path, attribute[i], 145 attrib_promises[i] = eio_job_file_xattr_set
144 attr_data[i], strlen(attr_data[i]), 146 (job, test_file_path, attribute[i],
145 EINA_XATTR_INSERT, 147 attr_data[i], strlen(attr_data[i]),
146 &attrib_promises[i]); 148 EINA_XATTR_INSERT);
147 149
148 fail_if(num_of_attr != 0); // test asynchronous 150 fail_if(num_of_attr != 0); // test asynchronous
149 } 151 }
150 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void**)attrib_promises)), 152 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void**)attrib_promises)),
151 (Eina_Promise_Cb)_done_set_cb, (Eina_Promise_Error_Cb)_error_cb, &num_of_attr); 153 &_done_set_cb, _error_cb, &num_of_attr);
152 154
153 ecore_main_loop_begin(); 155 ecore_main_loop_begin();
154 156
@@ -156,25 +158,25 @@ START_TEST(eio_test_job_xattr_set)
156 158
157 num_of_attr = 0; 159 num_of_attr = 0;
158 160
159 attrib_promises = (Eina_Promise **)calloc(total_attributes + 1, sizeof(Eina_Promise*)); 161 attrib_promises = (Eina_Promise**)calloc(total_attributes + 1, sizeof(Eina_Promise*));
160 attrib_promises[total_attributes] = NULL; 162 attrib_promises[total_attributes] = NULL;
161 163
162 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i) 164 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i)
163 { 165 {
164 eio_job_file_xattr_get(job, test_file_path, attribute[i], &attrib_promises[i]); 166 attrib_promises[i] = eio_job_file_xattr_get(job, test_file_path, attribute[i]);
165 } 167 }
166 168
167 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void**)attrib_promises)), 169 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void**)attrib_promises)),
168 (Eina_Promise_Cb)_done_get_cb, (Eina_Promise_Error_Cb)_error_cb, &num_of_attr); 170 _done_get_cb, _error_cb, &num_of_attr);
169 171
170 ecore_main_loop_begin(); 172 ecore_main_loop_begin();
171 173
172 num_of_attr = 0; 174 num_of_attr = 0;
173 175
174 eo_event_callback_add(job, EIO_JOB_EVENT_XATTR, _filter_cb, NULL); 176 eo_event_callback_add(job, EIO_JOB_EVENT_XATTR, _filter_cb, NULL);
175 eio_job_file_xattr(job, test_file_path, &list_promise); 177 list_promise = eio_job_file_xattr_list_get(job, test_file_path);
176 eina_promise_progress_cb_add(list_promise, (Eina_Promise_Progress_Cb)_main_cb, &num_of_attr, NULL); 178 eina_promise_progress_cb_add(list_promise, _main_cb, &num_of_attr, NULL);
177 eina_promise_then(list_promise, (Eina_Promise_Cb)_done_cb, (Eina_Promise_Error_Cb)_error_cb, &num_of_attr); 179 eina_promise_then(list_promise, _done_cb, _error_cb, &num_of_attr);
178 180
179 fail_if(num_of_attr != 0); 181 fail_if(num_of_attr != 0);
180 182
@@ -192,13 +194,12 @@ START_TEST(eio_test_job_xattr_set)
192} 194}
193END_TEST 195END_TEST
194 196
195#endif
196
197void eio_test_job_xattr(TCase *tc) 197void eio_test_job_xattr(TCase *tc)
198{ 198{
199#ifdef XATTR_TEST_DIR 199#ifndef DISABLE_XATTR_TEST
200 tcase_add_test(tc, eio_test_job_xattr_set); 200 tcase_add_test(tc, eio_test_job_xattr_set);
201#else 201#else
202 (void)eio_test_job_xattr_set;
202 (void)tc; 203 (void)tc;
203#endif 204#endif
204} 205}