summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-02-09 12:11:37 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-09 22:03:27 +0100
commit024880add4bbe932f826cf408f25185448963b6b (patch)
tree52588f61c54c6cce8b9db7b289474992d75030e2 /src
parent00c2451656167dc4a42dfa1ef84fa7f21e5dc48e (diff)
ecore_con: add test cases to test ecore_con_server and client with different options.
Summary: Before ecore_con_server_add and client add with only TCP sockets. Have made that function generic and testing for other options too. Not all options are covered. Need to add different kind of cases for other options. Will check how I can add and add. Reviewers: stefan_schmidt, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1939 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/tests/ecore/ecore_test_ecore_con.c69
1 files changed, 59 insertions, 10 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_con.c b/src/tests/ecore/ecore_test_ecore_con.c
index ca0e311c11..58ea44c70b 100644
--- a/src/tests/ecore/ecore_test_ecore_con.c
+++ b/src/tests/ecore/ecore_test_ecore_con.c
@@ -162,7 +162,7 @@ _dns_err(void *data, int type EINA_UNUSED, void *ev EINA_UNUSED)
162 return ECORE_CALLBACK_RENEW; 162 return ECORE_CALLBACK_RENEW;
163} 163}
164 164
165START_TEST(ecore_test_ecore_con_server) 165void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name)
166{ 166{
167 Ecore_Con_Server *server; 167 Ecore_Con_Server *server;
168 Ecore_Con_Server *client; 168 Ecore_Con_Server *client;
@@ -171,13 +171,13 @@ START_TEST(ecore_test_ecore_con_server)
171 Ecore_Event_Handler *handlers[6]; 171 Ecore_Event_Handler *handlers[6];
172 void *server_data = malloc (1); 172 void *server_data = malloc (1);
173 void *client_data = malloc (1); 173 void *client_data = malloc (1);
174 int ret; 174 char sdata[] = "Server_info";
175 double timeout_val = 10, timeout_ret;
176 int ret, server_port = 1234;
175 void *del_ret; 177 void *del_ret;
176 178
177 ret = eina_init(); 179 ret = eina_init();
178 fail_if(ret != 1); 180 fail_if(ret != 1);
179 ret = ecore_init();
180 fail_if(ret < 1);
181 ret = ecore_con_init(); 181 ret = ecore_con_init();
182 fail_if(ret != 1); 182 fail_if(ret != 1);
183 183
@@ -201,14 +201,30 @@ START_TEST(ecore_test_ecore_con_server)
201 _data, (void *) 2); 201 _data, (void *) 2);
202 fail_if(handlers[5] == NULL); 202 fail_if(handlers[5] == NULL);
203 203
204 server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, "127.0.0.1", 1234, 204 fail_if (ecore_con_server_connected_get(server));
205
206 server = ecore_con_server_add(compl_type, name, server_port,
205 server_data); 207 server_data);
206 fail_if (server == NULL); 208 fail_if (server == NULL);
207 209
208 ecore_con_server_timeout_set(server, 10); 210 del_ret = ecore_con_server_data_get(server);
211 fail_if (del_ret != server_data);
212
213 del_ret = ecore_con_server_data_set(server, sdata);
214 fail_if (del_ret != server_data);
215
216 fail_if (!ecore_con_server_connected_get(server));
217
218 ecore_con_server_timeout_set(server, timeout_val);
219 timeout_ret = ecore_con_server_timeout_get(server);
220 fail_if (timeout_ret != timeout_val);
221
222 ret = ecore_con_server_port_get(server);
223 fail_if (ret != server_port);
224
209 ecore_con_server_client_limit_set(server, 1, 0); 225 ecore_con_server_client_limit_set(server, 1, 0);
210 226
211 client = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "127.0.0.1", 1234, 227 client = ecore_con_server_connect(compl_type, name, server_port,
212 client_data); 228 client_data);
213 fail_if (client == NULL); 229 fail_if (client == NULL);
214 230
@@ -226,7 +242,8 @@ START_TEST(ecore_test_ecore_con_server)
226 ecore_con_server_uptime_get(server)); 242 ecore_con_server_uptime_get(server));
227 243
228 del_ret = ecore_con_server_del(server); 244 del_ret = ecore_con_server_del(server);
229 fail_if (del_ret != server_data); 245 fail_if (strcmp((char *)del_ret, sdata));
246
230 free (server_data); 247 free (server_data);
231 del_ret = ecore_con_server_del(client); 248 del_ret = ecore_con_server_del(client);
232 fail_if (del_ret != client_data); 249 fail_if (del_ret != client_data);
@@ -248,9 +265,37 @@ START_TEST(ecore_test_ecore_con_server)
248 265
249 ret = ecore_con_shutdown(); 266 ret = ecore_con_shutdown();
250 fail_if(ret != 0); 267 fail_if(ret != 0);
251 ret = ecore_shutdown();
252 ret = eina_shutdown(); 268 ret = eina_shutdown();
253} 269}
270
271START_TEST(ecore_test_ecore_con_local_user)
272{
273 _ecore_con_server_client_tests(ECORE_CON_LOCAL_USER, "test_sock");
274}
275END_TEST
276
277START_TEST(ecore_test_ecore_con_local_system)
278{
279 _ecore_con_server_client_tests(ECORE_CON_LOCAL_SYSTEM, "test_sock");
280}
281END_TEST
282
283START_TEST(ecore_test_ecore_con_local_abstract)
284{
285 _ecore_con_server_client_tests(ECORE_CON_LOCAL_ABSTRACT, "test_sock");
286}
287END_TEST
288
289START_TEST(ecore_test_ecore_con_remote_tcp)
290{
291 _ecore_con_server_client_tests(ECORE_CON_REMOTE_TCP, "127.0.0.1");
292}
293END_TEST
294
295START_TEST(ecore_test_ecore_con_remote_nodelay)
296{
297 _ecore_con_server_client_tests(ECORE_CON_REMOTE_NODELAY, "127.0.0.1");
298}
254END_TEST 299END_TEST
255 300
256START_TEST(ecore_test_ecore_con_init) 301START_TEST(ecore_test_ecore_con_init)
@@ -321,7 +366,11 @@ END_TEST
321void ecore_test_ecore_con(TCase *tc) 366void ecore_test_ecore_con(TCase *tc)
322{ 367{
323 tcase_add_test(tc, ecore_test_ecore_con_init); 368 tcase_add_test(tc, ecore_test_ecore_con_init);
324 tcase_add_test(tc, ecore_test_ecore_con_server); 369 tcase_add_test(tc, ecore_test_ecore_con_local_user);
370 tcase_add_test(tc, ecore_test_ecore_con_local_system);
371 tcase_add_test(tc, ecore_test_ecore_con_local_abstract);
372 tcase_add_test(tc,ecore_test_ecore_con_remote_tcp);
373 tcase_add_test(tc,ecore_test_ecore_con_remote_nodelay);
325 tcase_add_test(tc, ecore_test_ecore_con_dns); 374 tcase_add_test(tc, ecore_test_ecore_con_dns);
326 tcase_add_test(tc, ecore_test_ecore_con_shutdown_bef_init); 375 tcase_add_test(tc, ecore_test_ecore_con_shutdown_bef_init);
327} 376}