summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2015-05-06 08:32:04 +0200
committerStefan Schmidt <s.schmidt@samsung.com>2015-05-06 08:42:55 +0200
commit400436cd1af6aef8892ac899eb0844892fc5e54c (patch)
tree03776ffeed6f7508916ba27f18c147b3f05f96a7
parent26ebd007af719bda591c2cf125ae0afc8cef4777 (diff)
eina_xattr: Fixed T2381, eina xattr tests failing
Summary: This fixes the case where the system runs with SELinux enabled and enforced. In this scenario the system does add a selinux attribute to new files which we need to handle during our testing. @Fix Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: cedric, stefan_schmidt Subscribers: stefan_schmidt, cedric Maniphest Tasks: T2381 Differential Revision: https://phab.enlightenment.org/D2467
-rw-r--r--src/tests/eina/eina_test_file.c17
-rw-r--r--src/tests/eina/eina_test_xattr.c52
-rw-r--r--src/tests/eio/eio_test_xattr.c8
3 files changed, 55 insertions, 22 deletions
diff --git a/src/tests/eina/eina_test_file.c b/src/tests/eina/eina_test_file.c
index 5fa4a6862c..766ff46b67 100644
--- a/src/tests/eina/eina_test_file.c
+++ b/src/tests/eina/eina_test_file.c
@@ -525,7 +525,7 @@ START_TEST(eina_test_file_xattr)
525 Eina_Bool ret; 525 Eina_Bool ret;
526 Eina_Tmpstr *test_file_path; 526 Eina_Tmpstr *test_file_path;
527 Eina_Iterator *it; 527 Eina_Iterator *it;
528 int fd; 528 int fd, count=0;
529 Eina_Xattr *xattr; 529 Eina_Xattr *xattr;
530 530
531 eina_init(); 531 eina_init();
@@ -549,20 +549,27 @@ START_TEST(eina_test_file_xattr)
549 { 549 {
550 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); i++) 550 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); i++)
551 if (strcmp(attribute[i], ret_str) == 0) 551 if (strcmp(attribute[i], ret_str) == 0)
552 break ; 552 {
553 fail_if(i == sizeof (attribute) / sizeof (attribute[0])); 553 count++;
554 break;
555 }
554 } 556 }
557 fail_if(count != sizeof (attribute) / sizeof (attribute[0]));
555 eina_iterator_free(it); 558 eina_iterator_free(it);
556 559
560 count = 0;
557 it = eina_file_xattr_value_get(ef); 561 it = eina_file_xattr_value_get(ef);
558 EINA_ITERATOR_FOREACH(it, xattr) 562 EINA_ITERATOR_FOREACH(it, xattr)
559 { 563 {
560 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++) 564 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++)
561 if (strcmp(attribute[i], xattr->name) == 0 && 565 if (strcmp(attribute[i], xattr->name) == 0 &&
562 strcmp(data[i], xattr->value) == 0) 566 strcmp(data[i], xattr->value) == 0)
563 break ; 567 {
564 fail_if(i == sizeof (data) / sizeof (data[0])); 568 count++;
569 break;
570 }
565 } 571 }
572 fail_if(count != sizeof (data) / sizeof (data[0]));
566 eina_iterator_free(it); 573 eina_iterator_free(it);
567 574
568 unlink(test_file_path); 575 unlink(test_file_path);
diff --git a/src/tests/eina/eina_test_xattr.c b/src/tests/eina/eina_test_xattr.c
index 50e1ad01eb..43a315aee3 100644
--- a/src/tests/eina/eina_test_xattr.c
+++ b/src/tests/eina/eina_test_xattr.c
@@ -87,6 +87,7 @@ START_TEST(eina_test_xattr_set)
87 87
88 ret = eina_xattr_fd_del(fd, attribute1); 88 ret = eina_xattr_fd_del(fd, attribute1);
89 fail_if(ret != EINA_TRUE); 89 fail_if(ret != EINA_TRUE);
90
90 close(fd); 91 close(fd);
91 unlink(test_file_path); 92 unlink(test_file_path);
92 eina_tmpstr_del(test_file_path); 93 eina_tmpstr_del(test_file_path);
@@ -112,7 +113,7 @@ START_TEST(eina_test_xattr_list)
112 "This file has extra attributes" 113 "This file has extra attributes"
113 }; 114 };
114 char *ret_str; 115 char *ret_str;
115 int fd, fd1; 116 int fd, fd1, count=0;
116 unsigned int i; 117 unsigned int i;
117 Eina_Bool ret; 118 Eina_Bool ret;
118 Eina_Tmpstr *test_file_path, *cp_file_path; 119 Eina_Tmpstr *test_file_path, *cp_file_path;
@@ -134,61 +135,81 @@ START_TEST(eina_test_xattr_list)
134 ret = eina_xattr_set(test_file_path, attribute[i], data[i], strlen(data[i]), EINA_XATTR_INSERT); 135 ret = eina_xattr_set(test_file_path, attribute[i], data[i], strlen(data[i]), EINA_XATTR_INSERT);
135 fail_if(ret != EINA_TRUE); 136 fail_if(ret != EINA_TRUE);
136 } 137 }
138
137 it = eina_xattr_ls(test_file_path); 139 it = eina_xattr_ls(test_file_path);
138 EINA_ITERATOR_FOREACH(it, ret_str) 140 EINA_ITERATOR_FOREACH(it, ret_str)
139 { 141 {
140 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); i++) 142 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); i++)
141 if (strcmp(attribute[i], ret_str) == 0) 143 if (strcmp(attribute[i], ret_str) == 0)
142 break ; 144 {
143 fail_if(i == sizeof (attribute) / sizeof (attribute[0])); 145 count++;
146 break ;
147 }
144 } 148 }
149 fail_if(count != sizeof (attribute) / sizeof (attribute[0]));
145 eina_iterator_free(it); 150 eina_iterator_free(it);
146 151
152 count = 0;
147 it = eina_xattr_value_ls(test_file_path); 153 it = eina_xattr_value_ls(test_file_path);
148 EINA_ITERATOR_FOREACH(it, xattr) 154 EINA_ITERATOR_FOREACH(it, xattr)
149 { 155 {
150 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++) 156 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++)
151 if (strcmp(attribute[i], xattr->name) == 0 && 157 if (strcmp(attribute[i], xattr->name) == 0 &&
152 strcmp(data[i], xattr->value) == 0) 158 strcmp(data[i], xattr->value) == 0)
153 break ; 159 {
154 fail_if(i == sizeof (data) / sizeof (data[0])); 160 count++;
161 break ;
162 }
155 } 163 }
164 fail_if(count != sizeof (data) / sizeof (data[0]));
156 eina_iterator_free(it); 165 eina_iterator_free(it);
157 166
167 count = 0;
158 it = eina_xattr_fd_ls(fd); 168 it = eina_xattr_fd_ls(fd);
159 EINA_ITERATOR_FOREACH(it, ret_str) 169 EINA_ITERATOR_FOREACH(it, ret_str)
160 { 170 {
161 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); i++) 171 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); i++)
162 if (strcmp(attribute[i], ret_str) == 0) 172 if (strcmp(attribute[i], ret_str) == 0)
163 break ; 173 {
164 fail_if(i == sizeof (attribute) / sizeof (attribute[0])); 174 count++;
175 break ;
176 }
165 } 177 }
178 fail_if(count != sizeof (attribute) / sizeof (attribute[0]));
166 eina_iterator_free(it); 179 eina_iterator_free(it);
167 180
181 count = 0;
168 it = eina_xattr_value_fd_ls(fd); 182 it = eina_xattr_value_fd_ls(fd);
169 EINA_ITERATOR_FOREACH(it, xattr) 183 EINA_ITERATOR_FOREACH(it, xattr)
170 { 184 {
171 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++) 185 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++)
172 if (strcmp(attribute[i], xattr->name) == 0 && 186 if (strcmp(attribute[i], xattr->name) == 0 &&
173 strcmp(data[i], xattr->value) == 0) 187 strcmp(data[i], xattr->value) == 0)
174 break ; 188 {
175 fail_if(i == sizeof (data) / sizeof (data[0])); 189 count++;
190 break ;
191 }
176 } 192 }
193 fail_if(count != sizeof (data) / sizeof (data[0]));
177 eina_iterator_free(it); 194 eina_iterator_free(it);
178 195
179 /* Test case for eina_xattr_copy and eina_xattr_fd_copy */ 196 /* Test case for eina_xattr_copy and eina_xattr_fd_copy */
180 ret = eina_xattr_copy(test_file_path, cp_file_path); 197 ret = eina_xattr_copy(test_file_path, cp_file_path);
181 fail_if(ret != EINA_TRUE); 198 fail_if(ret != EINA_TRUE);
182 199
200 count = 0;
183 it = eina_xattr_value_ls(cp_file_path); 201 it = eina_xattr_value_ls(cp_file_path);
184 EINA_ITERATOR_FOREACH(it, xattr) 202 EINA_ITERATOR_FOREACH(it, xattr)
185 { 203 {
186 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++) 204 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++)
187 if (strcmp(attribute[i], xattr->name) == 0 && 205 if (strcmp(attribute[i], xattr->name) == 0 &&
188 strcmp(data[i], xattr->value) == 0) 206 strcmp(data[i], xattr->value) == 0)
189 break ; 207 {
190 fail_if(i == sizeof (data) / sizeof (data[0])); 208 count++;
209 break ;
210 }
191 } 211 }
212 fail_if(count != sizeof (data) / sizeof (data[0]));
192 eina_iterator_free(it); 213 eina_iterator_free(it);
193 214
194 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i) 215 for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i)
@@ -199,15 +220,20 @@ START_TEST(eina_test_xattr_list)
199 220
200 ret = eina_xattr_fd_copy(fd, fd1); 221 ret = eina_xattr_fd_copy(fd, fd1);
201 fail_if(ret != EINA_TRUE); 222 fail_if(ret != EINA_TRUE);
223
224 count = 0;
202 it = eina_xattr_value_fd_ls(fd1); 225 it = eina_xattr_value_fd_ls(fd1);
203 EINA_ITERATOR_FOREACH(it, xattr) 226 EINA_ITERATOR_FOREACH(it, xattr)
204 { 227 {
205 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++) 228 for (i = 0; i < sizeof (data) / sizeof (data[0]); i++)
206 if (strcmp(attribute[i], xattr->name) == 0 && 229 if (strcmp(attribute[i], xattr->name) == 0 &&
207 strcmp(data[i], xattr->value) == 0) 230 strcmp(data[i], xattr->value) == 0)
208 break ; 231 {
209 fail_if(i == sizeof (data) / sizeof (data[0])); 232 count++;
233 break ;
234 }
210 } 235 }
236 fail_if(count != sizeof (data) / sizeof (data[0]));
211 eina_iterator_free(it); 237 eina_iterator_free(it);
212 238
213 close(fd); 239 close(fd);
diff --git a/src/tests/eio/eio_test_xattr.c b/src/tests/eio/eio_test_xattr.c
index b832eb001e..dfc5894045 100644
--- a/src/tests/eio/eio_test_xattr.c
+++ b/src/tests/eio/eio_test_xattr.c
@@ -58,10 +58,10 @@ _main_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const char *attr
58 58
59 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); ++i) 59 for (i = 0; i < sizeof (attribute) / sizeof (attribute[0]); ++i)
60 if (strcmp(attr, attribute[i]) == 0) 60 if (strcmp(attr, attribute[i]) == 0)
61 break; 61 {
62 62 (*num_of_attr)++;
63 fail_if(i == sizeof (attribute) / sizeof (attribute[0])); 63 break;
64 (*num_of_attr)++; 64 }
65} 65}
66 66
67static void 67static void