forked from enlightenment/efl
ecore_con: Split ecore_con test suite from ecore.
Summary: Have created ecore_con test suite. Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric, Sergeant_Whitespace, stefan_schmidt Subscribers: stefan_schmidt, Sergeant_Whitespace, cedric Maniphest Tasks: T2235 Differential Revision: https://phab.enlightenment.org/D2269
This commit is contained in:
parent
39432aa0f2
commit
4b0e879591
|
@ -187,8 +187,6 @@ TESTS += tests/ecore/ecore_suite
|
||||||
tests_ecore_ecore_suite_SOURCES = \
|
tests_ecore_ecore_suite_SOURCES = \
|
||||||
tests/ecore/ecore_suite.c \
|
tests/ecore/ecore_suite.c \
|
||||||
tests/ecore/ecore_test_ecore.c \
|
tests/ecore/ecore_test_ecore.c \
|
||||||
tests/ecore/ecore_test_ecore_con.c \
|
|
||||||
tests/ecore/ecore_test_ecore_con_url.c \
|
|
||||||
tests/ecore/ecore_test_ecore_imf.c \
|
tests/ecore/ecore_test_ecore_imf.c \
|
||||||
tests/ecore/ecore_test_timer.c \
|
tests/ecore/ecore_test_timer.c \
|
||||||
tests/ecore/ecore_test_ecore_evas.c \
|
tests/ecore/ecore_test_ecore_evas.c \
|
||||||
|
@ -204,7 +202,6 @@ tests_ecore_ecore_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
@CHECK_CFLAGS@ \
|
@CHECK_CFLAGS@ \
|
||||||
@ECORE_CFLAGS@ \
|
@ECORE_CFLAGS@ \
|
||||||
@ECORE_AUDIO_CFLAGS@ \
|
@ECORE_AUDIO_CFLAGS@ \
|
||||||
@ECORE_CON_CFLAGS@ \
|
|
||||||
@ECORE_FILE_CFLAGS@ \
|
@ECORE_FILE_CFLAGS@ \
|
||||||
@ECORE_X_CFLAGS@ \
|
@ECORE_X_CFLAGS@ \
|
||||||
@ECORE_IMF_CFLAGS@ \
|
@ECORE_IMF_CFLAGS@ \
|
||||||
|
@ -219,7 +216,6 @@ tests_ecore_ecore_suite_LDADD = \
|
||||||
@CHECK_LIBS@ \
|
@CHECK_LIBS@ \
|
||||||
@USE_ECORE_LIBS@ \
|
@USE_ECORE_LIBS@ \
|
||||||
@USE_ECORE_AUDIO_LIBS@ \
|
@USE_ECORE_AUDIO_LIBS@ \
|
||||||
@USE_ECORE_CON_LIBS@ \
|
|
||||||
@USE_ECORE_FILE_LIBS@ \
|
@USE_ECORE_FILE_LIBS@ \
|
||||||
@USE_ECORE_X_LIBS@ \
|
@USE_ECORE_X_LIBS@ \
|
||||||
@USE_ECORE_IMF_LIBS@ \
|
@USE_ECORE_IMF_LIBS@ \
|
||||||
|
@ -232,7 +228,6 @@ tests_ecore_ecore_suite_LDADD = \
|
||||||
tests_ecore_ecore_suite_DEPENDENCIES = \
|
tests_ecore_ecore_suite_DEPENDENCIES = \
|
||||||
@USE_ECORE_INTERNAL_LIBS@ \
|
@USE_ECORE_INTERNAL_LIBS@ \
|
||||||
@USE_ECORE_AUDIO_INTERNAL_LIBS@ \
|
@USE_ECORE_AUDIO_INTERNAL_LIBS@ \
|
||||||
@USE_ECORE_CON_INTERNAL_LIBS@ \
|
|
||||||
@USE_ECORE_FILE_INTERNAL_LIBS@ \
|
@USE_ECORE_FILE_INTERNAL_LIBS@ \
|
||||||
@USE_ECORE_X_INTERNAL_LIBS@ \
|
@USE_ECORE_X_INTERNAL_LIBS@ \
|
||||||
@USE_ECORE_IMF_INTERNAL_LIBS@ \
|
@USE_ECORE_IMF_INTERNAL_LIBS@ \
|
||||||
|
@ -266,9 +261,7 @@ endif
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
tests/ecore/modem.wav \
|
tests/ecore/modem.wav \
|
||||||
tests/ecore/sms.ogg \
|
tests/ecore/sms.ogg
|
||||||
tests/ecore/server.key \
|
|
||||||
tests/ecore/server.pem
|
|
||||||
|
|
||||||
if HAVE_ELUA
|
if HAVE_ELUA
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,41 @@ lib_ecore_con_libecore_con_la_LIBADD = @ECORE_CON_LIBS@ @EVIL_LIBS@
|
||||||
lib_ecore_con_libecore_con_la_DEPENDENCIES = @ECORE_CON_INTERNAL_LIBS@
|
lib_ecore_con_libecore_con_la_DEPENDENCIES = @ECORE_CON_INTERNAL_LIBS@
|
||||||
lib_ecore_con_libecore_con_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
lib_ecore_con_libecore_con_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
check_PROGRAMS += tests/ecore_con/ecore_con_suite
|
||||||
|
TESTS += tests/ecore_con/ecore_con_suite
|
||||||
|
|
||||||
|
tests_ecore_con_ecore_con_suite_SOURCES = \
|
||||||
|
tests/ecore_con/ecore_con_suite.c \
|
||||||
|
tests/ecore_con/ecore_con_test_ecore_con.c \
|
||||||
|
tests/ecore_con/ecore_con_test_ecore_con_url.c \
|
||||||
|
tests/ecore_con/ecore_con_suite.h
|
||||||
|
|
||||||
|
tests_ecore_con_ecore_con_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/ecore_con\" \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/ecore_con\" \
|
||||||
|
@CHECK_CFLAGS@ \
|
||||||
|
@ECORE_CFLAGS@ \
|
||||||
|
@ECORE_CON_CFLAGS@
|
||||||
|
|
||||||
|
tests_ecore_con_ecore_con_suite_LDADD = \
|
||||||
|
@CHECK_LIBS@ \
|
||||||
|
@USE_ECORE_LIBS@ \
|
||||||
|
@USE_ECORE_CON_LIBS@
|
||||||
|
|
||||||
|
tests_ecore_con_ecore_con_suite_DEPENDENCIES = \
|
||||||
|
@USE_ECORE_INTERNAL_LIBS@ \
|
||||||
|
@USE_ECORE_CON_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
tests/ecore_con/server.key \
|
||||||
|
tests/ecore_con/server.pem
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
if HAVE_ELUA
|
if HAVE_ELUA
|
||||||
|
|
||||||
ecore_con_eolian_lua = $(ecore_con_eolian_files:%.eo=%.eo.lua)
|
ecore_con_eolian_lua = $(ecore_con_eolian_files:%.eo=%.eo.lua)
|
||||||
|
|
|
@ -19,8 +19,6 @@ struct _Ecore_Test_Case
|
||||||
|
|
||||||
static const Ecore_Test_Case etc[] = {
|
static const Ecore_Test_Case etc[] = {
|
||||||
{ "Ecore", ecore_test_ecore },
|
{ "Ecore", ecore_test_ecore },
|
||||||
{ "Ecore_Con", ecore_test_ecore_con },
|
|
||||||
{ "Ecore_Con_Url", ecore_test_ecore_con_url },
|
|
||||||
#if HAVE_ECORE_X
|
#if HAVE_ECORE_X
|
||||||
{ "Ecore_X", ecore_test_ecore_x },
|
{ "Ecore_X", ecore_test_ecore_x },
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
|
|
||||||
void ecore_test_ecore(TCase *tc);
|
void ecore_test_ecore(TCase *tc);
|
||||||
void ecore_test_ecore_con(TCase *tc);
|
|
||||||
void ecore_test_ecore_con_url(TCase *tc);
|
|
||||||
void ecore_test_ecore_x(TCase *tc);
|
void ecore_test_ecore_x(TCase *tc);
|
||||||
void ecore_test_ecore_imf(TCase *tc);
|
void ecore_test_ecore_imf(TCase *tc);
|
||||||
void ecore_test_ecore_audio(TCase *tc);
|
void ecore_test_ecore_audio(TCase *tc);
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "Ecore.h"
|
||||||
|
|
||||||
|
#include "ecore_con_suite.h"
|
||||||
|
|
||||||
|
typedef struct _Ecore_Con_Test_Case Ecore_Con_Test_Case;
|
||||||
|
|
||||||
|
struct _Ecore_Con_Test_Case
|
||||||
|
{
|
||||||
|
const char *test_case;
|
||||||
|
void (*build)(TCase *tc);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Ecore_Con_Test_Case etc[] = {
|
||||||
|
{ "Ecore_Con", ecore_con_test_ecore_con },
|
||||||
|
{ "Ecore_Con_Url", ecore_con_test_ecore_con_url },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_tests(void)
|
||||||
|
{
|
||||||
|
const Ecore_Con_Test_Case *itr;
|
||||||
|
|
||||||
|
itr = etc;
|
||||||
|
fputs("Available Test Cases:\n", stderr);
|
||||||
|
for (; itr->test_case; itr++)
|
||||||
|
fprintf(stderr, "\t%s\n", itr->test_case);
|
||||||
|
}
|
||||||
|
static Eina_Bool
|
||||||
|
_use_test(int argc, const char **argv, const char *test_case)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (; argc > 0; argc--, argv++)
|
||||||
|
if (strcmp(test_case, *argv) == 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
ecore_con_suite_build(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
TCase *tc;
|
||||||
|
Suite *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
s = suite_create("Ecore_Con");
|
||||||
|
|
||||||
|
for (i = 0; etc[i].test_case; ++i)
|
||||||
|
{
|
||||||
|
if (!_use_test(argc, argv, etc[i].test_case)) continue;
|
||||||
|
tc = tcase_create(etc[i].test_case);
|
||||||
|
|
||||||
|
etc[i].build(tc);
|
||||||
|
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
tcase_set_timeout(tc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
Suite *s;
|
||||||
|
SRunner *sr;
|
||||||
|
int i, failed_count;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
if ((strcmp(argv[i], "-h") == 0) ||
|
||||||
|
(strcmp(argv[i], "--help") == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
|
||||||
|
argv[0]);
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||||
|
(strcmp(argv[i], "--list") == 0))
|
||||||
|
{
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
putenv("EFL_RUN_IN_TREE=1");
|
||||||
|
|
||||||
|
s = ecore_con_suite_build(argc - 1, (const char **)argv + 1);
|
||||||
|
sr = srunner_create(s);
|
||||||
|
|
||||||
|
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
||||||
|
|
||||||
|
srunner_run_all(sr, CK_ENV);
|
||||||
|
failed_count = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
|
||||||
|
return (failed_count == 0) ? 0 : 255;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef _ECORE_CON_SUITE_H
|
||||||
|
#define _ECORE_CON_SUITE_H
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
void ecore_con_test_ecore_con(TCase *tc);
|
||||||
|
void ecore_con_test_ecore_con_url(TCase *tc);
|
||||||
|
|
||||||
|
#endif /* _ECORE_CON_SUITE_H */
|
|
@ -2,7 +2,7 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
#include "ecore_con_suite.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
|
@ -15,47 +15,47 @@ Eina_Bool
|
||||||
_add(void *data, int type EINA_UNUSED, void *ev)
|
_add(void *data, int type EINA_UNUSED, void *ev)
|
||||||
{
|
{
|
||||||
fail_if (type != ECORE_CON_EVENT_CLIENT_ADD &&
|
fail_if (type != ECORE_CON_EVENT_CLIENT_ADD &&
|
||||||
type != ECORE_CON_EVENT_SERVER_ADD);
|
type != ECORE_CON_EVENT_SERVER_ADD);
|
||||||
|
|
||||||
/* Server */
|
/* Server */
|
||||||
if (type == ECORE_CON_EVENT_CLIENT_ADD)
|
if (type == ECORE_CON_EVENT_CLIENT_ADD)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Add *event = ev;
|
Ecore_Con_Event_Client_Add *event = ev;
|
||||||
double timeout_val = 10, ret;
|
double timeout_val = 10, ret;
|
||||||
void *del_data;
|
void *del_data;
|
||||||
|
|
||||||
fail_if (data != (void *) 1);
|
fail_if (data != (void *) 1);
|
||||||
fail_if (!event->client);
|
fail_if (!event->client);
|
||||||
|
|
||||||
printf("Client with ip %s, port %d, connected = %d!\n",
|
printf("Client with ip %s, port %d, connected = %d!\n",
|
||||||
ecore_con_client_ip_get(event->client),
|
ecore_con_client_ip_get(event->client),
|
||||||
ecore_con_client_port_get(event->client),
|
ecore_con_client_port_get(event->client),
|
||||||
ecore_con_client_connected_get(event->client));
|
ecore_con_client_connected_get(event->client));
|
||||||
|
|
||||||
ecore_con_client_timeout_set(event->client, timeout_val);
|
ecore_con_client_timeout_set(event->client, timeout_val);
|
||||||
ret = ecore_con_client_timeout_get(event->client);
|
ret = ecore_con_client_timeout_get(event->client);
|
||||||
fail_if (ret != timeout_val);
|
fail_if (ret != timeout_val);
|
||||||
|
|
||||||
ecore_con_client_data_set(event->client, cdata);
|
ecore_con_client_data_set(event->client, cdata);
|
||||||
del_data = ecore_con_client_data_get(event->client);
|
del_data = ecore_con_client_data_get(event->client);
|
||||||
fail_if (strcmp((char *)del_data, cdata));
|
fail_if (strcmp((char *)del_data, cdata));
|
||||||
}
|
}
|
||||||
else if (type == ECORE_CON_EVENT_SERVER_ADD)
|
else if (type == ECORE_CON_EVENT_SERVER_ADD)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Server_Add *event = ev;
|
Ecore_Con_Event_Server_Add *event = ev;
|
||||||
const char ping[] = "PING";
|
const char ping[] = "PING";
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
fail_if (data != (void *) 2);
|
fail_if (data != (void *) 2);
|
||||||
fail_if (!event->server);
|
fail_if (!event->server);
|
||||||
printf("Server with ip %s, name %s, port %d, connected = %d!\n",
|
printf("Server with ip %s, name %s, port %d, connected = %d!\n",
|
||||||
ecore_con_server_ip_get(event->server),
|
ecore_con_server_ip_get(event->server),
|
||||||
ecore_con_server_name_get(event->server),
|
ecore_con_server_name_get(event->server),
|
||||||
ecore_con_server_port_get(event->server),
|
ecore_con_server_port_get(event->server),
|
||||||
ecore_con_server_connected_get(event->server));
|
ecore_con_server_connected_get(event->server));
|
||||||
ret = ecore_con_server_send(event->server, ping, sizeof(ping));
|
ret = ecore_con_server_send(event->server, ping, sizeof(ping));
|
||||||
fail_if (ret != sizeof(ping));
|
fail_if (ret != sizeof(ping));
|
||||||
ecore_con_server_flush(event->server);
|
ecore_con_server_flush(event->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
@ -67,34 +67,35 @@ _del(void *data , int type EINA_UNUSED, void *ev)
|
||||||
void *del_data;
|
void *del_data;
|
||||||
|
|
||||||
fail_if (type != ECORE_CON_EVENT_CLIENT_DEL &&
|
fail_if (type != ECORE_CON_EVENT_CLIENT_DEL &&
|
||||||
type != ECORE_CON_EVENT_SERVER_DEL);
|
type != ECORE_CON_EVENT_SERVER_DEL);
|
||||||
|
|
||||||
/* Server */
|
/* Server */
|
||||||
if (type == ECORE_CON_EVENT_CLIENT_DEL)
|
if (type == ECORE_CON_EVENT_CLIENT_DEL)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Del *event = ev;
|
Ecore_Con_Event_Client_Del *event = ev;
|
||||||
|
|
||||||
fail_if (data != (void *) 1);
|
fail_if (data != (void *) 1);
|
||||||
fail_if (!event->client);
|
fail_if (!event->client);
|
||||||
|
|
||||||
printf("Lost client with ip %s!\n", ecore_con_client_ip_get(event->client));
|
printf("Lost client with ip %s!\n",
|
||||||
printf("Client was connected for %0.3f seconds.\n",
|
ecore_con_client_ip_get(event->client));
|
||||||
ecore_con_client_uptime_get(event->client));
|
printf("Client was connected for %0.3f seconds.\n",
|
||||||
|
ecore_con_client_uptime_get(event->client));
|
||||||
|
|
||||||
del_data = ecore_con_client_del(event->client);
|
del_data = ecore_con_client_del(event->client);
|
||||||
fail_if (strcmp((char *)del_data, cdata));
|
fail_if (strcmp((char *)del_data, cdata));
|
||||||
}
|
}
|
||||||
else if (type == ECORE_CON_EVENT_SERVER_DEL)
|
else if (type == ECORE_CON_EVENT_SERVER_DEL)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Server_Del *event = ev;
|
Ecore_Con_Event_Server_Del *event = ev;
|
||||||
|
|
||||||
fail_if (!event->server);
|
fail_if (!event->server);
|
||||||
|
|
||||||
fail_if (data != (void *) 2);
|
fail_if (data != (void *) 2);
|
||||||
|
|
||||||
printf("Lost server with ip %s!\n", ecore_con_server_ip_get(event->server));
|
printf("Lost server with ip %s!\n", ecore_con_server_ip_get(event->server));
|
||||||
|
|
||||||
ecore_con_server_del(event->server);
|
ecore_con_server_del(event->server);
|
||||||
}
|
}
|
||||||
fail ();
|
fail ();
|
||||||
|
|
||||||
|
@ -106,52 +107,52 @@ _data(void *data, int type EINA_UNUSED, void *ev)
|
||||||
{
|
{
|
||||||
|
|
||||||
fail_if (type != ECORE_CON_EVENT_CLIENT_DATA &&
|
fail_if (type != ECORE_CON_EVENT_CLIENT_DATA &&
|
||||||
type != ECORE_CON_EVENT_SERVER_DATA);
|
type != ECORE_CON_EVENT_SERVER_DATA);
|
||||||
|
|
||||||
/* Server */
|
/* Server */
|
||||||
if (type == ECORE_CON_EVENT_CLIENT_DATA)
|
if (type == ECORE_CON_EVENT_CLIENT_DATA)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Data *event = ev;
|
Ecore_Con_Event_Client_Data *event = ev;
|
||||||
const char pong[] = "PONG";
|
const char pong[] = "PONG";
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
char fmt[128];
|
char fmt[128];
|
||||||
fail_if (data != (void *) 1);
|
fail_if (data != (void *) 1);
|
||||||
|
|
||||||
snprintf(fmt, sizeof(fmt),
|
snprintf(fmt, sizeof(fmt),
|
||||||
"Received %i bytes from client %s port %d:\n"
|
"Received %i bytes from client %s port %d:\n"
|
||||||
">>>>>\n"
|
">>>>>\n"
|
||||||
"%%.%is\n"
|
"%%.%is\n"
|
||||||
">>>>>\n",
|
">>>>>\n",
|
||||||
event->size, ecore_con_client_ip_get(event->client),
|
event->size, ecore_con_client_ip_get(event->client),
|
||||||
ecore_con_client_port_get(event->client), event->size);
|
ecore_con_client_port_get(event->client), event->size);
|
||||||
|
|
||||||
printf(fmt, event->data);
|
printf(fmt, event->data);
|
||||||
fail_if (event->size != sizeof("PING"));
|
fail_if (event->size != sizeof("PING"));
|
||||||
fail_if (memcmp (event->data, "PING", sizeof("PING")) != 0);
|
fail_if (memcmp (event->data, "PING", sizeof("PING")) != 0);
|
||||||
|
|
||||||
ret = ecore_con_client_send(event->client, pong, sizeof(pong));
|
ret = ecore_con_client_send(event->client, pong, sizeof(pong));
|
||||||
fail_if (ret != sizeof(pong));
|
fail_if (ret != sizeof(pong));
|
||||||
ecore_con_client_flush(event->client);
|
ecore_con_client_flush(event->client);
|
||||||
}
|
}
|
||||||
else if (type == ECORE_CON_EVENT_SERVER_DATA)
|
else if (type == ECORE_CON_EVENT_SERVER_DATA)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Server_Data *event = ev;
|
Ecore_Con_Event_Server_Data *event = ev;
|
||||||
char fmt[128];
|
char fmt[128];
|
||||||
|
|
||||||
fail_if (data != (void *) 2);
|
fail_if (data != (void *) 2);
|
||||||
|
|
||||||
snprintf(fmt, sizeof(fmt),
|
snprintf(fmt, sizeof(fmt),
|
||||||
"Received %i bytes from server:\n"
|
"Received %i bytes from server:\n"
|
||||||
">>>>>\n"
|
">>>>>\n"
|
||||||
"%%.%is\n"
|
"%%.%is\n"
|
||||||
">>>>>\n",
|
">>>>>\n",
|
||||||
event->size, event->size);
|
event->size, event->size);
|
||||||
|
|
||||||
printf(fmt, event->data);
|
printf(fmt, event->data);
|
||||||
fail_if (event->size != sizeof("PONG"));
|
fail_if (event->size != sizeof("PONG"));
|
||||||
fail_if (memcmp (event->data, "PONG", sizeof("PONG")) != 0);
|
fail_if (memcmp (event->data, "PONG", sizeof("PONG")) != 0);
|
||||||
ecore_main_loop_quit();
|
ecore_main_loop_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
@ -195,29 +196,29 @@ void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name,
|
||||||
fail_if(ret != 1);
|
fail_if(ret != 1);
|
||||||
|
|
||||||
handlers[0] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
|
handlers[0] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
|
||||||
_add, (void *) 1);
|
_add, (void *) 1);
|
||||||
fail_if(handlers[0] == NULL);
|
fail_if(handlers[0] == NULL);
|
||||||
handlers[1] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
|
handlers[1] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
|
||||||
_del, (void *) 1);
|
_del, (void *) 1);
|
||||||
fail_if(handlers[1] == NULL);
|
fail_if(handlers[1] == NULL);
|
||||||
handlers[2] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
|
handlers[2] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
|
||||||
_data, (void *) 1);
|
_data, (void *) 1);
|
||||||
fail_if(handlers[2] == NULL);
|
fail_if(handlers[2] == NULL);
|
||||||
|
|
||||||
handlers[3] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
|
handlers[3] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
|
||||||
_add, (void *) 2);
|
_add, (void *) 2);
|
||||||
fail_if(handlers[3] == NULL);
|
fail_if(handlers[3] == NULL);
|
||||||
handlers[4] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
|
handlers[4] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
|
||||||
_del, (void *) 2);
|
_del, (void *) 2);
|
||||||
fail_if(handlers[4] == NULL);
|
fail_if(handlers[4] == NULL);
|
||||||
handlers[5] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
|
handlers[5] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
|
||||||
_data, (void *) 2);
|
_data, (void *) 2);
|
||||||
fail_if(handlers[5] == NULL);
|
fail_if(handlers[5] == NULL);
|
||||||
|
|
||||||
fail_if (ecore_con_server_connected_get(server));
|
fail_if (ecore_con_server_connected_get(server));
|
||||||
|
|
||||||
server = ecore_con_server_add(compl_type, name, server_port,
|
server = ecore_con_server_add(compl_type, name, server_port,
|
||||||
server_data);
|
server_data);
|
||||||
fail_if (server == NULL);
|
fail_if (server == NULL);
|
||||||
|
|
||||||
if (is_ssl)
|
if (is_ssl)
|
||||||
|
@ -244,7 +245,7 @@ void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name,
|
||||||
ecore_con_server_client_limit_set(server, 1, 0);
|
ecore_con_server_client_limit_set(server, 1, 0);
|
||||||
|
|
||||||
client = ecore_con_server_connect(compl_type, name, server_port,
|
client = ecore_con_server_connect(compl_type, name, server_port,
|
||||||
client_data);
|
client_data);
|
||||||
fail_if (client == NULL);
|
fail_if (client == NULL);
|
||||||
|
|
||||||
if (is_ssl)
|
if (is_ssl)
|
||||||
|
@ -263,7 +264,7 @@ void _ecore_con_server_client_tests(Ecore_Con_Type compl_type, const char *name,
|
||||||
eina_list_count(clients));
|
eina_list_count(clients));
|
||||||
EINA_LIST_FOREACH(clients, l, cl)
|
EINA_LIST_FOREACH(clients, l, cl)
|
||||||
{
|
{
|
||||||
printf("%s\n", ecore_con_client_ip_get(cl));
|
printf("%s\n", ecore_con_client_ip_get(cl));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Server was up for %0.3f seconds\n",
|
printf("Server was up for %0.3f seconds\n",
|
||||||
|
@ -331,13 +332,13 @@ START_TEST(ecore_test_ecore_con_local_user_none)
|
||||||
{
|
{
|
||||||
const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
|
const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
|
||||||
const char *homedir = getenv("HOME");
|
const char *homedir = getenv("HOME");
|
||||||
const char *tmp = getenv("TMP");
|
const char *tmp = getenv("TMPDIR");
|
||||||
|
|
||||||
unsetenv("XDG_RUNTIME_DIR");
|
unsetenv("XDG_RUNTIME_DIR");
|
||||||
unsetenv("HOME");
|
unsetenv("HOME");
|
||||||
unsetenv("TMP");
|
unsetenv("TMPDIR");
|
||||||
_ecore_con_server_client_tests(ECORE_CON_LOCAL_USER, "test_sock", EINA_FALSE, 12345);
|
_ecore_con_server_client_tests(ECORE_CON_LOCAL_USER, "test_sock", EINA_FALSE, 12345);
|
||||||
setenv("TMP", tmp, 1);
|
setenv("TMPDIR", tmp, 1);
|
||||||
setenv("HOME", homedir, 1);
|
setenv("HOME", homedir, 1);
|
||||||
setenv("XDG_RUNTIME_DIR", xdg_runtime_dir, 1);
|
setenv("XDG_RUNTIME_DIR", xdg_runtime_dir, 1);
|
||||||
}
|
}
|
||||||
|
@ -531,7 +532,7 @@ START_TEST(ecore_test_ecore_con_shutdown_bef_init)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
void ecore_test_ecore_con(TCase *tc)
|
void ecore_con_test_ecore_con(TCase *tc)
|
||||||
{
|
{
|
||||||
tcase_add_test(tc, ecore_test_ecore_con_init);
|
tcase_add_test(tc, ecore_test_ecore_con_init);
|
||||||
tcase_add_test(tc, ecore_test_ecore_con_local_user);
|
tcase_add_test(tc, ecore_test_ecore_con_local_user);
|
|
@ -2,7 +2,7 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
#include "ecore_con_suite.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
|
@ -318,7 +318,7 @@ START_TEST(ecore_test_ecore_con_url_init)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
void ecore_test_ecore_con_url(TCase *tc)
|
void ecore_con_test_ecore_con_url(TCase *tc)
|
||||||
{
|
{
|
||||||
tcase_add_test(tc, ecore_test_ecore_con_url_init);
|
tcase_add_test(tc, ecore_test_ecore_con_url_init);
|
||||||
tcase_add_test(tc, ecore_test_ecore_con_url_create);
|
tcase_add_test(tc, ecore_test_ecore_con_url_create);
|
Loading…
Reference in New Issue