tests: add timeout to fixture for ecore tests

Summary:
this is mainly to handle the case of ecore-file, which fetches external
resources during the test and requires an active network connection which
may fail to resolve/connect/download during the test. if this particular test
fails then it is almost certainly a network issue

a future patch should implement some form of http server to remove the
dependency on external network resources

also probably all test suites should have timeout timers just in case

fix T6950
Depends on D6205

Reviewers: stefan_schmidt, cedric

Reviewed By: cedric

Subscribers: cedric, #committers

Tags: #efl

Maniphest Tasks: T6950

Differential Revision: https://phab.enlightenment.org/D6206
This commit is contained in:
Mike Blumenkrantz 2018-06-12 10:52:12 -04:00 committed by Mike Blumenkrantz
parent d5a4fba118
commit 7aeab74e41
3 changed files with 32 additions and 1 deletions

View File

@ -35,13 +35,39 @@ static const Efl_Test_Case etc[] = {
{ NULL, NULL }
};
static Ecore_Timer *timeout;
int timeout_reached = 0;
static Eina_Bool
timeout_cb()
{
const char *tcname = tcase_name();
timeout_reached = 1;
if (tcname && strstr(tcname, "download"))
{
fprintf(stderr, "test timeout reached: download failed, probably network issue. skipping\n");
ecore_main_loop_quit();
}
else
ck_abort_msg("test timeout reached!");
timeout = NULL;
return EINA_FALSE;
}
SUITE_INIT(ecore)
{
timeout_reached = 0;
ck_assert_int_eq(ecore_init(), 1);
timeout = ecore_timer_add(5.0, timeout_cb, NULL);
ck_assert_msg(!!timeout, "timeout timer creation failed!");
}
SUITE_SHUTDOWN(ecore)
{
ecore_timer_del(timeout);
timeout = NULL;
ck_assert_int_eq(ecore_shutdown(), 0);
}

View File

@ -3,6 +3,9 @@
#include <check.h>
#include "../efl_check.h"
extern int timeout_reached;
void ecore_test_ecore(TCase *tc);
void ecore_test_ecore_idle(TCase *tc);
void ecore_test_ecore_poller(TCase *tc);

View File

@ -508,6 +508,7 @@ EFL_START_TEST(ecore_test_ecore_file_download)
fail_if(!job);
ecore_file_download_abort(job);
ecore_main_loop_begin();
if (timeout_reached) goto end;
res = ecore_file_remove(dest_name);
fail_if(res != EINA_TRUE);
@ -519,10 +520,11 @@ EFL_START_TEST(ecore_test_ecore_file_download)
fail_if(res != EINA_TRUE);
fail_if(!job);
ecore_main_loop_begin();
if (timeout_reached) goto end;
fprintf(stderr, "Downloaded %lld bytes\n", ecore_file_size(dest_name));
res = ecore_file_exists(dest_name);
fail_if(res != EINA_TRUE);
end:
res = ecore_file_recursive_rm(download_dir);
fail_if(res != EINA_TRUE);