summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-05-24 11:21:06 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-05-24 11:21:06 -0400
commitf4a453f660d435416903fc29da94a1c0181e8902 (patch)
tree72cccfc43cac96d68688193637e8cd881fb98521
parentfbf1aedba06dc702e389fd4358b7b258584440e6 (diff)
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.c26
-rw-r--r--src/tests/ecore/ecore_suite.h3
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c4
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[] = {
35 { NULL, NULL } 35 { NULL, NULL }
36}; 36};
37 37
38static Ecore_Timer *timeout;
39int timeout_reached = 0;
40
41static Eina_Bool
42timeout_cb()
43{
44 const char *tcname = tcase_name();
45
46 timeout_reached = 1;
47
48 if (tcname && strstr(tcname, "download"))
49 {
50 fprintf(stderr, "test timeout reached: download failed, probably network issue. skipping\n");
51 ecore_main_loop_quit();
52 }
53 else
54 ck_abort_msg("test timeout reached!");
55 timeout = NULL;
56 return EINA_FALSE;
57}
58
38SUITE_INIT(ecore) 59SUITE_INIT(ecore)
39{ 60{
61 timeout_reached = 0;
40 ck_assert_int_eq(ecore_init(), 1); 62 ck_assert_int_eq(ecore_init(), 1);
63 timeout = ecore_timer_add(5.0, timeout_cb, NULL);
64 ck_assert_msg(!!timeout, "timeout timer creation failed!");
41} 65}
42 66
43SUITE_SHUTDOWN(ecore) 67SUITE_SHUTDOWN(ecore)
44{ 68{
69 ecore_timer_del(timeout);
70 timeout = NULL;
45 ck_assert_int_eq(ecore_shutdown(), 0); 71 ck_assert_int_eq(ecore_shutdown(), 0);
46} 72}
47 73
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 @@
3 3
4#include <check.h> 4#include <check.h>
5#include "../efl_check.h" 5#include "../efl_check.h"
6
7extern int timeout_reached;
8
6void ecore_test_ecore(TCase *tc); 9void ecore_test_ecore(TCase *tc);
7void ecore_test_ecore_idle(TCase *tc); 10void ecore_test_ecore_idle(TCase *tc);
8void ecore_test_ecore_poller(TCase *tc); 11void 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)
508 fail_if(!job); 508 fail_if(!job);
509 ecore_file_download_abort(job); 509 ecore_file_download_abort(job);
510 ecore_main_loop_begin(); 510 ecore_main_loop_begin();
511 if (timeout_reached) goto end;
511 res = ecore_file_remove(dest_name); 512 res = ecore_file_remove(dest_name);
512 fail_if(res != EINA_TRUE); 513 fail_if(res != EINA_TRUE);
513 514
@@ -519,10 +520,11 @@ EFL_START_TEST(ecore_test_ecore_file_download)
519 fail_if(res != EINA_TRUE); 520 fail_if(res != EINA_TRUE);
520 fail_if(!job); 521 fail_if(!job);
521 ecore_main_loop_begin(); 522 ecore_main_loop_begin();
523 if (timeout_reached) goto end;
522 fprintf(stderr, "Downloaded %lld bytes\n", ecore_file_size(dest_name)); 524 fprintf(stderr, "Downloaded %lld bytes\n", ecore_file_size(dest_name));
523 res = ecore_file_exists(dest_name); 525 res = ecore_file_exists(dest_name);
524 fail_if(res != EINA_TRUE); 526 fail_if(res != EINA_TRUE);
525 527end:
526 res = ecore_file_recursive_rm(download_dir); 528 res = ecore_file_recursive_rm(download_dir);
527 fail_if(res != EINA_TRUE); 529 fail_if(res != EINA_TRUE);
528 530