summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2016-07-28 20:54:20 -0700
committerCedric Bail <cedric@osg.samsung.com>2016-07-28 21:03:12 -0700
commit351c2007f6d06d5463cae431f54618fa4410eeea (patch)
tree27e2480ceb9226244c2481b6cba816bba0dcbe5d /src/tests/eio
parentcec3eddb41376aba0be93aa42a11843e66126c33 (diff)
eio: add a test for T3237.
I have been trying to reproduce the reported ephoto issue, but couldn't. This test case reproduce the reported scenario.
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/eio_test_monitor.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/tests/eio/eio_test_monitor.c b/src/tests/eio/eio_test_monitor.c
index fbf813486b..b05824165c 100644
--- a/src/tests/eio/eio_test_monitor.c
+++ b/src/tests/eio/eio_test_monitor.c
@@ -242,6 +242,65 @@ START_TEST(eio_test_monitor_directory_file_created_notify)
242} 242}
243END_TEST 243END_TEST
244 244
245struct {
246 Eina_Stringshare *s;
247 Eina_Bool checked;
248} multi_files[] = {
249 { NULL, EINA_FALSE },
250 { NULL, EINA_FALSE },
251 { NULL, EINA_FALSE },
252 { NULL, EINA_FALSE }
253};
254
255static void
256_multi_file_created_cb(void *data EINA_UNUSED, int type, void *event)
257{
258 Eio_Monitor_Event *ev = event;
259 Eina_Bool checked = EINA_TRUE;
260 int i;
261
262 ck_assert_int_eq(type, (int)EIO_MONITOR_FILE_CREATED);
263
264 for (i = 0; multi_files[i].s && strcmp(multi_files[i].s, ev->filename); i++)
265 ;
266
267 if (!multi_files[i].s) return ;
268 multi_files[i].checked = EINA_TRUE;
269
270 for (i = 0; multi_files[i].s; i++)
271 checked &= multi_files[i].checked;
272
273 if (!checked) return ;
274
275 _cancel_timeout();
276 ecore_main_loop_quit();
277}
278
279START_TEST(eio_test_monitor_directory_multi_file_created_notify)
280{
281 Eina_Tmpstr *dirname = _common_init();
282
283 multi_files[0].s = eina_stringshare_printf("%s/eio_test_monitor_directory_m1file_created_notify", dirname);
284 multi_files[1].s = eina_stringshare_printf("%s/eio_test_monitor_directory_m2file_created_notify", dirname);
285 multi_files[2].s = eina_stringshare_printf("%s/eio_test_monitor_directory_m3file_created_notify", dirname);
286
287 //sleep to avoid catching event generated by above manipulations
288 usleep(500000);
289
290 //monitor directory
291 eio_monitor_add(dirname);
292 ecore_event_handler_add(EIO_MONITOR_FILE_CREATED, (Ecore_Event_Handler_Cb)_multi_file_created_cb, NULL);
293
294 ecore_timer_add(TEST_OPERATION_DELAY, _create_file, multi_files[0].s);
295 ecore_timer_add(TEST_OPERATION_DELAY, _create_file, multi_files[1].s);
296 ecore_timer_add(TEST_OPERATION_DELAY + TEST_OPERATION_DELAY, _create_file, multi_files[2].s);
297
298 ecore_main_loop_begin();
299
300 _common_shutdown(dirname);
301}
302END_TEST
303
245static void _file_deleted_cb(void *data, int type, void *event) 304static void _file_deleted_cb(void *data, int type, void *event)
246{ 305{
247 ck_assert_int_eq(type, (int)EIO_MONITOR_FILE_DELETED); 306 ck_assert_int_eq(type, (int)EIO_MONITOR_FILE_DELETED);
@@ -729,6 +788,7 @@ void eio_test_monitor(TCase *tc)
729 tcase_add_test(tc, eio_test_monitor_add_add_remove_remove); 788 tcase_add_test(tc, eio_test_monitor_add_add_remove_remove);
730 789
731 tcase_add_test(tc, eio_test_monitor_directory_file_created_notify); 790 tcase_add_test(tc, eio_test_monitor_directory_file_created_notify);
791 tcase_add_test(tc, eio_test_monitor_directory_multi_file_created_notify);
732 tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify); 792 tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify);
733 tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify); 793 tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify);
734#if !defined(_WIN32) && !defined(__MACH__) 794#if !defined(_WIN32) && !defined(__MACH__)