summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Friloux <guillaume.friloux@gmail.com>2013-11-06 15:10:28 +0100
committerGuillaume Friloux <guillaume.friloux@gmail.com>2013-11-06 15:10:28 +0100
commit4e425d92bd49ad0aed7691ac88aadc96672c0de6 (patch)
treeffd452b0ff1dd677ea03107fe5a727aecd23a2ac
parent1b216cc108169c08633fd43f74fa0f4cc77f2e86 (diff)
Adds a test case for the DNS error patch.
Do not set the timeout value to something too low or you walk over another bug i discovered and that needs a lil talk.
-rw-r--r--src/tests/ecore_test_ecore_con.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/tests/ecore_test_ecore_con.c b/src/tests/ecore_test_ecore_con.c
index 45c1f69f..4b53866d 100644
--- a/src/tests/ecore_test_ecore_con.c
+++ b/src/tests/ecore_test_ecore_con.c
@@ -146,6 +146,24 @@ _data(void *data, int type __UNUSED__, void *ev)
146 return ECORE_CALLBACK_RENEW; 146 return ECORE_CALLBACK_RENEW;
147} 147}
148 148
149Eina_Bool
150_dns_add(void *data, int type EINA_UNUSED, void *ev EINA_UNUSED)
151{
152 Eina_Bool *err_check = data;
153 *err_check = EINA_FALSE;
154 ecore_main_loop_quit();
155 return ECORE_CALLBACK_RENEW;
156}
157
158Eina_Bool
159_dns_err(void *data, int type EINA_UNUSED, void *ev EINA_UNUSED)
160{
161 Eina_Bool *err_check = data;
162 *err_check = EINA_TRUE;
163 ecore_main_loop_quit();
164 return ECORE_CALLBACK_RENEW;
165}
166
149START_TEST(ecore_test_ecore_con_server) 167START_TEST(ecore_test_ecore_con_server)
150{ 168{
151 Ecore_Con_Server *server; 169 Ecore_Con_Server *server;
@@ -251,8 +269,46 @@ START_TEST(ecore_test_ecore_con_init)
251} 269}
252END_TEST 270END_TEST
253 271
272START_TEST(ecore_test_ecore_con_dns)
273{
274 Ecore_Con_Server *client;
275 Ecore_Event_Handler *e_err;
276 Ecore_Event_Handler *e_add;
277 Eina_Bool err_check = EINA_FALSE;
278 int ret;
279
280 ret = eina_init();
281 fail_if(ret != 1);
282 ret = ecore_init();
283 fail_if(ret != 1);
284 ret = ecore_con_init();
285 fail_if(ret != 1);
286
287 e_add = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _dns_add, (void *) &err_check);
288 e_err = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR, _dns_err, (void *) &err_check);
289
290 client = ecore_con_server_connect(ECORE_CON_REMOTE_TCP,
291 "wongsub.wrongdns.lan", 1234, NULL);
292 fail_if (client == NULL);
293 ecore_con_server_timeout_set(client, 5.0);
294
295 ecore_main_loop_begin();
296 fail_if (err_check == EINA_FALSE);
297 fail_if (ecore_event_handler_del(e_err) != (void *) &err_check);
298 fail_if (ecore_event_handler_del(e_add) != (void *) &err_check);
299
300 ret = ecore_con_shutdown();
301 fail_if(ret != 0);
302 ret = ecore_shutdown();
303 fail_if(ret != 0);
304 ret = eina_shutdown();
305 fail_if(ret != 0);
306}
307END_TEST
308
254void ecore_test_ecore_con(TCase *tc) 309void ecore_test_ecore_con(TCase *tc)
255{ 310{
256 tcase_add_test(tc, ecore_test_ecore_con_init); 311 tcase_add_test(tc, ecore_test_ecore_con_init);
257 tcase_add_test(tc, ecore_test_ecore_con_server); 312 tcase_add_test(tc, ecore_test_ecore_con_server);
313 tcase_add_test(tc, ecore_test_ecore_con_dns);
258} 314}