summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-06-28 23:51:20 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-06-29 09:47:06 -0400
commit3f4d7e175cf81256848de05cd6df55f29fe05ae0 (patch)
tree0d5abc93bddcc069e22cf9b26d63f32cf86e52fc
parent278bd8ae96c64fe7ac5a07a296c5b831f2c4f181 (diff)
-rw-r--r--src/lib/eio/eio_monitor.c5
-rw-r--r--src/lib/eio/eio_monitor_inotify.c22
-rw-r--r--src/tests/efl_check.h2
-rw-r--r--src/tests/eio/eio_suite.c1
-rw-r--r--src/tests/eio/eio_test_monitor.c39
5 files changed, 26 insertions, 43 deletions
diff --git a/src/lib/eio/eio_monitor.c b/src/lib/eio/eio_monitor.c
index 84262bb329..21704bfc82 100644
--- a/src/lib/eio/eio_monitor.c
+++ b/src/lib/eio/eio_monitor.c
@@ -150,6 +150,7 @@ eio_monitor_init(void)
150 EIO_MONITOR_DIRECTORY_DELETED = ecore_event_type_new(); 150 EIO_MONITOR_DIRECTORY_DELETED = ecore_event_type_new();
151 EIO_MONITOR_DIRECTORY_MODIFIED = ecore_event_type_new(); 151 EIO_MONITOR_DIRECTORY_MODIFIED = ecore_event_type_new();
152 EIO_MONITOR_DIRECTORY_CLOSED = ecore_event_type_new(); 152 EIO_MONITOR_DIRECTORY_CLOSED = ecore_event_type_new();
153 fprintf(stderr, "EIO_MONITOR_ERROR = %d\n", EIO_MONITOR_ERROR);
153 154
154 eio_monitor_backend_init(); 155 eio_monitor_backend_init();
155 eio_monitor_fallback_init(); 156 eio_monitor_fallback_init();
@@ -218,10 +219,10 @@ void
218_eio_monitor_send(Eio_Monitor *monitor, const char *filename, int event_code) 219_eio_monitor_send(Eio_Monitor *monitor, const char *filename, int event_code)
219{ 220{
220 Eio_Monitor_Event *ev; 221 Eio_Monitor_Event *ev;
221 222fprintf(stderr, "%s:%u EVENT %d\n", __FILE__, __LINE__, event_code);
222 if (monitor->delete_me) 223 if (monitor->delete_me)
223 return; 224 return;
224 225fprintf(stderr, "%s:%u EVENT %d\n", __FILE__, __LINE__, event_code);
225 INF("Event '%s' for monitored path '%s'.", 226 INF("Event '%s' for monitored path '%s'.",
226 _eio_naming_event(event_code), filename); 227 _eio_naming_event(event_code), filename);
227 228
diff --git a/src/lib/eio/eio_monitor_inotify.c b/src/lib/eio/eio_monitor_inotify.c
index f3a83be5b7..a9cca1f7f7 100644
--- a/src/lib/eio/eio_monitor_inotify.c
+++ b/src/lib/eio/eio_monitor_inotify.c
@@ -91,10 +91,10 @@ _eio_inotify_events(Eio_Monitor_Backend *backend, const char *file, int mask)
91 unsigned int tmp_length; 91 unsigned int tmp_length;
92 unsigned int i; 92 unsigned int i;
93 Eina_Bool is_dir; 93 Eina_Bool is_dir;
94 94fprintf(stderr, "%s:%u\n", __FILE__, __LINE__);
95 if (backend->parent->delete_me) 95 if (backend->parent->delete_me)
96 return; 96 return;
97 97fprintf(stderr, "%s:%u\n", __FILE__, __LINE__);
98 length = file ? strlen(file) : 0; 98 length = file ? strlen(file) : 0;
99 tmp_length = eina_stringshare_strlen(backend->parent->path) + length + 2; 99 tmp_length = eina_stringshare_strlen(backend->parent->path) + length + 2;
100 tmp = alloca(sizeof (char) * tmp_length); 100 tmp = alloca(sizeof (char) * tmp_length);
@@ -106,16 +106,16 @@ _eio_inotify_events(Eio_Monitor_Backend *backend, const char *file, int mask)
106 106
107 107
108 is_dir = !!(mask & IN_ISDIR); 108 is_dir = !!(mask & IN_ISDIR);
109 109fprintf(stderr, "%s:%u\n", __FILE__, __LINE__);
110 for (i = 0; i < sizeof (match) / sizeof (Eio_Inotify_Table); ++i) 110 for (i = 0; i < sizeof (match) / sizeof (Eio_Inotify_Table); ++i)
111 if (match[i].mask & mask) 111 if (match[i].mask & mask)
112 { 112 {fprintf(stderr, "%s:%u\n", __FILE__, __LINE__);
113 _eio_monitor_send(backend->parent, tmp, is_dir ? *match[i].ev_dir_code : *match[i].ev_file_code); 113 _eio_monitor_send(backend->parent, tmp, is_dir ? *match[i].ev_dir_code : *match[i].ev_file_code);
114 } 114 }
115 115
116 /* special case for IN_IGNORED */ 116 /* special case for IN_IGNORED */
117 if (mask & IN_IGNORED) 117 if (mask & IN_IGNORED)
118 { 118 {fprintf(stderr, "%s:%u\n", __FILE__, __LINE__);
119 _eio_monitor_rename(backend->parent, tmp); 119 _eio_monitor_rename(backend->parent, tmp);
120 } 120 }
121} 121}
@@ -143,9 +143,10 @@ _eio_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh)
143 143
144 // No need to waste time looking up for just destroyed handler 144 // No need to waste time looking up for just destroyed handler
145 if ((event->mask & IN_IGNORED)) continue ; 145 if ((event->mask & IN_IGNORED)) continue ;
146 146fprintf(stderr, "%s:%u\n", __FILE__, __LINE__);
147 backend = eina_hash_find(_inotify_monitors, &event->wd); 147 backend = eina_hash_find(_inotify_monitors, &event->wd);
148 if (!backend) continue ; 148 if (!backend) continue ;
149 fprintf(stderr, "%s:%u\n", __FILE__, __LINE__);
149 if (!backend->parent) continue ; 150 if (!backend->parent) continue ;
150 151
151 _eio_inotify_events(backend, (event->len ? event->name : NULL), event->mask); 152 _eio_inotify_events(backend, (event->len ? event->name : NULL), event->mask);
@@ -196,11 +197,17 @@ void eio_monitor_backend_init(void)
196 if (fd < 0) 197 if (fd < 0)
197 return; 198 return;
198 199
199 eina_file_close_on_exec(fd, EINA_TRUE); 200 if (!eina_file_close_on_exec(fd, EINA_TRUE))
201 {
202 ERR("CLOEXEC failed!");
203 close(fd);
204 return;
205 }
200 206
201 _inotify_fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _eio_inotify_handler, NULL, NULL, NULL); 207 _inotify_fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _eio_inotify_handler, NULL, NULL, NULL);
202 if (!_inotify_fdh) 208 if (!_inotify_fdh)
203 { 209 {
210 ERR("FDH creation failed!");
204 close(fd); 211 close(fd);
205 return; 212 return;
206 } 213 }
@@ -262,6 +269,7 @@ void eio_monitor_backend_add(Eio_Monitor *monitor)
262 backend->hwnd = inotify_add_watch(ecore_main_fd_handler_fd_get(_inotify_fdh), monitor->path, mask); 269 backend->hwnd = inotify_add_watch(ecore_main_fd_handler_fd_get(_inotify_fdh), monitor->path, mask);
263 if (backend->hwnd < 0) 270 if (backend->hwnd < 0)
264 { 271 {
272 ERR("ERROR adding inotify watch: %s", strerror(errno));
265 if (errno != EACCES) 273 if (errno != EACCES)
266 eio_monitor_fallback_add(monitor); 274 eio_monitor_fallback_add(monitor);
267 275
diff --git a/src/tests/efl_check.h b/src/tests/efl_check.h
index 0e655541ab..3417a381cc 100644
--- a/src/tests/efl_check.h
+++ b/src/tests/efl_check.h
@@ -266,7 +266,7 @@ _efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, co
266 sr = srunner_create(s); 266 sr = srunner_create(s);
267 do_fork = _efl_test_fork_has(sr); 267 do_fork = _efl_test_fork_has(sr);
268 if (do_fork) 268 if (do_fork)
269 can_fork = !!etc[1].test_case /* can't parallelize 1 test */; 269 can_fork = strcmp(suite_name, "Eio") && !!etc[1].test_case /* can't parallelize 1 test */;
270 270
271 for (i = 0; etc[i].test_case; ++i) 271 for (i = 0; etc[i].test_case; ++i)
272 { 272 {
diff --git a/src/tests/eio/eio_suite.c b/src/tests/eio/eio_suite.c
index 5b59c5c4dc..1f0d417e68 100644
--- a/src/tests/eio/eio_suite.c
+++ b/src/tests/eio/eio_suite.c
@@ -37,6 +37,7 @@ static const Efl_Test_Case etc[] = {
37SUITE_INIT(eio) 37SUITE_INIT(eio)
38{ 38{
39 ck_assert_int_eq(eio_init(), 1); 39 ck_assert_int_eq(eio_init(), 1);
40eina_log_level_set(4);
40} 41}
41 42
42SUITE_SHUTDOWN(eio) 43SUITE_SHUTDOWN(eio)
diff --git a/src/tests/eio/eio_test_monitor.c b/src/tests/eio/eio_test_monitor.c
index 26b469fe96..f8eaf8d838 100644
--- a/src/tests/eio/eio_test_monitor.c
+++ b/src/tests/eio/eio_test_monitor.c
@@ -14,8 +14,8 @@
14 14
15/////////////////timeout function 15/////////////////timeout function
16 16
17#define TEST_TIMEOUT_SEC 5 17#define TEST_TIMEOUT_SEC 0.5
18#define TEST_OPERATION_DELAY 1 18#define TEST_OPERATION_DELAY 0.05
19 19
20static Ecore_Timer *test_timeout_timer; 20static Ecore_Timer *test_timeout_timer;
21 21
@@ -485,7 +485,7 @@ static void _directory_self_deleted_cb(void *data, int type, void *event)
485EFL_START_TEST(eio_test_monitor_directory_directory_self_deleted_notify) 485EFL_START_TEST(eio_test_monitor_directory_directory_self_deleted_notify)
486{ 486{
487 Eina_Tmpstr *dirname = _common_init(); 487 Eina_Tmpstr *dirname = _common_init();
488 488fprintf(stderr, "START TEST eio_test_monitor_directory_directory_self_deleted_notify\n");
489 //monitor directory 489 //monitor directory
490 eio_monitor_add(dirname); 490 eio_monitor_add(dirname);
491 ecore_event_handler_add(EIO_MONITOR_SELF_DELETED, (Ecore_Event_Handler_Cb)_directory_self_deleted_cb, dirname); 491 ecore_event_handler_add(EIO_MONITOR_SELF_DELETED, (Ecore_Event_Handler_Cb)_directory_self_deleted_cb, dirname);
@@ -504,7 +504,7 @@ EFL_START_TEST(eio_test_monitor_file_file_modified_notify)
504{ 504{
505 Eina_Tmpstr *dirname = _common_init(); 505 Eina_Tmpstr *dirname = _common_init();
506 Eina_Stringshare *filename; 506 Eina_Stringshare *filename;
507 507fprintf(stderr, "START TEST eio_test_monitor_file_file_modified_notify\n");
508 filename = eina_stringshare_printf("%s/filecreated", dirname); 508 filename = eina_stringshare_printf("%s/filecreated", dirname);
509 _create_file((void*)filename); 509 _create_file((void*)filename);
510 510
@@ -571,7 +571,7 @@ EFL_START_TEST(eio_test_monitor_file_file_self_deleted_notify)
571{ 571{
572 Eina_Tmpstr *dirname = _common_init(); 572 Eina_Tmpstr *dirname = _common_init();
573 Eina_Stringshare *filename; 573 Eina_Stringshare *filename;
574 574fprintf(stderr, "START TEST eio_test_monitor_file_file_self_deleted_notify\n");
575 filename = eina_stringshare_printf("%s/eio_test_monitor_file_file_self_deleted_notify", dirname); 575 filename = eina_stringshare_printf("%s/eio_test_monitor_file_file_self_deleted_notify", dirname);
576 _create_file((void*)filename); 576 _create_file((void*)filename);
577 577
@@ -677,7 +677,7 @@ EFL_START_TEST(eio_test_monitor_two_files_in_same_directory)
677 Eina_Tmpstr *dirname = _common_init(); 677 Eina_Tmpstr *dirname = _common_init();
678 Eina_Stringshare *filename; 678 Eina_Stringshare *filename;
679 Eina_Stringshare *filename2; 679 Eina_Stringshare *filename2;
680 680fprintf(stderr, "START TEST eio_test_monitor_two_files_in_same_directory\n");
681 filename = eina_stringshare_printf("%s/eio_test_monitor_two_files_in_same_directory_1", dirname); 681 filename = eina_stringshare_printf("%s/eio_test_monitor_two_files_in_same_directory_1", dirname);
682 filename2 = eina_stringshare_printf("%s/eio_test_monitor_two_files_in_same_directory_2", dirname); 682 filename2 = eina_stringshare_printf("%s/eio_test_monitor_two_files_in_same_directory_2", dirname);
683 _create_file((void*)filename); 683 _create_file((void*)filename);
@@ -730,36 +730,9 @@ EFL_END_TEST
730 730
731void eio_test_monitor(TCase *tc) 731void eio_test_monitor(TCase *tc)
732{ 732{
733 tcase_add_test(tc, eio_test_monitor_add_and_remove);
734 tcase_add_test(tc, eio_test_monitor_add_remove_add);
735 tcase_add_test(tc, eio_test_monitor_add_add_remove_remove);
736
737 tcase_add_test(tc, eio_test_monitor_directory_file_created_notify);
738 tcase_add_test(tc, eio_test_monitor_directory_multi_file_created_notify);
739 tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify);
740 tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify);
741#if !defined(_WIN32) && !defined(__MACH__)
742 tcase_add_test(tc, eio_test_monitor_directory_file_closed_notify);
743#endif
744 tcase_add_test(tc, eio_test_monitor_directory_directory_created_notify);
745 tcase_add_test(tc, eio_test_monitor_directory_directory_deleted_notify);
746 tcase_add_test(tc, eio_test_monitor_directory_directory_modified_notify);
747#ifndef __MACH__
748 tcase_add_test(tc, eio_test_monitor_directory_directory_self_deleted_notify); 733 tcase_add_test(tc, eio_test_monitor_directory_directory_self_deleted_notify);
749#endif
750 734
751 tcase_add_test(tc, eio_test_monitor_file_file_modified_notify); 735 tcase_add_test(tc, eio_test_monitor_file_file_modified_notify);
752 tcase_add_test(tc, eio_test_monitor_file_file_attrib_modified_notify);
753#if !defined(_WIN32) && !defined(__MACH__)
754 tcase_add_test(tc, eio_test_monitor_file_file_closed_notify);
755#endif
756#ifndef __MACH__
757 tcase_add_test(tc, eio_test_monitor_file_file_self_deleted_notify); 736 tcase_add_test(tc, eio_test_monitor_file_file_self_deleted_notify);
758#endif
759
760 tcase_add_test(tc, eio_test_monitor_two_monitors_one_event);
761 tcase_add_test(tc, eio_test_monitor_two_monitors_one_removed_one_event);
762 tcase_add_test(tc, eio_test_monitor_two_monitors_one_removed_no_event);
763 tcase_add_test(tc, eio_test_monitor_two_files_in_same_directory); 737 tcase_add_test(tc, eio_test_monitor_two_files_in_same_directory);
764 tcase_add_test(tc, eio_test_monitor_two_files_in_same_directory_one_removed);
765} 738}