diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2018-05-24 11:21:06 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2018-05-24 11:21:06 -0400 |
commit | f4a453f660d435416903fc29da94a1c0181e8902 (patch) | |
tree | 72cccfc43cac96d68688193637e8cd881fb98521 | |
parent | fbf1aedba06dc702e389fd4358b7b258584440e6 (diff) | |
download | efl-devs/discomfitor/test.tar.gz |
tests: add timeout to fixture for ecore testsdevs/discomfitor/test
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
-rw-r--r-- | src/tests/ecore/ecore_suite.c | 26 | ||||
-rw-r--r-- | src/tests/ecore/ecore_suite.h | 3 | ||||
-rw-r--r-- | src/tests/ecore/ecore_test_ecore_file.c | 4 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/tests/ecore/ecore_suite.c b/src/tests/ecore/ecore_suite.c index 4db69812ed..0e67feafa7 100644 --- a/src/tests/ecore/ecore_suite.c +++ b/src/tests/ecore/ecore_suite.c @@ -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); } diff --git a/src/tests/ecore/ecore_suite.h b/src/tests/ecore/ecore_suite.h index 5cd57de8e3..debc20337e 100644 --- a/src/tests/ecore/ecore_suite.h +++ b/src/tests/ecore/ecore_suite.h @@ -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); diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c index 764d0073f9..fb23ffb15e 100644 --- a/src/tests/ecore/ecore_test_ecore_file.c +++ b/src/tests/ecore/ecore_test_ecore_file.c @@ -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); |