eio-tests: fix deadlocking of the testsuite

what happens was is that efl_model_children_count_get trigger the
monitoring to start. However, that means that *sometimes* the created
file in this test was sometimes called in a ADDED event due to the
listing of files, and sometimes due to the event of a newly added file.
The problem here is that when the ADDED event is added due to the file
listing and not the monitoring, then there *could* be a ADDED event and
the deletion of the file will not trigger a REMOVED event. Which is a
bug.

However, up to this point it is not fully clear to me if this is
solvable with this setup of monitoring or not. So this test is changed
to not trigger this deadlock anymore, the idea of the test is still
tested, just in another way.

ref T7478

Differential Revision: https://phab.enlightenment.org/D7412
This commit is contained in:
Marcel Hollerbach 2018-12-04 16:14:25 +01:00
parent e15d696372
commit 117d94d90e
1 changed files with 14 additions and 20 deletions

View File

@ -36,6 +36,8 @@ _children_removed_cb(void *data EINA_UNUSED, const Efl_Event* event)
eina_value_free(path);
}
static Eina_Bool started_up = EINA_FALSE;
static Eina_Value
_children_get(void *data,
const Eina_Value v,
@ -57,7 +59,7 @@ _children_get(void *data,
str = eina_value_to_string(path);
fail_if(str == NULL);
if (strcmp(temp_filename, str) == 0)
if (started_up && strcmp(temp_filename, str) == 0)
{
children_deleted = EINA_TRUE;
efl_model_child_del(filemodel, child);
@ -66,6 +68,17 @@ _children_get(void *data,
eina_value_free(path);
}
if (!started_up)
{
int fd;
if ((fd = eina_file_mkstemp("prefixXXXXXX.ext", &temp_filename)) > 0)
{
close(fd);
}
}
started_up = EINA_TRUE;
return v;
}
@ -79,21 +92,6 @@ _children_added_cb(void *d EINA_UNUSED, const Efl_Event* event)
eina_future_then(future, _children_get, event->object, NULL);
}
static Eina_Value
_create_file(void *data EINA_UNUSED,
const Eina_Value v,
const Eina_Future *dead_future EINA_UNUSED)
{
int fd;
if((fd = eina_file_mkstemp("prefixXXXXXX.ext", &temp_filename)) > 0)
{
close(fd);
}
return v;
}
EFL_START_TEST(eio_model_test_test_monitor_add)
{
Eo *filemodel = NULL;
@ -109,10 +107,6 @@ EFL_START_TEST(eio_model_test_test_monitor_add)
efl_event_callback_add(filemodel, EFL_MODEL_EVENT_CHILD_ADDED, &_children_added_cb, filemodel);
efl_event_callback_add(filemodel, EFL_MODEL_EVENT_CHILD_REMOVED, &_children_removed_cb, NULL);
future = efl_model_children_slice_get(filemodel, 0, efl_model_children_count_get(filemodel));
eina_future_then(future, &_create_file, NULL, NULL);
ecore_main_loop_begin();
efl_del(filemodel);