ecore_con: fix a wrong usage of server connection
authorMyoungwoon Roy, Kim <myoungwoon.kim@samsung.com>
Mon, 14 May 2018 01:45:34 +0000 (10:45 +0900)
committerYeongjong Lee <yj34.lee@samsung.com>
Fri, 13 Jul 2018 10:51:56 +0000 (19:51 +0900)
Change-Id: Ib0da8b9150fbcf6e1aea0c6a110e42452b32be0f

TC/ecore/ecore_con/utc_ecore_con_server_ip_get.c

index 61784015472a51b20c21bd3a9ef548b82a77bb77..df5644dfba857007f2e7b1aad5cad410f2a2821c 100644 (file)
@@ -7,11 +7,18 @@
 
 #include "../../utc_negative_unitest.h"
 
-#define HOSTNAME "yandex.ru"
+//#define HOSTNAME "yandex.ru"
+#define HOSTNAME "127.0.0.1"
 #define PORT 8080
 
 static Eina_Bool startup_status = EINA_FALSE;
-static Ecore_Con_Server *srv = NULL;
+static Ecore_Con_Server *svr = NULL;
+
+Eina_Bool _quit_timer_cb(void *data)
+{
+   ecore_main_loop_quit();
+   return ECORE_CALLBACK_CANCEL;
+}
 
 /**
  * @addtogroup ecore_con
@@ -29,11 +36,9 @@ setup(void)
    printf(" ============ Startup ============ \n");
    if (ecore_con_init() > 0)
      {
-        srv = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "127.0.0.1", PORT, NULL);
-        if (srv != NULL)
-          {
-             startup_status = EINA_TRUE;
-          }
+        svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, HOSTNAME, PORT, NULL);
+        if (svr != NULL)
+          startup_status = EINA_TRUE;
      }
 }
 
@@ -66,11 +71,17 @@ START_TEST(utc_ecore_con_server_ip_get_p)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (startup was been executed unsuccessfully)..", __FILE__, __LINE__);
      }
-
-   const char *ip = NULL;
    Eina_Bool ok = EINA_FALSE;
 
-   ip = ecore_con_server_ip_get(srv);
+   if (ecore_timer_add(0.5, _quit_timer_cb, NULL) == NULL)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (timer cannot be created for testing.., __FILE__, __LINE__");
+     }
+
+   ecore_main_loop_begin();
+
+   const char *ip = NULL;
+   ip = ecore_con_server_ip_get(svr);
    if (ip != NULL)
      {
         printf("IP is %s\n", ip);
@@ -85,6 +96,10 @@ START_TEST(utc_ecore_con_server_ip_get_p)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
      }
+
+   if (svr) ecore_con_server_del(svr);
+   svr = NULL;
+
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }
 END_TEST
@@ -111,10 +126,14 @@ START_TEST(utc_ecore_con_server_ip_get_n)
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (startup was been executed unsuccessfully)..", __FILE__, __LINE__);
      }
 
-   if (UNITEST_FUNC_NEG_RET(NULL, ecore_con_server_ip_get, srv) == TEST_FAIL)
+   if (UNITEST_FUNC_NEG_RET(NULL, ecore_con_server_ip_get, svr) == TEST_FAIL)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
      }
+
+   if (svr) ecore_con_server_del(svr);
+   svr = NULL;
+
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }
 END_TEST