ecore: Fix download test.
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Tue, 30 Jul 2019 19:22:03 +0000 (15:22 -0400)
committerWooHyun Jung <wh0705.jung@samsung.com>
Mon, 5 Aug 2019 02:05:22 +0000 (11:05 +0900)
Summary:
After ecore_main_loop_quit() changes, calling it from outside the main
loop does not make the next iteration of the main loop quit, causing the
original version of the test to deadlock.

Also update the function documentation about it.

Reviewers: zmike

Reviewed By: zmike

Subscribers: cedric, #reviewers, felipealmeida, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9448

src/lib/ecore/Ecore_Common.h
src/tests/ecore/ecore_test_ecore_file.c

index 6df1006..24cbf8a 100644 (file)
@@ -328,8 +328,10 @@ EAPI void ecore_main_loop_begin(void);
  * Quits the main loop once all the events currently on the queue have
  * been processed.
  *
- * This function returns immediately, but will mark the ecore_main_loop_begin()
- * function to return at the end of the current main loop iteration.
+ * This function returns immediately, but if called inside the main loop
+ * it will mark the ecore_main_loop_begin() function to return at the
+ * end of the current main loop iteration.
+ *
  */
 EAPI void ecore_main_loop_quit(void);
 
index fe0e73f..3b6fcff 100644 (file)
@@ -104,9 +104,13 @@ completion_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED, int status)
 }
 
 void
-err_completion_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED, int status)
+err_completion_cb(void *data, const char *file EINA_UNUSED, int status)
 {
+   if (data)
+     *((int*) data) = status;
    fail_if(status != 1);
+   // NOP if called from outside main loop. Keep it here if abort fails and
+   // we get called from there.
    ecore_main_loop_quit();
 }
 
@@ -521,12 +525,15 @@ EFL_START_TEST(ecore_test_ecore_file_download)
                              progress_cb, NULL, &job);
    fail_if(res != EINA_FALSE);
 
+   int status = 0;
    res = ecore_file_download(download_url, dest_name, err_completion_cb,
-                             progress_cb, NULL, &job);
+                             progress_cb, &status, &job);
    fail_if(res != EINA_TRUE);
    fail_if(!job);
    ecore_file_download_abort(job);
-   ecore_main_loop_begin();
+   fail_if(status != 1);
+   if (!status)
+     ecore_main_loop_begin();
    if (timeout_reached) goto end;
    res = ecore_file_remove(dest_name);
    fail_if(res != EINA_TRUE);