summaryrefslogtreecommitdiff
path: root/src/tests/ecore_con
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-04-22 14:26:57 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-22 15:10:19 +0200
commit48db81cfb5e01e7993afa65b649de4e2c043b07d (patch)
tree29282a4c6804073017782752aafcd86f056c9842 /src/tests/ecore_con
parentdab4fb492a0f6689f3f64275945c4214e6a496b3 (diff)
ecore_con: add test cases to cover more ecore con functions.
Summary: The dns lookup test would result in a crash unless https://phab.enlightenment.org/D2398 fix. Also added more functions to existing case to cover ecore_con.c Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2403 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/ecore_con')
-rw-r--r--src/tests/ecore_con/ecore_con_test_ecore_con.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/tests/ecore_con/ecore_con_test_ecore_con.c b/src/tests/ecore_con/ecore_con_test_ecore_con.c
index 1d8379e..dc31d8e 100644
--- a/src/tests/ecore_con/ecore_con_test_ecore_con.c
+++ b/src/tests/ecore_con/ecore_con_test_ecore_con.c
@@ -27,6 +27,10 @@ _add(void *data, int type EINA_UNUSED, void *ev)
27 fail_if (data != (void *) 1); 27 fail_if (data != (void *) 1);
28 fail_if (!event->client); 28 fail_if (!event->client);
29 29
30 fprintf(stderr, "client fd: %d\n",
31 ecore_con_client_fd_get(event->client));
32 fail_unless(ecore_con_client_fd_get(event->client));
33
30 printf("Client with ip %s, port %d, connected = %d!\n", 34 printf("Client with ip %s, port %d, connected = %d!\n",
31 ecore_con_client_ip_get(event->client), 35 ecore_con_client_ip_get(event->client),
32 ecore_con_client_port_get(event->client), 36 ecore_con_client_port_get(event->client),
@@ -79,8 +83,11 @@ _del(void *data , int type EINA_UNUSED, void *ev)
79 83
80 printf("Lost client with ip %s!\n", 84 printf("Lost client with ip %s!\n",
81 ecore_con_client_ip_get(event->client)); 85 ecore_con_client_ip_get(event->client));
86 fail_if(ecore_con_client_ip_get(event->client));
87
82 printf("Client was connected for %0.3f seconds.\n", 88 printf("Client was connected for %0.3f seconds.\n",
83 ecore_con_client_uptime_get(event->client)); 89 ecore_con_client_uptime_get(event->client));
90 fail_unless(ecore_con_client_uptime_get(event->client));
84 91
85 del_data = ecore_con_client_del(event->client); 92 del_data = ecore_con_client_del(event->client);
86 fail_if (strcmp((char *)del_data, cdata)); 93 fail_if (strcmp((char *)del_data, cdata));
@@ -93,7 +100,9 @@ _del(void *data , int type EINA_UNUSED, void *ev)
93 100
94 fail_if (data != (void *) 2); 101 fail_if (data != (void *) 2);
95 102
96 printf("Lost server with ip %s!\n", ecore_con_server_ip_get(event->server)); 103 printf("Lost server with ip %s!\n",
104 ecore_con_server_ip_get(event->server));
105 fail_unless(ecore_con_server_ip_get(event->server));
97 106
98 ecore_con_server_del(event->server); 107 ecore_con_server_del(event->server);
99 } 108 }
@@ -179,7 +188,7 @@ _dns_err(void *data, int type EINA_UNUSED, void *ev EINA_UNUSED)
179void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name, Eina_Bool is_ssl, int server_port) 188void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name, Eina_Bool is_ssl, int server_port)
180{ 189{
181 Ecore_Con_Server *server = NULL; 190 Ecore_Con_Server *server = NULL;
182 Ecore_Con_Server *client; 191 Ecore_Con_Server *client, *client2;
183 Ecore_Con_Client *cl; 192 Ecore_Con_Client *cl;
184 const Eina_List *clients, *l; 193 const Eina_List *clients, *l;
185 Ecore_Event_Handler *handlers[6]; 194 Ecore_Event_Handler *handlers[6];
@@ -248,6 +257,10 @@ void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name,
248 client_data); 257 client_data);
249 fail_if (client == NULL); 258 fail_if (client == NULL);
250 259
260 client2 = ecore_con_server_connect(compl_type, name, server_port,
261 client_data);
262 fail_if (client2 == NULL);
263
251 if (is_ssl) 264 if (is_ssl)
252 { 265 {
253 fail_unless(ecore_con_ssl_server_cafile_add(server, TESTS_SRC_DIR"/server.pem")); 266 fail_unless(ecore_con_ssl_server_cafile_add(server, TESTS_SRC_DIR"/server.pem"));
@@ -259,6 +272,14 @@ void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name,
259 272
260 ecore_main_loop_begin(); 273 ecore_main_loop_begin();
261 274
275 fprintf(stderr, "server fd for client 1: %d\n",
276 ecore_con_server_fd_get(client));
277 fail_unless(ecore_con_server_fd_get(client));
278
279 fprintf(stderr, "server fd for client 2: %d\n",
280 ecore_con_server_fd_get(client2));
281 fail_unless(ecore_con_server_fd_get(client2));
282
262 clients = ecore_con_server_clients_get(server); 283 clients = ecore_con_server_clients_get(server);
263 printf("Clients connected to this server when exiting: %d\n", 284 printf("Clients connected to this server when exiting: %d\n",
264 eina_list_count(clients)); 285 eina_list_count(clients));
@@ -270,6 +291,9 @@ void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name,
270 printf("Server was up for %0.3f seconds\n", 291 printf("Server was up for %0.3f seconds\n",
271 ecore_con_server_uptime_get(server)); 292 ecore_con_server_uptime_get(server));
272 293
294 del_ret = ecore_con_server_del(client2);
295 fail_if (del_ret != client_data);
296
273 del_ret = ecore_con_server_del(server); 297 del_ret = ecore_con_server_del(server);
274 fail_if (strcmp((char *)del_ret, sdata)); 298 fail_if (strcmp((char *)del_ret, sdata));
275 free (server_data); 299 free (server_data);
@@ -532,6 +556,32 @@ START_TEST(ecore_test_ecore_con_shutdown_bef_init)
532} 556}
533END_TEST 557END_TEST
534 558
559static void
560_lookup_done_cb(const char *canonname, const char *ip, struct sockaddr *addr, int addrlen, void *data)
561{
562 fail_if(strncmp(canonname,(char *)data, strlen((char *)data)));
563
564 fprintf(stderr, "canonname = %s\n", canonname);
565 fprintf(stderr, "ip = %s\n", ip);
566 fprintf(stderr, "addr = %p\n", addr);
567 fprintf(stderr, "addrlen = %d\n", addrlen);
568
569 ecore_main_loop_quit();
570}
571
572START_TEST(ecore_test_ecore_con_dns_lookup)
573{
574 const char link[] = "www.google.com";
575 ecore_con_init();
576
577 fail_unless(ecore_con_lookup(link, _lookup_done_cb, link));
578
579 ecore_main_loop_begin();
580
581 ecore_con_shutdown();
582}
583END_TEST
584
535void ecore_con_test_ecore_con(TCase *tc) 585void ecore_con_test_ecore_con(TCase *tc)
536{ 586{
537 tcase_add_test(tc, ecore_test_ecore_con_init); 587 tcase_add_test(tc, ecore_test_ecore_con_init);
@@ -560,5 +610,6 @@ void ecore_con_test_ecore_con(TCase *tc)
560 tcase_add_test(tc, ecore_test_ecore_con_remote_nodelay_mixed_load_cert); 610 tcase_add_test(tc, ecore_test_ecore_con_remote_nodelay_mixed_load_cert);
561 tcase_add_test(tc, ecore_test_ecore_con_ssl_available); 611 tcase_add_test(tc, ecore_test_ecore_con_ssl_available);
562 tcase_add_test(tc, ecore_test_ecore_con_dns); 612 tcase_add_test(tc, ecore_test_ecore_con_dns);
613 tcase_add_test(tc, ecore_test_ecore_con_dns_lookup);
563 tcase_add_test(tc, ecore_test_ecore_con_shutdown_bef_init); 614 tcase_add_test(tc, ecore_test_ecore_con_shutdown_bef_init);
564} 615}