summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorpierre lamot <pierre.lamot@openwide.fr>2015-03-03 17:01:03 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-17 10:42:51 +0100
commitde767cabfaf84f262c785ce468508f6ed52cc009 (patch)
tree880db66d1636587a6b8a29a3fc44ff88375eeb6a /src/tests/eio
parentc380812496f226d6d3243a2b1c083f6aed8a4dc9 (diff)
eio: don't restart a monitor on MacOSX when every paths have been removed.
This patch check that when a monitor is removed the FSEvent service, it is not restarted if there is no more paths to monitor. This was generating an error message from FSEvent. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/eio_test_monitor.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/tests/eio/eio_test_monitor.c b/src/tests/eio/eio_test_monitor.c
index 378c427a3c..ba5943f863 100644
--- a/src/tests/eio/eio_test_monitor.c
+++ b/src/tests/eio/eio_test_monitor.c
@@ -135,6 +135,82 @@ static void _common_shutdown(Eina_Tmpstr *dirname)
135 135
136/////// tests monitoring a directory 136/////// tests monitoring a directory
137 137
138START_TEST(eio_test_monitor_add_and_remove)
139{
140 Eina_Tmpstr *dirname = _common_init();
141 Eina_Stringshare *filename;
142 Eio_Monitor *monitor;
143
144 filename = eina_stringshare_printf("%s/eio_test_monitor_directory_file_created_notify", dirname);
145 _create_directory((void*)filename);
146
147 //sleep to avoid catching event generated by above manipulations
148 usleep(500000);
149
150 //monitor directory
151 monitor = eio_monitor_add(filename);
152
153 usleep(500000);
154
155 eio_monitor_del(monitor);
156
157 _common_shutdown(dirname);
158}
159END_TEST
160
161START_TEST(eio_test_monitor_add_remove_add)
162{
163 Eina_Tmpstr *dirname = _common_init();
164 Eina_Stringshare *filename;
165 Eio_Monitor *monitor1;
166 Eio_Monitor *monitor2;
167
168 filename = eina_stringshare_printf("%s/eio_test_monitor_add_remove_add", dirname);
169 _create_directory((void*)filename);
170
171 //sleep to avoid catching event generated by above manipulations
172 usleep(500000);
173
174 //monitor directory
175 monitor1 = eio_monitor_add(filename);
176 eio_monitor_del(monitor1);
177
178 usleep(500000);
179
180 monitor2 = eio_monitor_add(filename);
181 eio_monitor_del(monitor2);
182
183 _common_shutdown(dirname);
184}
185END_TEST
186
187START_TEST(eio_test_monitor_add_add_remove_remove)
188{
189 Eina_Tmpstr *dirname = _common_init();
190 Eina_Stringshare *filename1;
191 Eina_Stringshare *filename2;
192 Eio_Monitor *monitor1;
193 Eio_Monitor *monitor2;
194
195 filename1 = eina_stringshare_printf("%s/eio_test_monitor_add_add_remove_remove", dirname);
196 filename2 = eina_stringshare_printf("%s/eio_test_monitor_add_add_remove_remove", dirname);
197 _create_directory((void*)filename1);
198 _create_directory((void*)filename2);
199
200 //sleep to avoid catching event generated by above manipulations
201 usleep(500000);
202
203 //monitor directory
204 monitor1 = eio_monitor_add(filename1);
205 monitor2 = eio_monitor_add(filename2);
206 usleep(500000);
207 eio_monitor_del(monitor2);
208 eio_monitor_del(monitor1);
209
210 _common_shutdown(dirname);
211}
212END_TEST
213
138static void _file_created_cb(void *data, int type, void *event) 214static void _file_created_cb(void *data, int type, void *event)
139{ 215{
140 ck_assert_int_eq(type, (int)EIO_MONITOR_FILE_CREATED); 216 ck_assert_int_eq(type, (int)EIO_MONITOR_FILE_CREATED);
@@ -650,6 +726,10 @@ END_TEST
650 726
651void eio_test_monitor(TCase *tc) 727void eio_test_monitor(TCase *tc)
652{ 728{
729 tcase_add_test(tc, eio_test_monitor_add_and_remove);
730 tcase_add_test(tc, eio_test_monitor_add_remove_add);
731 tcase_add_test(tc, eio_test_monitor_add_add_remove_remove);
732
653 tcase_add_test(tc, eio_test_monitor_directory_file_created_notify); 733 tcase_add_test(tc, eio_test_monitor_directory_file_created_notify);
654 tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify); 734 tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify);
655 tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify); 735 tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify);