Efl tests: Major test rework

This is a merge commit of a branch by vtorri to rework all the test
infrastructure.

Closes D3654
This commit is contained in:
Tom Hacohen 2016-02-16 13:09:10 +00:00
commit 475b43f4a9
199 changed files with 4783 additions and 5879 deletions

View File

@ -34,7 +34,8 @@ TESTS += tests/ecore_cxx/ecore_cxx_suite tests/ecore_cxx/cxx_compile_test
tests_ecore_cxx_ecore_cxx_suite_SOURCES = \
tests/ecore_cxx/ecore_cxx_suite.cc \
tests/ecore_cxx/ecore_cxx_test_safe_call.cc
tests/ecore_cxx/ecore_cxx_test_safe_call.cc \
tests/ecore_cxx/ecore_cxx_suite.h
tests_ecore_cxx_ecore_cxx_suite_CPPFLAGS = \
-I$(top_builddir)/src/lib/efl \

View File

@ -62,8 +62,17 @@ check_PROGRAMS += tests/eet/eet_suite
TESTS += tests/eet/eet_suite
tests_eet_eet_suite_SOURCES = \
tests/eet/eet_test_cache.c \
tests/eet/eet_test_cipher.c \
tests/eet/eet_test_common.c \
tests/eet/eet_test_connection.c \
tests/eet/eet_test_data.c \
tests/eet/eet_test_file.c \
tests/eet/eet_test_identity.c \
tests/eet/eet_test_image.c \
tests/eet/eet_test_init.c \
tests/eet/eet_suite.c \
tests/eet/eet_data_suite.c \
tests/eet/eet_test_common.h \
tests/eet/eet_suite.h
tests_eet_eet_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \

View File

@ -19,7 +19,8 @@ TESTS += tests/eet_cxx/eet_cxx_suite
tests_eet_cxx_eet_cxx_suite_SOURCES = \
tests/eet_cxx/eet_cxx_suite.cc \
tests/eet_cxx/eet_cxx_test_descriptors.cc
tests/eet_cxx/eet_cxx_test_descriptors.cc \
tests/eet_cxx/eet_cxx_suite.h
tests_eet_cxx_eet_cxx_suite_CPPFLAGS = \
-I$(top_builddir)/src/lib/efl \

View File

@ -162,7 +162,13 @@ if EFL_ENABLE_TESTS
check_PROGRAMS += tests/eeze/eeze_suite
TESTS += tests/eeze/eeze_suite
tests_eeze_eeze_suite_SOURCES = tests/eeze/eeze_suite.c
tests_eeze_eeze_suite_SOURCES = \
tests/eeze/eeze_suite.c \
tests/eeze/eeze_test_init.c \
tests/eeze/eeze_test_net.c \
tests/eeze/eeze_test_sensor.c \
tests/eeze/eeze_test_udev.c \
tests/eeze/eeze_suite.h
tests_eeze_eeze_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
@EEZE_CFLAGS@ \
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eeze\" \

View File

@ -273,6 +273,7 @@ check_PROGRAMS += tests/eina/eina_suite tests/eina/cxx_compile_test
TESTS += tests/eina/eina_suite
tests_eina_eina_suite_SOURCES = \
tests/efl_check.h \
tests/eina/eina_suite.c \
tests/eina/eina_suite.h \
tests/eina/eina_test_abi.c \

View File

@ -60,7 +60,8 @@ tests/eina_cxx/eina_cxx_test_accessor.cc \
tests/eina_cxx/eina_cxx_test_thread.cc \
tests/eina_cxx/eina_cxx_test_optional.cc \
tests/eina_cxx/eina_cxx_test_value.cc \
tests/eina_cxx/simple.c
tests/eina_cxx/simple.c \
tests/eina_cxx/eina_cxx_suite.h
tests/eina_cxx/tests_eina_cxx_eina_cxx_suite-eina_cxx_test_accessor.$(OBJEXT): tests/eina_cxx/simple.eo.hh tests/eina_cxx/simple.eo.h
tests/eina_cxx/tests_eina_cxx_eina_cxx_suite-eina_cxx_test_ptrarray.$(OBJEXT): tests/eina_cxx/simple.eo.hh tests/eina_cxx/simple.eo.h

View File

@ -48,7 +48,8 @@ TESTS += tests/eldbus_cxx/eldbus_cxx_suite
tests_eldbus_cxx_eldbus_cxx_suite_SOURCES = \
tests/eldbus_cxx/eldbus_cxx_suite.cc \
tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc \
tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc
tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc \
tests/eldbus_cxx/eldbus_cxx_suite.h
tests_eldbus_cxx_eldbus_cxx_suite_CPPFLAGS = \
-I$(top_builddir)/src/bindings/eina_cxx \

View File

@ -81,7 +81,10 @@ check_PROGRAMS += tests/emile/emile_suite
TESTS += tests/emile/emile_suite
tests_emile_emile_suite_SOURCES = \
tests/emile/emile_suite.c
tests/emile/emile_suite.c \
tests/emile/emile_test_base.c \
tests/emile/emile_test_base64.c \
tests/emile/emile_suite.h
tests_emile_emile_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-DTESTS_WD=\"`pwd`\" \

View File

@ -74,7 +74,8 @@ tests/eolian_cxx/eolian_cxx_test_wrapper.cc \
tests/eolian_cxx/simple.c \
tests/eolian_cxx/generic.c \
tests/eolian_cxx/eolian_cxx_test_inheritance.cc \
tests/eolian_cxx/eolian_cxx_test_generate.cc
tests/eolian_cxx/eolian_cxx_test_generate.cc \
tests/eolian_cxx/eolian_cxx_suite.h
tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_wrapper.$(OBJEXT): tests/eolian_cxx/callback.eo.hh tests/eolian_cxx/callback.eo.h
tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_callback.$(OBJEXT): tests/eolian_cxx/callback.eo.hh tests/eolian_cxx/callback.eo.h

View File

@ -2,22 +2,10 @@
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <Ecore.h>
#include "ecore_suite.h"
#include "../efl_check.h"
typedef struct _Ecore_Test_Case Ecore_Test_Case;
struct _Ecore_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static const Ecore_Test_Case etc[] = {
static const Efl_Test_Case etc[] = {
{ "Ecore", ecore_test_ecore },
#if HAVE_ECORE_X
{ "Ecore_X", ecore_test_ecore_x },
@ -41,84 +29,18 @@ static const Ecore_Test_Case etc[] = {
{ NULL, NULL }
};
static void
_list_tests(void)
{
const Ecore_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_suite_build(int argc, const char **argv)
{
TCase *tc;
Suite *s;
int i;
s = suite_create("Ecore");
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;
int 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;
}
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv("EFL_RUN_IN_TREE=1");
s = ecore_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);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Ecore", etc);
return (failed_count == 0) ? 0 : 255;
}

View File

@ -2,10 +2,11 @@
#include <config.h>
#endif
#include <math.h>
#include <Ecore.h>
#include "ecore_suite.h"
#include <math.h>
static double prev = 0;
static Eina_Bool _anim_cb(void *data EINA_UNUSED, double pos)

View File

@ -2,17 +2,15 @@
#include <config.h>
#endif
#include <stdio.h>
#include <math.h>
#include <Ecore.h>
#include <Ecore_Audio.h>
#include <Ecore_File.h>
#include "ecore_suite.h"
#include <stdio.h>
#include <Ecore.h>
#include <Ecore_Audio.h>
static Eina_Bool _failed_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{
Eina_Bool *pulse_context_failed = data;

View File

@ -9,9 +9,9 @@
#include <fcntl.h>
#include <libgen.h>
#include <Ecore_File.h>
#include <Ecore.h>
#include <Eina.h>
#include <Ecore.h>
#include <Ecore_File.h>
#include "ecore_suite.h"

View File

@ -2,10 +2,11 @@
# include <config.h>
#endif
#include <Ecore.h>
#include <Eina.h>
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>
#include <Eina.h>
#include <Ecore.h>
#include "ecore_suite.h"

View File

@ -2,10 +2,10 @@
# include <config.h>
#endif
#include "ecore_suite.h"
#include <Eina.h>
#include "ecore_suite.h"
/* FIXME: Currently disable these tests. They are useless ATM and they just
* make buildbot complain. Once we add useful tests here we'll also bother
* with getting X on the server. */

View File

@ -2,106 +2,28 @@
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "Ecore.h"
#include "ecore_con_suite.h"
#include "../efl_check.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[] = {
static const Efl_Test_Case etc[] = {
{ "Ecore_Con", ecore_con_test_ecore_con },
{ "Ecore_Con_Url", ecore_con_test_ecore_con_url },
{ "Ecore_Con_Eet", ecore_con_test_ecore_con_eet },
{ 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;
int 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;
}
if (!_efl_test_option_disp(argc, argv, etc))
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);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Ecore_Con", etc);
return (failed_count == 0) ? 0 : 255;
}

View File

@ -2,12 +2,13 @@
# include <config.h>
#endif
#include "ecore_con_suite.h"
#include <stdio.h>
#include <Ecore.h>
#include <Ecore_Con.h>
#include "ecore_con_suite.h"
char sdata[] = "Server_info";
char cdata[] = "Client_info";

View File

@ -2,11 +2,11 @@
# include <config.h>
#endif
#include "ecore_con_suite.h"
#include <Eet.h>
#include <Ecore_Con_Eet.h>
#include "ecore_con_suite.h"
#define TEST_STREAM "test_stream"
#define SRV_MSG "Server Message"
#define CLI_MSG "Client Message"

View File

@ -2,13 +2,14 @@
# include <config.h>
#endif
#include "ecore_con_suite.h"
#include <stdio.h>
#include <unistd.h>
#include <Eina.h>
#include <Ecore.h>
#include <Ecore_Con.h>
#include <Eina.h>
#include <unistd.h>
#include "ecore_con_suite.h"
#define COOKIEJAR "testcookieXXXXXX.jar"
#define DEFAULT_LINK "www.google.com"

View File

@ -2,107 +2,26 @@
# include <config.h>
#endif
#include "Ecore.hh"
#include "ecore_cxx_suite.h"
#include "../efl_check.h"
#include <cassert>
#include <algorithm>
#include <check.h>
void ecore_test_safe_call(TCase* tc);
typedef struct _Ecore_Test_Case Ecore_Test_Case;
struct _Ecore_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static const Ecore_Test_Case etc[] = {
{ "Safe_Call", ecore_test_safe_call },
static const Efl_Test_Case etc[] = {
{ "Safe_Call", ecore_cxx_test_safe_call },
{ NULL, NULL }
};
static void
_list_tests(void)
int
main(int argc, char* argv[])
{
const Ecore_Test_Case *itr = etc;
fputs("Available Test Cases:\n", stderr);
for (; itr->test_case; itr++)
fprintf(stderr, "\t%s\n", itr->test_case);
}
int failed_count;
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;
}
Suite *
ecore_build_suite(int argc, const char **argv)
{
TCase *tc;
Suite *s;
int i;
s = suite_create("Ecore");
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);
#ifndef _WIN32
tcase_set_timeout(tc, 0);
#endif
etc[i].build(tc);
suite_add_tcase(s, tc);
}
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;
}
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
s = ecore_build_suite(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);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Ecore C++", etc);
return (failed_count == 0) ? 0 : 255;
}

View File

@ -0,0 +1,11 @@
#ifndef _ECORE_CXX_SUITE_H
#define _ECORE_CXX_SUITE_H
#include <cassert>
#include <algorithm>
#include <check.h>
void ecore_cxx_test_safe_call(TCase* tc);
#endif /* _ECORE_CXX_SUITE_H */

View File

@ -2,14 +2,13 @@
# include <config.h>
#endif
#include "Ecore.hh"
#include "Eina.hh"
#include <algorithm>
#include <iostream>
#include <check.h>
#include <Eina.hh>
#include <Ecore.hh>
#include "ecore_cxx_suite.h"
void call_async(efl::eina::mutex& mutex, efl::eina::condition_variable& cond, int& done)
{
@ -260,7 +259,7 @@ START_TEST(ecore_cxx_safe_call_sync)
END_TEST
void
ecore_test_safe_call(TCase* tc)
ecore_cxx_test_safe_call(TCase* tc)
{
tcase_add_test(tc, ecore_cxx_safe_call_async);
tcase_add_test(tc, ecore_cxx_safe_call_sync);

View File

@ -18,96 +18,28 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#include <stdio.h>
#include <string.h>
#include <check.h>
#include "Eina.h"
#endif
#include "ector_suite.h"
#include "../efl_check.h"
typedef struct _Ector_Test_Case Ector_Test_Case;
struct _Ector_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static const Ector_Test_Case etc[] = {
static const Efl_Test_Case etc[] = {
{ "init", ector_test_init },
{ NULL, NULL }
};
static void
_list_tests(void)
{
const Ector_Test_Case *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;
}
int
main(int argc, char *argv[])
{
TCase *tc;
Suite *s;
SRunner *sr;
int failed_count, i;
int 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;
}
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv("EFL_RUN_IN_TREE=1");
s = suite_create("Ector");
for (i = 0; etc[i].test_case; ++i)
{
if (!_use_test(argc - 1, (const char **) argv + 1, etc[i].test_case))
continue;
tc = tcase_create(etc[i].test_case);
tcase_set_timeout(tc, 0);
etc[i].build(tc);
suite_add_tcase(s, tc);
}
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);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Ector", etc);
return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -20,9 +20,9 @@
# include "config.h"
#endif
#include "ector_suite.h"
#include <Ector.h>
#include "Ector.h"
#include "ector_suite.h"
START_TEST(ector_init_simple)
{

View File

@ -2,106 +2,26 @@
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <Edje.h>
#include "edje_suite.h"
#include "../efl_check.h"
typedef struct _Edje_Test_Case Edje_Test_Case;
struct _Edje_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static const Edje_Test_Case etc[] = {
static const Efl_Test_Case etc[] = {
{ "Edje", edje_test_edje },
{ NULL, NULL }
};
static void
_list_tests(void)
{
const Edje_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 *
edje_suite_build(int argc, const char **argv)
{
TCase *tc;
Suite *s;
int i;
s = suite_create("Edje");
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);
#ifndef _WIN32
tcase_set_timeout(tc, 0);
#endif
}
return s;
}
int
main(int argc, char **argv)
{
Suite *s;
SRunner *sr;
int i, failed_count;
int 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;
}
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv("EFL_RUN_IN_TREE=1");
s = edje_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);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Edje", etc);
return (failed_count == 0) ? 0 : 255;
}

View File

@ -363,7 +363,7 @@ START_TEST(edje_test_color_class)
END_TEST
void edje_test_edje(TCase *tc)
{
{
tcase_add_test(tc, edje_test_edje_init);
tcase_add_test(tc,edje_test_load_simple_layout);
tcase_add_test(tc, edje_test_edje_load);

View File

@ -1,73 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <Eina.h>
#include "eet_suite.h"
static char *
_eet_str_direct_alloc(const char *str)
{
return (char *)str;
} /* _eet_str_direct_alloc */
static void
_eet_str_direct_free(const char *str)
{
/* FIXME: Use attribute unused */
(void)str;
} /* _eet_str_direct_free */
static void
_eet_eina_hash_foreach(void *hash,
Eina_Hash_Foreach cb,
void *fdata)
{
if (hash)
eina_hash_foreach(hash, cb, fdata);
} /* _eet_eina_hash_foreach */
/* Internal wrapper for eina_hash */
static Eina_Hash *
_eet_eina_hash_add(Eina_Hash *hash,
const char *key,
const void *data)
{
if (!hash)
hash = eina_hash_string_superfast_new(NULL);
if (!hash)
return NULL;
eina_hash_add(hash, key, data);
return hash;
} /* _eet_eina_hash_add */
static void
_eet_eina_hash_free(Eina_Hash *hash)
{
if (hash)
eina_hash_free(hash);
} /* _eet_eina_hash_free */
void
eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc)
{
eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
eddc->func.mem_alloc = NULL;
eddc->func.mem_free = NULL;
eddc->func.str_alloc = NULL;
eddc->func.str_free = NULL;
eddc->func.list_next = (void *)eina_list_next;
eddc->func.list_append = (void *)eina_list_append;
eddc->func.list_data = (void *)eina_list_data_get;
eddc->func.list_free = (void *)eina_list_free;
eddc->func.hash_foreach = (void *)_eet_eina_hash_foreach;
eddc->func.hash_add = (void *)_eet_eina_hash_add;
eddc->func.hash_free = (void *)_eet_eina_hash_free;
eddc->func.str_direct_alloc = (void *)_eet_str_direct_alloc;
eddc->func.str_direct_free = (void *)_eet_str_direct_free;
eddc->func.array_alloc = NULL;
eddc->func.array_free = NULL;
} /* eet_test_setup_eddc */

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,15 @@
#ifndef _EET_SUITE_H
# define _EET_SUITE_H
#include "Eet.h"
#include <check.h>
void
eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc);
void eet_test_init(TCase *tc);
void eet_test_data(TCase *tc);
void eet_test_file(TCase *tc);
void eet_test_image(TCase *tc);
void eet_test_identity(TCase *tc);
void eet_test_cipher(TCase *tc);
void eet_test_cache(TCase *tc);
void eet_test_connection(TCase *tc);
#endif /* _EET_SUITE_H */

View File

@ -0,0 +1,105 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <Eina.h>
#include <Eet.h>
#include "eet_suite.h"
#include "eet_test_common.h"
static Eina_Bool open_worker_stop;
static Eina_Condition open_worker_cond;
static Eina_Lock open_worker_mutex;
static void *
_open_close_worker(void *path, Eina_Thread tid EINA_UNUSED)
{
static Eina_Bool first = EINA_TRUE;
while (!open_worker_stop)
{
Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ);
if (ef == NULL)
return "eet_open() failed";
else
{
Eet_Error err_code = eet_close(ef);
if (err_code != EET_ERROR_NONE)
return "eet_close() failed";
}
if (first)
{
eina_lock_take(&open_worker_mutex);
eina_condition_broadcast(&open_worker_cond);
eina_lock_release(&open_worker_mutex);
first = EINA_FALSE;
}
}
return NULL;
}
START_TEST(eet_test_cache_concurrency)
{
char *file;
const char *buffer = "test data";
Eet_File *ef;
void *thread_ret;
unsigned int n;
Eina_Thread thread;
Eina_Bool r;
int tmpfd;
file = strdup("/tmp/eet_suite_testXXXXXX");
eet_init();
eina_threads_init();
eina_lock_new(&open_worker_mutex);
eina_condition_new(&open_worker_cond, &open_worker_mutex);
/* create a file to test with */
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
ef = eet_open(file, EET_FILE_MODE_WRITE);
fail_if(!ef);
fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0));
eina_lock_take(&open_worker_mutex);
/* start a thread that repeatedly opens and closes a file */
open_worker_stop = 0;
r = eina_thread_create(&thread, EINA_THREAD_NORMAL, -1, _open_close_worker, file);
fail_unless(r);
eina_condition_wait(&open_worker_cond);
eina_lock_release(&open_worker_mutex);
/* clear the cache repeatedly in this thread */
for (n = 0; n < 20000; ++n)
{
eet_clearcache();
}
/* join the other thread, and fail if it returned an error message */
open_worker_stop = 1;
thread_ret = eina_thread_join(thread);
fail_unless(thread_ret == NULL, (char const *)thread_ret);
eet_close(ef);
fail_if(unlink(file) != 0);
eina_threads_shutdown();
eet_shutdown();
}
END_TEST
void eet_test_cache(TCase *tc)
{
tcase_add_test(tc, eet_test_cache_concurrency);
}

View File

@ -0,0 +1,72 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <Eina.h>
#include <Eet.h>
#include "eet_suite.h"
#include "eet_test_common.h"
START_TEST(eet_test_cipher_decipher_simple)
{
const char *buffer = "Here is a string of data to save !";
const char *key = "This is a crypto key";
const char *key_bad = "This is another crypto key";
Eet_File *ef;
char *test;
char *file = strdup("/tmp/eet_suite_testXXXXXX");
int size;
int tmpfd;
eet_init();
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
/* Crypt an eet file. */
ef = eet_open(file, EET_FILE_MODE_WRITE);
fail_if(!ef);
fail_if(!eet_write_cipher(ef, "keys/tests", buffer, strlen(buffer) + 1, 0,
key));
eet_close(ef);
/* Decrypt an eet file. */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
test = eet_read_cipher(ef, "keys/tests", &size, key);
fail_if(!test);
fail_if(size != (int)strlen(buffer) + 1);
fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
eet_close(ef);
/* Decrypt an eet file. */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
test = eet_read_cipher(ef, "keys/tests", &size, key_bad);
if (size == (int)strlen(buffer) + 1)
fail_if(memcmp(test, buffer, strlen(buffer) + 1) == 0);
eet_close(ef);
fail_if(unlink(file) != 0);
eet_shutdown();
}
END_TEST
void eet_test_cipher(TCase *tc)
{
tcase_add_test(tc, eet_test_cipher_decipher_simple);
}

View File

@ -0,0 +1,649 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include <Eina.h>
#include <Eet.h>
#include <check.h>
#include "eet_test_common.h"
int i42 = 42;
int i7 = 7;
Eina_Bool _dump_call = EINA_FALSE;
void
append_string(void *data,
const char *str)
{
char **string = data;
int length;
if (!data)
return;
length = *string ? strlen(*string) : 0;
*string = realloc(*string, strlen(str) + length + 1);
fail_unless(*string); // Fail test case if realloc fails.
memcpy((*string) + length, str, strlen(str) + 1);
}
void
append_strbuf_string(void *data, const char *string)
{
Eina_Strbuf *strbuf = data;
eina_strbuf_append(strbuf, string);
}
Eina_Bool
func(EINA_UNUSED const Eina_Hash *hash,
const void *key,
void *data,
void *fdata)
{
int *res = fdata;
if (strcmp(key, EET_TEST_KEY1) != 0
&& strcmp(key, EET_TEST_KEY2) != 0)
*res = 1;
if (eet_test_ex_check(data, 2, _dump_call))
*res = 1;
return EINA_TRUE;
} /* func */
Eina_Bool
func7(EINA_UNUSED const Eina_Hash *hash,
EINA_UNUSED const void *key,
void *data,
void *fdata)
{
int *res = fdata;
int *val;
val = data;
if (!val)
*res = 1;
if (*val != 7)
*res = 1;
return EINA_TRUE;
} /* func7 */
static char *
_eet_str_direct_alloc(const char *str)
{
return (char *)str;
} /* _eet_str_direct_alloc */
static void
_eet_str_direct_free(const char *str)
{
/* FIXME: Use attribute unused */
(void)str;
} /* _eet_str_direct_free */
static void
_eet_eina_hash_foreach(void *hash,
Eina_Hash_Foreach cb,
void *fdata)
{
if (hash)
eina_hash_foreach(hash, cb, fdata);
} /* _eet_eina_hash_foreach */
/* Internal wrapper for eina_hash */
static Eina_Hash *
_eet_eina_hash_add(Eina_Hash *hash,
const char *key,
const void *data)
{
if (!hash)
hash = eina_hash_string_superfast_new(NULL);
if (!hash)
return NULL;
eina_hash_add(hash, key, data);
return hash;
} /* _eet_eina_hash_add */
static void
_eet_eina_hash_free(Eina_Hash *hash)
{
if (hash)
eina_hash_free(hash);
} /* _eet_eina_hash_free */
void
eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc)
{
eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
eddc->func.mem_alloc = NULL;
eddc->func.mem_free = NULL;
eddc->func.str_alloc = NULL;
eddc->func.str_free = NULL;
eddc->func.list_next = (void *)eina_list_next;
eddc->func.list_append = (void *)eina_list_append;
eddc->func.list_data = (void *)eina_list_data_get;
eddc->func.list_free = (void *)eina_list_free;
eddc->func.hash_foreach = (void *)_eet_eina_hash_foreach;
eddc->func.hash_add = (void *)_eet_eina_hash_add;
eddc->func.hash_free = (void *)_eet_eina_hash_free;
eddc->func.str_direct_alloc = (void *)_eet_str_direct_alloc;
eddc->func.str_direct_free = (void *)_eet_str_direct_free;
eddc->func.array_alloc = NULL;
eddc->func.array_free = NULL;
}
void
eet_build_basic_descriptor(Eet_Data_Descriptor *edd)
{
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"c",
c,
EET_T_CHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"s",
s,
EET_T_SHORT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"i",
i,
EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"l",
l,
EET_T_LONG_LONG);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"str",
str,
EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"istr",
istr,
EET_T_INLINED_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"f1",
f1,
EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"f2",
f2,
EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"d",
d,
EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"uc",
uc,
EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"us",
us,
EET_T_USHORT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"ui",
ui,
EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"ul",
ul,
EET_T_ULONG_LONG);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Basic_Type,
"vp",
vp,
EET_T_VALUE);
EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "empty", empty, edd);
EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "with", with, edd);
}
void
eet_test_basic_check(Eet_Test_Basic_Type *result,
int i,
Eina_Bool dumper)
{
int test = -1;
float tmp;
fail_if(result->c != EET_TEST_CHAR);
fail_if(result->s != EET_TEST_SHORT);
fail_if(result->i != EET_TEST_INT + i);
fail_if(result->l != (long long)EET_TEST_LONG_LONG);
fail_if(strcmp(result->str, EET_TEST_STRING) != 0);
fail_if(strcmp(result->istr, EET_TEST_STRING) != 0);
fail_if(result->uc != EET_TEST_CHAR);
fail_if(result->us != EET_TEST_SHORT);
fail_if(result->ui != EET_TEST_INT);
fail_if(result->ul != EET_TEST_LONG_LONG);
if (!dumper)
{
fail_if(result->vp == NULL);
eina_value_get(result->vp, &test);
fail_if(test != EET_TEST_INT + i);
}
else
{
fail_if(result->vp != NULL);
}
tmp = (result->f1 + EET_TEST_FLOAT);
if (tmp < 0)
tmp = -tmp;
fail_if(tmp > 0.005);
tmp = (result->f2 - EET_TEST_FLOAT4);
if (tmp < 0)
tmp = -tmp;
fail_if(tmp > 0.005);
tmp = (result->d + EET_TEST_DOUBLE);
if (tmp < 0)
tmp = -tmp;
fail_if(tmp > 0.00005);
fail_if(result->empty != NULL);
if (i == 0)
{
Eet_Test_Basic_Type *tmp2;
tmp2 = result->with;
fail_if(tmp2 == NULL);
fail_if(tmp2->c != EET_TEST_CHAR);
fail_if(tmp2->s != EET_TEST_SHORT);
fail_if(tmp2->i != EET_TEST_INT + i + 1);
fail_if(tmp2->l != (long long)EET_TEST_LONG_LONG);
fail_if(strcmp(tmp2->str, EET_TEST_STRING) != 0);
fail_if(strcmp(tmp2->istr, EET_TEST_STRING) != 0);
fail_if(tmp2->uc != EET_TEST_CHAR);
fail_if(tmp2->us != EET_TEST_SHORT);
fail_if(tmp2->ui != EET_TEST_INT);
fail_if(tmp2->ul != EET_TEST_LONG_LONG);
fail_if(tmp2->vp != NULL);
}
else
fail_if(result->with != NULL);
}
void
eet_build_ex_descriptor(Eet_Data_Descriptor *edd, Eina_Bool stream)
{
Eet_Data_Descriptor_Class eddc;
Eet_Test_Ex_Type etbt;
Eet_Data_Descriptor *eddb;
if (stream)
{
eet_eina_stream_data_descriptor_class_set(&eddc,
sizeof (Eet_Data_Descriptor_Class),
"Eet_Test_Basic_Type",
sizeof(Eet_Test_Basic_Type));
eddb = eet_data_descriptor_stream_new(&eddc);
}
else
{
eet_eina_file_data_descriptor_class_set(&eddc,
sizeof (Eet_Data_Descriptor_Class),
"Eet_Test_Basic_Type",
sizeof(Eet_Test_Basic_Type));
eddb = eet_data_descriptor_file_new(&eddc);
}
fail_if(!eddb);
eet_build_basic_descriptor(eddb);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"c",
c,
EET_T_CHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"s",
s,
EET_T_SHORT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Eet_Test_Ex_Type, "i", i, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"l",
l,
EET_T_LONG_LONG);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"str",
str,
EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"istr",
istr,
EET_T_INLINED_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"f1",
f1,
EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"f2",
f2,
EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"f3",
f3,
EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"f4",
f4,
EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"d1",
d1,
EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"d2",
d2,
EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"d3",
d3,
EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"d4",
d4,
EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"uc",
uc,
EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"us",
us,
EET_T_USHORT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"ui",
ui,
EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
Eet_Test_Ex_Type,
"ul",
ul,
EET_T_ULONG_LONG);
EET_DATA_DESCRIPTOR_ADD_ARRAY(edd,
Eet_Test_Ex_Type,
"sarray1",
sarray1,
eddb);
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd,
Eet_Test_Ex_Type,
"varray2",
varray2,
eddb);
eet_data_descriptor_element_add(edd,
"varray1",
EET_T_INT,
EET_G_VAR_ARRAY,
(char *)(&(etbt.varray1)) - (char *)(&(etbt)),
(char *)(&(etbt.varray1_count)) -
(char *)(&(etbt)),
/* 0, */ NULL,
NULL);
eet_data_descriptor_element_add(edd, "sarray2", EET_T_INT, EET_G_ARRAY,
(char *)(&(etbt.sarray2)) - (char *)(&(etbt)),
/* 0, */ sizeof(etbt.sarray2) /
sizeof(etbt.sarray2[0]), NULL, NULL);
eet_data_descriptor_element_add(edd, "charray", EET_T_STRING, EET_G_ARRAY,
(char *)(&(etbt.charray)) - (char *)(&(etbt)),
/* 0, */ sizeof(etbt.charray) /
sizeof(etbt.charray[0]), NULL, NULL);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Eet_Test_Ex_Type, "list", list, edd);
EET_DATA_DESCRIPTOR_ADD_HASH(edd, Eet_Test_Ex_Type, "hash", hash, edd);
eet_data_descriptor_element_add(edd, "ilist", EET_T_INT, EET_G_LIST,
(char *)(&(etbt.ilist)) - (char *)(&(etbt)),
0, /* 0, */ NULL, NULL);
eet_data_descriptor_element_add(edd, "ihash", EET_T_INT, EET_G_HASH,
(char *)(&(etbt.ihash)) - (char *)(&(etbt)),
0, /* 0, */ NULL, NULL);
eet_data_descriptor_element_add(edd, "slist", EET_T_STRING, EET_G_LIST,
(char *)(&(etbt.slist)) - (char *)(&(etbt)),
0, /* 0, */ NULL, NULL);
eet_data_descriptor_element_add(edd, "shash", EET_T_STRING, EET_G_HASH,
(char *)(&(etbt.shash)) - (char *)(&(etbt)),
0, /* 0, */ NULL, NULL);
}
Eet_Test_Ex_Type *
eet_test_ex_set(Eet_Test_Ex_Type *res,
int offset)
{
unsigned int i;
if (!res)
res = malloc(sizeof(Eet_Test_Ex_Type));
if (!res)
return NULL;
res->c = EET_TEST_CHAR + offset;
res->s = EET_TEST_SHORT + offset;
res->i = EET_TEST_INT + offset;
res->l = EET_TEST_LONG_LONG + offset;
res->str = EET_TEST_STRING;
res->istr = EET_TEST_STRING;
res->f1 = EET_TEST_FLOAT + offset;
res->f2 = -(EET_TEST_FLOAT2 + offset);
res->f3 = EET_TEST_FLOAT3 + offset;
res->f4 = EET_TEST_FLOAT2 + offset;
res->d1 = EET_TEST_DOUBLE + offset;
res->d2 = -(EET_TEST_DOUBLE2 + offset);
res->d3 = EET_TEST_DOUBLE3 + offset;
res->d4 = EET_TEST_DOUBLE2 + offset;
res->list = NULL;
res->hash = NULL;
res->ilist = NULL;
res->ihash = NULL;
res->slist = NULL;
res->shash = NULL;
for (i = 0; i < sizeof(res->charray) / sizeof(res->charray[0]); ++i)
res->charray[i] = NULL;
res->varray2 = malloc(sizeof (Eet_Test_Basic_Type) * 10);
res->varray1 = malloc(sizeof (int) * 5);
fail_if(!res->varray1 || !res->varray2);
for (i = 0; i < 10; ++i)
{
eet_test_basic_set(res->sarray1 + i, i);
eet_test_basic_set(res->varray2 + i, i);
}
res->varray2_count = 10;
for (i = 0; i < 5; ++i)
{
res->sarray2[i] = i * 42 + 1;
res->varray1[i] = i * 42 + 1;
}
res->varray1_count = 5;
res->uc = EET_TEST_CHAR + offset;
res->us = EET_TEST_SHORT + offset;
res->ui = EET_TEST_INT + offset;
res->ul = EET_TEST_LONG_LONG + offset;
return res;
}
int
eet_test_ex_check(Eet_Test_Ex_Type *stuff,
int offset,
Eina_Bool dumper)
{
double tmp;
unsigned int i;
if (!stuff)
return 1;
if (stuff->c != EET_TEST_CHAR + offset)
return 1;
if (stuff->s != EET_TEST_SHORT + offset)
return 1;
if (stuff->i != EET_TEST_INT + offset)
return 1;
if (stuff->l != EET_TEST_LONG_LONG + offset)
return 1;
if (strcmp(stuff->str, EET_TEST_STRING) != 0)
return 1;
if (strcmp(stuff->istr, EET_TEST_STRING) != 0)
return 1;
tmp = stuff->f1 - (EET_TEST_FLOAT + offset);
if (tmp < 0)
tmp = -tmp;
if (tmp > 0.005)
return 1;
tmp = stuff->d1 - (EET_TEST_DOUBLE + offset);
if (tmp < 0)
tmp = -tmp;
if (tmp > 0.00005)
return 1;
if (stuff->f2 != -(EET_TEST_FLOAT2 + offset))
return 1;
if (stuff->d2 != -(EET_TEST_DOUBLE2 + offset))
return 1;
if (stuff->f3 != EET_TEST_FLOAT3 + offset)
return 1;
if (stuff->d3 != EET_TEST_DOUBLE3 + offset)
return 1;
if (stuff->f4 != EET_TEST_FLOAT2 + offset)
return 1;
if (stuff->d4 != EET_TEST_DOUBLE2 + offset)
return 1;
if (stuff->uc != EET_TEST_CHAR + offset)
return 1;
if (stuff->us != EET_TEST_SHORT + offset)
return 1;
if (stuff->ui != (unsigned int)EET_TEST_INT + offset)
return 1;
if (stuff->ul != EET_TEST_LONG_LONG + offset)
return 1;
if (stuff->varray1_count != 5)
return 1;
if (stuff->varray2_count != 10)
return 1;
for (i = 0; i < 5; ++i)
if (stuff->sarray2[i] != i * 42 + 1 && stuff->varray1[i] != i * 42 + 1)
return 1;
for (i = 0; i < 10; ++i)
{
eet_test_basic_check(stuff->sarray1 + i, i, dumper);
eet_test_basic_check(stuff->varray2 + i, i, dumper);
}
return 0;
}
void
eet_test_basic_set(Eet_Test_Basic_Type *res,
int i)
{
res->c = EET_TEST_CHAR;
res->s = EET_TEST_SHORT;
res->i = EET_TEST_INT + i;
res->l = EET_TEST_LONG_LONG;
res->str = EET_TEST_STRING;
res->istr = EET_TEST_STRING;
res->f1 = -EET_TEST_FLOAT;
res->d = -EET_TEST_DOUBLE;
res->f2 = EET_TEST_FLOAT4;
res->uc = EET_TEST_CHAR;
res->us = EET_TEST_SHORT;
res->ui = EET_TEST_INT;
res->ul = EET_TEST_LONG_LONG;
res->empty = NULL;
res->with = NULL;
res->vp = eina_value_new(EINA_VALUE_TYPE_INT);
eina_value_set(res->vp, EET_TEST_INT + i);
if (i == 0)
{
Eet_Test_Basic_Type *tmp;
tmp = malloc(sizeof (Eet_Test_Basic_Type));
fail_if(!tmp);
res->with = tmp;
tmp->c = EET_TEST_CHAR;
tmp->s = EET_TEST_SHORT;
tmp->i = EET_TEST_INT + i + 1;
tmp->l = EET_TEST_LONG_LONG;
tmp->str = EET_TEST_STRING;
tmp->istr = EET_TEST_STRING;
tmp->f1 = -EET_TEST_FLOAT;
tmp->d = -EET_TEST_DOUBLE;
tmp->f2 = EET_TEST_FLOAT4;
tmp->uc = EET_TEST_CHAR;
tmp->us = EET_TEST_SHORT;
tmp->ui = EET_TEST_INT;
tmp->ul = EET_TEST_LONG_LONG;
tmp->empty = NULL;
tmp->with = NULL;
tmp->vp = NULL;
}
}

View File

@ -0,0 +1,139 @@
#ifndef EET_TEST_COMMON_H
#define EET_TEST_COMMON_H
#define EET_TEST_CHAR 0x42
#define EET_TEST_SHORT 0x4224
#define EET_TEST_INT 0x42211224
#define EET_TEST_LONG_LONG 0x84CB42211224BC48
#define EET_TEST_STRING "my little test with escape \\\""
#define EET_TEST_KEY1 "key1"
#define EET_TEST_KEY2 "key2"
#define EET_TEST_FLOAT 123.45689
#define EET_TEST_FLOAT2 1.0
#define EET_TEST_FLOAT3 0.25
#define EET_TEST_FLOAT4 0.0001234
#define EET_TEST_DOUBLE 123456789.9876543210
#define EET_TEST_DOUBLE2 1.0
#define EET_TEST_DOUBLE3 0.25
#define EET_TEST_FILE_KEY1 "keys/data/1"
#define EET_TEST_FILE_KEY2 "keys/data/2"
#define EET_TEST_FILE_IMAGE "keys/images/"
typedef struct _Eet_Test_Basic_Type Eet_Test_Basic_Type;
struct _Eet_Test_Basic_Type
{
char c;
short s;
int i;
long long l;
char *str;
char *istr;
float f1;
float f2;
double d;
unsigned char uc;
unsigned short us;
unsigned int ui;
unsigned long long ul;
Eina_Value *vp;
Eet_Test_Basic_Type *empty;
Eet_Test_Basic_Type *with;
};
typedef struct _Eet_Test_Ex_Type Eet_Test_Ex_Type;
struct _Eet_Test_Ex_Type
{
char c;
short s;
int i;
unsigned long long l;
char *str;
char *istr;
float f1;
float f2;
float f3;
float f4;
double d1;
double d2;
double d3;
double d4;
Eina_List *list;
Eina_Hash *hash;
Eina_List *ilist;
Eina_List *slist;
Eina_Hash *ihash;
Eina_Hash *shash;
Eet_Test_Basic_Type sarray1[10];
unsigned int sarray2[5];
unsigned int varray1_count;
unsigned int *varray1;
unsigned int varray2_count;
Eet_Test_Basic_Type *varray2;
unsigned char uc;
unsigned short us;
unsigned int ui;
unsigned long long ul;
char *charray[10];
};
typedef struct _Eet_5FP Eet_5FP;
struct _Eet_5FP
{
Eina_F32p32 fp32;
Eina_F16p16 fp16;
Eina_F8p24 fp8;
Eina_F32p32 f1;
Eina_F32p32 f0;
};
typedef struct _Eet_5DBL Eet_5DBL;
struct _Eet_5DBL
{
double fp32;
double fp16;
float fp8;
double f1;
double f0;
};
extern char argv0[PATH_MAX];
extern int i42;
extern int i7;
extern Eina_Bool _dump_call;
void append_string(void *data,
const char *str);
void append_strbuf_string(void *data, const char *string);
Eina_Bool func(EINA_UNUSED const Eina_Hash *hash,
const void *key,
void *data,
void *fdata);
Eina_Bool func7(EINA_UNUSED const Eina_Hash *hash,
EINA_UNUSED const void *key,
void *data,
void *fdata);
void eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc);
void eet_build_basic_descriptor(Eet_Data_Descriptor *edd);
void eet_test_basic_check(Eet_Test_Basic_Type *result,
int i,
Eina_Bool dumper);
void eet_build_ex_descriptor(Eet_Data_Descriptor *edd, Eina_Bool stream);
Eet_Test_Ex_Type *eet_test_ex_set(Eet_Test_Ex_Type *res,
int offset);
int eet_test_ex_check(Eet_Test_Ex_Type *stuff,
int offset,
Eina_Bool dumper);
void eet_test_basic_set(Eet_Test_Basic_Type *res,
int i);
#endif

View File

@ -0,0 +1,150 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Eina.h>
#include <Eet.h>
#include "eet_suite.h"
#include "eet_test_common.h"
typedef struct _Eet_Connection_Data Eet_Connection_Data;
struct _Eet_Connection_Data
{
Eet_Connection *conn;
Eet_Data_Descriptor *edd;
Eina_Bool test;
};
static Eina_Bool
_eet_connection_read(const void *eet_data,
size_t size,
void *user_data)
{
Eet_Connection_Data *dt = user_data;
Eet_Test_Ex_Type *result;
Eet_Node *node;
int test;
result = eet_data_descriptor_decode(dt->edd, eet_data, size);
node = eet_data_node_decode_cipher(eet_data, NULL, size);
/* Test the resulting data. */
fail_if(!node);
fail_if(eet_test_ex_check(result, 0, _dump_call) != 0);
fail_if(eet_test_ex_check(eina_list_data_get(result->list), 1, _dump_call) != 0);
fail_if(eina_list_data_get(result->ilist) == NULL);
fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
fail_if(eina_list_data_get(result->slist) == NULL);
fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
fail_if(strcmp(result->charray[0], "test") != 0);
test = 0;
if (result->hash)
eina_hash_foreach(result->hash, func, &test);
fail_if(test != 0);
if (result->ihash)
eina_hash_foreach(result->ihash, func7, &test);
fail_if(test != 0);
if (!dt->test)
{
dt->test = EINA_TRUE;
_dump_call = EINA_TRUE;
fail_if(!eet_connection_node_send(dt->conn, node, NULL));
_dump_call = EINA_FALSE;
}
return EINA_TRUE;
}
static Eina_Bool
_eet_connection_write(const void *data,
size_t size,
void *user_data)
{
Eet_Connection_Data *dt = user_data;
int still;
if (!dt->test)
{
int step = size / 3;
eet_connection_received(dt->conn, data, step);
eet_connection_received(dt->conn, (char *)data + step, step);
size -= 2 * step;
still = eet_connection_received(dt->conn, (char *)data + 2 * step, size);
}
else
still = eet_connection_received(dt->conn, data, size);
fail_if(still);
return EINA_TRUE;
}
START_TEST(eet_test_connection_check)
{
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
Eet_Connection_Data ecd;
Eet_Test_Ex_Type etbt;
Eina_Bool on_going;
eet_init();
eet_test_ex_set(&etbt, 0);
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.hash, EET_TEST_KEY1, eet_test_ex_set(NULL, 2));
eina_hash_add(etbt.hash, EET_TEST_KEY2, eet_test_ex_set(NULL, 2));
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ihash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
etbt.slist = eina_list_prepend(NULL, "test");
etbt.shash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
memset(&etbt.charray, 0, sizeof(etbt.charray));
etbt.charray[0] = "test";
eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc),
"Eet_Test_Ex_Type",
sizeof(Eet_Test_Ex_Type));
edd = eet_data_descriptor_stream_new(&eddc);
fail_if(!edd);
eet_build_ex_descriptor(edd, EINA_TRUE);
/* Init context. */
ecd.test = EINA_FALSE;
ecd.edd = edd;
/* Create a connection. */
ecd.conn = eet_connection_new(_eet_connection_read, _eet_connection_write, &ecd);
fail_if(!ecd.conn);
/* Test the connection. */
fail_if(!eet_connection_send(ecd.conn, edd, &etbt, NULL));
fail_if(!ecd.test);
fail_if(!eet_connection_close(ecd.conn, &on_going));
fail_if(on_going);
eet_shutdown();
}
END_TEST
void eet_test_connection(TCase *tc)
{
tcase_add_test(tc, eet_test_connection_check);
}

View File

@ -0,0 +1,764 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Eina.h>
#include <Eet.h>
#include "eet_suite.h"
#include "eet_test_common.h"
typedef struct _Eet_Union_Test Eet_Union_Test;
typedef struct _Eet_Variant_Test Eet_Variant_Test;
typedef struct _Eet_Variant_Type Eet_Variant_Type;
typedef struct _Eet_Inherit_Test1 Eet_Inherit_Test1;
typedef struct _Eet_Inherit_Test2 Eet_Inherit_Test2;
typedef struct _Eet_Inherit_Test3 Eet_Inherit_Test3;
typedef struct _Eet_St1 Eet_St1;
typedef struct _Eet_St2 Eet_St2;
typedef struct _Eet_St3 Eet_St3;
typedef struct _Eet_List Eet_List;
typedef enum _Eet_Union
{
EET_UNKNOWN,
EET_ST1,
EET_ST2,
EET_ST3
} Eet_Union;
struct
{
Eet_Union u;
const char *name;
} eet_mapping[] = {
{ EET_ST1, "ST1" },
{ EET_ST2, "ST2" },
{ EET_ST3, "ST3" },
{ EET_UNKNOWN, NULL }
};
struct _Eet_St1
{
double val1;
int stuff;
char *s1;
};
struct _Eet_St2
{
Eina_Bool b1;
unsigned long long v1;
};
struct _Eet_St3
{
int boby;
};
struct _Eet_Union_Test
{
Eet_Union type;
union {
Eet_St1 st1;
Eet_St2 st2;
Eet_St3 st3;
} u;
};
struct _Eet_Variant_Type
{
const char *type;
Eina_Bool unknow : 1;
};
struct _Eet_Variant_Test
{
Eet_Variant_Type t;
void *data;
Eina_List *data_list;
};
struct _Eet_Inherit_Test1
{
Eet_Union type;
Eet_St1 st1;
};
struct _Eet_Inherit_Test2
{
Eet_Union type;
Eet_St2 st2;
};
struct _Eet_Inherit_Test3
{
Eet_Union type;
Eet_St3 st3;
};
struct _Eet_List
{
Eina_List *list;
};
static const char *
_eet_union_type_get(const void *data,
Eina_Bool *unknow)
{
const Eet_Union *u = data;
int i;
if (unknow)
*unknow = EINA_FALSE;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (*u == eet_mapping[i].u)
return eet_mapping[i].name;
if (unknow)
*unknow = EINA_TRUE;
return NULL;
} /* _eet_union_type_get */
static Eina_Bool
_eet_union_type_set(const char *type,
void *data,
Eina_Bool unknow)
{
Eet_Union *u = data;
int i;
if (unknow)
return EINA_FALSE;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (strcmp(eet_mapping[i].name, type) == 0)
{
*u = eet_mapping[i].u;
return EINA_TRUE;
}
return EINA_FALSE;
} /* _eet_union_type_set */
static const char *
_eet_variant_type_get(const void *data,
Eina_Bool *unknow)
{
const Eet_Variant_Type *type = data;
int i;
if (unknow)
*unknow = type->unknow;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (strcmp(type->type, eet_mapping[i].name) == 0)
return eet_mapping[i].name;
if (unknow)
*unknow = EINA_FALSE;
return type->type;
} /* _eet_variant_type_get */
static Eina_Bool
_eet_variant_type_set(const char *type,
void *data,
Eina_Bool unknow)
{
Eet_Variant_Type *vt = data;
vt->type = type;
vt->unknow = unknow;
return EINA_TRUE;
} /* _eet_variant_type_set */
static Eet_Data_Descriptor *
_eet_st1_dd(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *res;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_St1);
res = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St1, "val1", val1, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St1, "stuff", stuff, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St1, "s1", s1, EET_T_STRING);
return res;
} /* _eet_st1_dd */
static void
_eet_st1_set(Eet_St1 *st1,
int i)
{
st1->val1 = EET_TEST_DOUBLE;
st1->stuff = EET_TEST_INT + i;
st1->s1 = EET_TEST_STRING;
} /* _eet_st1_set */
static void
_eet_st1_cmp(Eet_St1 *st1,
int i)
{
double tmp;
fail_if(!st1);
tmp = st1->val1 - EET_TEST_DOUBLE;
if (tmp < 0)
tmp = -tmp;
fail_if(tmp > 0.005);
fail_if(st1->stuff != EET_TEST_INT + i);
fail_if(strcmp(st1->s1, EET_TEST_STRING));
} /* _eet_st1_cmp */
static Eet_Data_Descriptor *
_eet_st2_dd(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *res;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_St2);
res = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St2, "b1", b1, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St2, "v1", v1, EET_T_ULONG_LONG);
return res;
} /* _eet_st2_dd */
static void
_eet_st2_set(Eet_St2 *st2,
int i)
{
st2->b1 = EINA_TRUE;
st2->v1 = EET_TEST_LONG_LONG + i;
} /* _eet_st2_set */
static void
_eet_st2_cmp(Eet_St2 *st2,
int i)
{
fail_if(!st2->b1);
fail_if(st2->v1 != EET_TEST_LONG_LONG + i);
} /* _eet_st2_cmp */
static Eet_Data_Descriptor *
_eet_st3_dd(void)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *res;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_St3);
res = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St3, "boby", boby, EET_T_INT);
return res;
} /* _eet_st3_dd */
static void
_eet_st3_set(Eet_St3 *st3,
int i)
{
st3->boby = EET_TEST_INT + i;
} /* _eet_st3_set */
static void
_eet_st3_cmp(Eet_St3 *st3,
int i)
{
fail_if(st3->boby != EET_TEST_INT + i);
} /* _eet_st3_cmp */
START_TEST(eet_test_data_basic_type_encoding_decoding)
{
Eet_Data_Descriptor *edd;
Eet_Test_Basic_Type *result;
Eet_Data_Descriptor_Class eddc;
Eet_Test_Basic_Type etbt;
void *transfert;
int size;
eet_init();
eet_test_basic_set(&etbt, 0);
eet_test_setup_eddc(&eddc);
eddc.name = "Eet_Test_Basic_Type";
eddc.size = sizeof(Eet_Test_Basic_Type);
edd = eet_data_descriptor_stream_new(&eddc);
fail_if(!edd);
eet_build_basic_descriptor(edd);
transfert = eet_data_descriptor_encode(edd, &etbt, &size);
fail_if(!transfert || size <= 0);
result = eet_data_descriptor_decode(edd, transfert, size);
fail_if(!result);
eet_test_basic_check(result, 0, EINA_FALSE);
free(result->str);
free(result);
eet_data_descriptor_free(edd);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_data_type_encoding_decoding)
{
Eet_Data_Descriptor *edd;
Eet_Test_Ex_Type *result;
void *transfert;
Eet_Data_Descriptor_Class eddc;
Eet_Test_Ex_Type etbt;
int size;
int test;
eet_init();
eet_test_ex_set(&etbt, 0);
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.hash, EET_TEST_KEY1, eet_test_ex_set(NULL, 2));
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ihash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
etbt.slist = eina_list_prepend(NULL, "test");
etbt.shash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
memset(&etbt.charray, 0, sizeof(etbt.charray));
etbt.charray[0] = "test";
etbt.charray[5] = "plouf";
eet_test_setup_eddc(&eddc);
eddc.name = "Eet_Test_Ex_Type";
eddc.size = sizeof(Eet_Test_Ex_Type);
edd = eet_data_descriptor_file_new(&eddc);
fail_if(!edd);
eet_build_ex_descriptor(edd, EINA_FALSE);
transfert = eet_data_descriptor_encode(edd, &etbt, &size);
fail_if(!transfert || size <= 0);
result = eet_data_descriptor_decode(edd, transfert, size);
fail_if(!result);
fail_if(eet_test_ex_check(result, 0, EINA_FALSE) != 0);
fail_if(eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_FALSE) != 0);
fail_if(eina_list_data_get(result->ilist) == NULL);
fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
fail_if(eina_list_data_get(result->slist) == NULL);
fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
fail_if(strcmp(result->charray[0], "test") != 0);
fail_if(strcmp(result->charray[5], "plouf") != 0);
test = 0;
if (result->hash)
eina_hash_foreach(result->hash, func, &test);
fail_if(test != 0);
if (result->ihash)
eina_hash_foreach(result->ihash, func7, &test);
fail_if(test != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_data_type_dump_undump)
{
Eet_Data_Descriptor *edd;
Eet_Test_Ex_Type *result;
Eet_Data_Descriptor_Class eddc;
Eet_Test_Ex_Type etbt;
char *transfert1;
char *transfert2;
char *string1;
char *string2;
int size1;
int size2;
int test;
eet_init();
eet_test_ex_set(&etbt, 0);
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.hash, EET_TEST_KEY1, eet_test_ex_set(NULL, 2));
etbt.hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.hash, EET_TEST_KEY2, eet_test_ex_set(NULL, 2));
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ihash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
etbt.ihash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
etbt.slist = eina_list_prepend(NULL, "test");
etbt.shash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
memset(&etbt.charray, 0, sizeof(etbt.charray));
etbt.charray[0] = "test";
eet_test_setup_eddc(&eddc);
eddc.name = "Eet_Test_Ex_Type";
eddc.size = sizeof(Eet_Test_Ex_Type);
edd = eet_data_descriptor_file_new(&eddc);
fail_if(!edd);
eet_build_ex_descriptor(edd, EINA_FALSE);
transfert1 = eet_data_descriptor_encode(edd, &etbt, &size1);
fail_if(!transfert1 || size1 <= 0);
string1 = NULL;
eet_data_text_dump(transfert1, size1, append_string, &string1);
fail_if(!string1);
transfert2 = eet_data_text_undump(string1, string1 ? strlen(
string1) : 0, &size2);
fail_if(!transfert2 && size2 <= 0);
string2 = NULL;
eet_data_text_dump(transfert2, size2, append_string, &string2);
fail_if(!string2);
fail_if(strlen(string2) != strlen(string1));
result = eet_data_descriptor_decode(edd, transfert2, size2);
fail_if(!result);
fail_if(eet_test_ex_check(result, 0, EINA_TRUE) != 0);
fail_if(eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_TRUE) != 0);
fail_if(eina_list_data_get(result->ilist) == NULL);
fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
fail_if(eina_list_data_get(result->slist) == NULL);
fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
fail_if(strcmp(result->charray[0], "test") != 0);
test = 0;
_dump_call = EINA_TRUE;
if (result->hash)
eina_hash_foreach(result->hash, func, &test);
_dump_call = EINA_FALSE;
fail_if(test != 0);
if (result->ihash)
eina_hash_foreach(result->ihash, func7, &test);
fail_if(test != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_data_type_escape_dump_undump)
{
void *blob;
int blob_len;
int ret = 0;
const char *outputstr;
Eina_Strbuf *strbuf;
const char inputstr[] = ""
"group \"\\\\My\\\"Group\\\\\" struct {\n"
" value \"\\\\My\\\\BackSlash\\\\\" string: \"\\\\\";\n"
" value \"\\\\My\\\\DoubleQuote\\\\\" string: \"\\\"\";\n"
" value \"\\\\My\\\\NewLine\\\\\" string: \"\\n\";\n"
"}\n";
eet_init();
blob = eet_data_text_undump(inputstr, strlen(inputstr), &blob_len);
fail_if(!blob);
strbuf = eina_strbuf_new();
ret = eet_data_text_dump(blob, blob_len, append_strbuf_string, strbuf);
ck_assert_int_eq(ret, 1);
outputstr = eina_strbuf_string_get(strbuf);
fail_if(!outputstr);
ck_assert_str_eq(inputstr, outputstr);
eina_strbuf_free(strbuf);
free(blob);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_data_fp)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *edd_5FP;
Eet_Data_Descriptor *edd_5DBL;
Eet_5FP origin;
Eet_5DBL *convert;
Eet_5FP *build;
void *blob;
int size;
eet_init();
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_5FP);
edd_5FP = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp32", fp32, EET_T_F32P32);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp16", fp16, EET_T_F16P16);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp8", fp8, EET_T_F8P24);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f1", f1, EET_T_F32P32);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f0", f0, EET_T_F32P32);
eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "Eet_5FP", sizeof (Eet_5DBL));
edd_5DBL = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp32", fp32, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp16", fp16, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp8", fp8, EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f1", f1, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f0", f0, EET_T_DOUBLE);
origin.fp32 = eina_f32p32_double_from(1.125);
origin.fp16 = eina_f16p16_int_from(2000);
origin.fp8 = eina_f8p24_int_from(125);
origin.f1 = eina_f32p32_int_from(1);
origin.f0 = 0;
blob = eet_data_descriptor_encode(edd_5FP, &origin, &size);
fail_if(!blob || size <= 0);
build = eet_data_descriptor_decode(edd_5FP, blob, size);
fail_if(!build);
convert = eet_data_descriptor_decode(edd_5DBL, blob, size);
fail_if(!convert);
fail_if(build->fp32 != eina_f32p32_double_from(1.125));
fail_if(build->fp16 != eina_f16p16_int_from(2000));
fail_if(build->fp8 != eina_f8p24_int_from(125));
fail_if(build->f1 != eina_f32p32_int_from(1));
fail_if(build->f0 != 0);
fail_if(convert->fp32 != 1.125);
fail_if(convert->fp16 != 2000);
fail_if(convert->fp8 != 125);
fail_if(convert->f1 != 1);
fail_if(convert->f0 != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_data_union)
{
Eet_Union_Test *eut;
Eet_List *l;
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor *unified;
Eet_Data_Descriptor *m;
void *blob;
int size;
int i;
eina_init();
eet_init();
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Union_Test);
edd = eet_data_descriptor_stream_new(&eddc);
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Union_Test);
m = eet_data_descriptor_stream_new(&eddc);
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
eddc.func.type_get = _eet_union_type_get;
eddc.func.type_set = _eet_union_type_set;
unified = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST1", _eet_st1_dd());
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST2", _eet_st2_dd());
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST3", _eet_st3_dd());
EET_DATA_DESCRIPTOR_ADD_UNION(edd, Eet_Union_Test, "u", u, type, unified);
EET_DATA_DESCRIPTOR_ADD_LIST(m, Eet_List, "list", list, edd);
l = calloc(1, sizeof (Eet_List));
#define EUT_NEW(Type_Index) \
eut = calloc(1, sizeof (Eet_Union_Test)); \
eut->type = EET_ST ## Type_Index; \
_eet_st ## Type_Index ## _set(&(eut->u.st ## Type_Index), i);
for (i = 0; i < 3; ++i)
{
EUT_NEW(1);
l->list = eina_list_append(l->list, eut);
EUT_NEW(2);
l->list = eina_list_append(l->list, eut);
EUT_NEW(3);
l->list = eina_list_append(l->list, eut);
}
blob = eet_data_descriptor_encode(m, l, &size);
fail_if(!blob || size <= 0);
l = eet_data_descriptor_decode(m, blob, size);
fail_if(!l);
fail_if(eina_list_count(l->list) != 9);
#define EUT_CMP(Type_Index) \
eut = eina_list_nth(l->list, i * 3 + Type_Index - 1); \
fail_if(eut->type != EET_ST ## Type_Index); \
_eet_st ## Type_Index ## _cmp(&(eut->u.st ## Type_Index), i);
for (i = 0; i < 3; ++i)
{
EUT_CMP(1);
EUT_CMP(2);
EUT_CMP(3);
}
eet_shutdown();
eina_shutdown();
}
END_TEST
START_TEST(eet_test_data_variant)
{
Eet_Variant_Test *evt;
Eet_List *l;
Eet_St1 *st1;
Eet_St2 *st2;
Eet_St3 *st3;
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor *unified;
Eet_Data_Descriptor *m;
void *blob;
int size;
int i;
eina_init();
eet_init();
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Variant_Test);
edd = eet_data_descriptor_stream_new(&eddc);
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Variant_Test);
m = eet_data_descriptor_stream_new(&eddc);
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
eddc.func.type_get = _eet_variant_type_get;
eddc.func.type_set = _eet_variant_type_set;
unified = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST1", _eet_st1_dd());
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST2", _eet_st2_dd());
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST3", _eet_st3_dd());
EET_DATA_DESCRIPTOR_ADD_VARIANT(edd,
Eet_Variant_Test,
"data",
data,
t,
unified);
unified = eet_data_descriptor_stream_new(&eddc);
eet_data_descriptor_element_add(unified, "ST1",
EET_T_UNKNOW, EET_G_LIST,
0, 0, NULL, _eet_st1_dd());
eet_data_descriptor_element_add(unified, "ST2",
EET_T_UNKNOW, EET_G_LIST,
0, 0, NULL, _eet_st2_dd());
EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, Eet_Variant_Test,
"data_list", data_list, t, unified);
EET_DATA_DESCRIPTOR_ADD_LIST(m, Eet_List, "list", list, edd);
l = calloc(1, sizeof (Eet_List));
#define EVT_NEW(Type_Index) \
evt = calloc(1, sizeof (Eet_Variant_Test)); \
evt->t.type = eet_mapping[Type_Index - 1].name; \
st ## Type_Index = calloc(1, sizeof (Eet_St ## Type_Index)); \
_eet_st ## Type_Index ## _set(st ## Type_Index, i); \
evt->data = st ## Type_Index;
for (i = 0; i < 3; ++i)
{
EVT_NEW(1);
l->list = eina_list_append(l->list, evt);
st1 = calloc(1, sizeof (Eet_St1));
_eet_st1_set(st1, i);
evt->data_list = eina_list_append(evt->data_list, st1);
EVT_NEW(2);
l->list = eina_list_append(l->list, evt);
EVT_NEW(3);
l->list = eina_list_append(l->list, evt);
}
blob = eet_data_descriptor_encode(m, l, &size);
fail_if(!blob || size <= 0);
l = eet_data_descriptor_decode(m, blob, size);
fail_if(!l);
fail_if(eina_list_count(l->list) != 9);
#define EVT_CMP(Type_Index) \
evt = eina_list_nth(l->list, i * 3 + Type_Index - 1); \
fail_if(strcmp(evt->t.type, eet_mapping[Type_Index - 1].name) != 0); \
_eet_st ## Type_Index ## _cmp(evt->data, i);
for (i = 0; i < 3; ++i)
{
EVT_CMP(1);
fail_if(!evt->data_list);
fail_if(eina_list_count(evt->data_list) != 1);
st1 = eina_list_data_get(evt->data_list);
_eet_st1_cmp(st1, i);
EVT_CMP(2);
EVT_CMP(3);
}
eet_shutdown();
eina_shutdown();
} /* START_TEST */
END_TEST
void eet_test_data(TCase *tc)
{
tcase_add_test(tc, eet_test_data_basic_type_encoding_decoding);
tcase_add_test(tc, eet_test_data_type_encoding_decoding);
tcase_add_test(tc, eet_test_data_type_dump_undump);
tcase_add_test(tc, eet_test_data_type_escape_dump_undump);
tcase_add_test(tc, eet_test_data_fp);
tcase_add_test(tc, eet_test_data_union);
tcase_add_test(tc, eet_test_data_variant);
}

View File

@ -0,0 +1,427 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <Eina.h>
#include <Eet.h>
#include "eet_suite.h"
#include "eet_test_common.h"
START_TEST(eet_test_file_simple_write)
{
const char *buffer = "Here is a string of data to save !";
Eet_File *ef;
char *test;
char *file;
int size;
int tmpfd;
file = strdup("/tmp/eet_suite_testXXXXXX");
eet_init();
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
fail_if(eet_mode_get(NULL) != EET_FILE_MODE_INVALID);
ef = eet_open(file, EET_FILE_MODE_WRITE);
fail_if(!ef);
fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 1));
fail_if(!eet_alias(ef, "keys/alias", "keys/tests", 0));
fail_if(!eet_alias(ef, "keys/alias2", "keys/alias", 1));
fail_if(eet_mode_get(ef) != EET_FILE_MODE_WRITE);
fail_if(eet_list(ef, "*", &size) != NULL);
fail_if(eet_num_entries(ef) != -1);
eet_close(ef);
/* Test read of simple file */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
test = eet_read(ef, "keys/tests", &size);
fail_if(!test);
fail_if(size != (int)strlen(buffer) + 1);
fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
test = eet_read(ef, "keys/alias2", &size);
fail_if(!test);
fail_if(size != (int)strlen(buffer) + 1);
fail_if(eet_read_direct(ef, "key/alias2", &size));
fail_if(eet_mode_get(ef) != EET_FILE_MODE_READ);
fail_if(eet_num_entries(ef) != 3);
eet_close(ef);
/* Test eet cache system */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
test = eet_read(ef, "keys/tests", &size);
fail_if(!test);
fail_if(size != (int)strlen(buffer) + 1);
fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
eet_close(ef);
fail_if(unlink(file) != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_file_data)
{
Eet_Data_Descriptor *edd;
Eet_Test_Ex_Type *result;
Eet_Dictionary *ed;
Eet_File *ef;
char **list;
char *file;
Eet_Data_Descriptor_Class eddc;
Eet_Test_Ex_Type etbt;
int size;
int test;
int tmpfd;
file = strdup("/tmp/eet_suite_testXXXXXX");
eet_init();
eet_test_ex_set(&etbt, 0);
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.hash, EET_TEST_KEY1, eet_test_ex_set(NULL, 2));
etbt.hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.hash, EET_TEST_KEY2, eet_test_ex_set(NULL, 2));
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ihash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
etbt.ihash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
etbt.slist = eina_list_prepend(NULL, "test");
etbt.shash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
memset(&etbt.charray, 0, sizeof(etbt.charray));
etbt.charray[0] = "test";
eet_test_setup_eddc(&eddc);
eddc.name = "Eet_Test_Ex_Type";
eddc.size = sizeof(Eet_Test_Ex_Type);
edd = eet_data_descriptor_file_new(&eddc);
fail_if(!edd);
eet_build_ex_descriptor(edd, EINA_FALSE);
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
/* Insert an error in etbt. */
etbt.i = 0;
/* Save the encoded data in a file. */
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
fail_if(!ef);
fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
fail_if(!result);
fail_if(eet_mode_get(ef) != EET_FILE_MODE_READ_WRITE);
/* Test string space. */
ed = eet_dictionary_get(ef);
fail_if(!eet_dictionary_string_check(ed, result->str));
fail_if(eet_dictionary_string_check(ed, result->istr));
eet_close(ef);
/* Attempt to replace etbt by the correct one. */
etbt.i = EET_TEST_INT;
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
fail_if(!ef);
fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
fail_if(!result);
/* Test the resulting data. */
fail_if(eet_test_ex_check(result, 0, EINA_FALSE) != 0);
eet_close(ef);
/* Read back the data. */
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
fail_if(!ef);
fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY2, &etbt, 0));
result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
fail_if(!result);
/* Test string space. */
ed = eet_dictionary_get(ef);
fail_if(!ed);
fail_if(!eet_dictionary_string_check(ed, result->str));
fail_if(eet_dictionary_string_check(ed, result->istr));
/* Test the resulting data. */
fail_if(eet_test_ex_check(result, 0, EINA_FALSE) != 0);
fail_if(eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_FALSE) != 0);
fail_if(eina_list_data_get(result->ilist) == NULL);
fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
fail_if(eina_list_data_get(result->slist) == NULL);
fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
fail_if(strcmp(result->charray[0], "test") != 0);
test = 0;
if (result->hash)
eina_hash_foreach(result->hash, func, &test);
fail_if(test != 0);
if (result->ihash)
eina_hash_foreach(result->ihash, func7, &test);
fail_if(test != 0);
list = eet_list(ef, "keys/*", &size);
fail_if(eet_num_entries(ef) != 2);
fail_if(size != 2);
fail_if(!(strcmp(list[0],
EET_TEST_FILE_KEY1) == 0 &&
strcmp(list[1], EET_TEST_FILE_KEY2) == 0)
&& !(strcmp(list[0],
EET_TEST_FILE_KEY2) == 0 &&
strcmp(list[1], EET_TEST_FILE_KEY1) == 0));
free(list);
fail_if(eet_delete(ef, NULL) != 0);
fail_if(eet_delete(NULL, EET_TEST_FILE_KEY1) != 0);
fail_if(eet_delete(ef, EET_TEST_FILE_KEY1) == 0);
list = eet_list(ef, "keys/*", &size);
fail_if(size != 1);
fail_if(eet_num_entries(ef) != 1);
/* Test some more wrong case */
fail_if(eet_data_read(ef, edd, "plop") != NULL);
fail_if(eet_data_read(ef, edd, EET_TEST_FILE_KEY1) != NULL);
/* Reinsert and reread data */
fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
fail_if(eet_data_read(ef, edd, EET_TEST_FILE_KEY1) == NULL);
fail_if(eet_read_direct(ef, EET_TEST_FILE_KEY1, &size) == NULL);
eet_close(ef);
fail_if(unlink(file) != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_file_data_dump)
{
Eet_Data_Descriptor *edd;
Eet_Test_Ex_Type *result;
Eet_Data_Descriptor_Class eddc;
Eet_Test_Ex_Type etbt;
Eet_File *ef;
char *string1;
char *file;
int test;
int tmpfd;
file = strdup("/tmp/eet_suite_testXXXXXX");
eet_init();
eet_test_ex_set(&etbt, 0);
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1));
etbt.hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.hash, EET_TEST_KEY1, eet_test_ex_set(NULL, 2));
eina_hash_add(etbt.hash, EET_TEST_KEY2, eet_test_ex_set(NULL, 2));
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
etbt.ihash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
etbt.slist = eina_list_prepend(NULL, "test");
etbt.shash = eina_hash_string_superfast_new(NULL);
eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
memset(&etbt.charray, 0, sizeof(etbt.charray));
etbt.charray[0] = "test";
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
"Eet_Test_Ex_Type",
sizeof(Eet_Test_Ex_Type));
edd = eet_data_descriptor_file_new(&eddc);
fail_if(!edd);
eet_build_ex_descriptor(edd, EINA_FALSE);
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
/* Save the encoded data in a file. */
ef = eet_open(file, EET_FILE_MODE_WRITE);
fail_if(!ef);
fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
eet_close(ef);
/* Use dump/undump in the middle */
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
fail_if(!ef);
string1 = NULL;
fail_if(eet_data_dump(ef, EET_TEST_FILE_KEY1, append_string, &string1) != 1);
fail_if(eet_delete(ef, EET_TEST_FILE_KEY1) == 0);
fail_if(!eet_data_undump(ef, EET_TEST_FILE_KEY1, string1, strlen(string1), 1));
eet_close(ef);
/* Test the correctness of the reinsertion. */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
fail_if(!result);
eet_close(ef);
/* Test the resulting data. */
fail_if(eet_test_ex_check(result, 0, EINA_TRUE) != 0);
fail_if(eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_TRUE) != 0);
fail_if(eina_list_data_get(result->ilist) == NULL);
fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
fail_if(eina_list_data_get(result->slist) == NULL);
fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
fail_if(strcmp(result->charray[0], "test") != 0);
test = 0;
_dump_call = EINA_TRUE;
if (result->hash)
eina_hash_foreach(result->hash, func, &test);
_dump_call = EINA_FALSE;
fail_if(test != 0);
if (result->ihash)
eina_hash_foreach(result->ihash, func7, &test);
fail_if(test != 0);
fail_if(unlink(file) != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_file_fp)
{
char *file;
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor *edd_5FP;
Eet_Data_Descriptor *edd_5DBL;
Eet_File *ef;
Eet_5FP origin;
Eet_5DBL *convert;
Eet_5FP *build;
int tmpfd;
file = strdup("/tmp/eet_suite_testXXXXXX");
eet_init();
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_5FP);
edd_5FP = eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp32", fp32, EET_T_F32P32);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp16", fp16, EET_T_F16P16);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp8", fp8, EET_T_F8P24);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f1", f1, EET_T_F32P32);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f0", f0, EET_T_F32P32);
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Eet_5FP", sizeof (Eet_5DBL));
edd_5DBL = eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp32", fp32, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp16", fp16, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp8", fp8, EET_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f1", f1, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f0", f0, EET_T_DOUBLE);
origin.fp32 = eina_f32p32_double_from(1.125);
origin.fp16 = eina_f16p16_int_from(2000);
origin.fp8 = eina_f8p24_int_from(125);
origin.f1 = eina_f32p32_int_from(1);
origin.f0 = 0;
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
fail_if(!ef);
fail_if(!eet_data_write(ef, edd_5FP, EET_TEST_FILE_KEY1, &origin, 1));
build = eet_data_read(ef, edd_5FP, EET_TEST_FILE_KEY1);
fail_if(!build);
convert = eet_data_read(ef, edd_5DBL, EET_TEST_FILE_KEY1);
fail_if(!convert);
fail_if(build->fp32 != eina_f32p32_double_from(1.125));
fail_if(build->fp16 != eina_f16p16_int_from(2000));
fail_if(build->fp8 != eina_f8p24_int_from(125));
fail_if(build->f1 != eina_f32p32_int_from(1));
fail_if(build->f0 != 0);
fail_if(convert->fp32 != 1.125);
fail_if(convert->fp16 != 2000);
fail_if(convert->fp8 != 125);
fail_if(convert->f1 != 1);
fail_if(convert->f0 != 0);
eet_close(ef);
fail_if(unlink(file) != 0);
eet_shutdown();
}
END_TEST
void eet_test_file(TCase *tc)
{
tcase_add_test(tc, eet_test_file_simple_write);
tcase_add_test(tc, eet_test_file_data);
tcase_add_test(tc, eet_test_file_data_dump);
tcase_add_test(tc, eet_test_file_fp);
}

View File

@ -0,0 +1,248 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <Eina.h>
#include <Eet.h>
#include "eet_suite.h"
#include "eet_test_common.h"
#ifndef O_BINARY
# define O_BINARY 0
#endif
static char _key_pem[PATH_MAX] = "";
static char _cert_pem[PATH_MAX] = "";
static char _key_enc[PATH_MAX] = "";
static char _key_enc_pem[PATH_MAX] = "";
static char _key_enc_none_pem[PATH_MAX] = "";
static int
pass_get(char *pass,
int size,
EINA_UNUSED int rwflags,
EINA_UNUSED void *u)
{
memset(pass, 0, size);
if ((int)strlen("password") > size)
return 0;
snprintf(pass, size, "%s", "password");
return strlen(pass);
}
static int
badpass_get(char *pass,
int size,
EINA_UNUSED int rwflags,
EINA_UNUSED void *u)
{
memset(pass, 0, size);
if ((int)strlen("bad password") > size)
return 0;
snprintf(pass, size, "%s", "bad password");
return strlen(pass);
}
START_TEST(eet_test_identity_simple)
{
const char *buffer = "Here is a string of data to save !";
const void *tmp;
Eet_File *ef;
Eet_Key *k;
FILE *noread;
char *test;
char *file;
int size;
int fd;
file = strdup("/tmp/eet_suite_testXXXXXX");
eet_init();
fail_if(-1 == (fd = mkstemp(file)));
fail_if(!!close(fd));
fail_if(!(noread = fopen("/dev/null", "wb")));
/* Sign an eet file. */
ef = eet_open(file, EET_FILE_MODE_WRITE);
fail_if(!ef);
fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0));
k = eet_identity_open(_cert_pem, _key_pem, NULL);
fail_if(!k);
fail_if(eet_identity_set(ef, k) != EET_ERROR_NONE);
eet_identity_print(k, noread);
eet_close(ef);
/* Open a signed file. */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
/* check that the certificates match */
fail_if(!eet_identity_verify(ef, _cert_pem));
test = eet_read(ef, "keys/tests", &size);
fail_if(!test);
fail_if(size != (int)strlen(buffer) + 1);
fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
tmp = eet_identity_x509(ef, &size);
fail_if(tmp == NULL);
eet_identity_certificate_print(tmp, size, noread);
eet_close(ef);
/* As we are changing file contain in less than 1s, this could get unnoticed
by eet cache system. */
eet_clearcache();
/* Corrupting the file. */
fd = open(file, O_WRONLY | O_BINARY);
fail_if(fd < 0);
fail_if(lseek(fd, 200, SEEK_SET) != 200);
fail_if(write(fd, "42", 2) != 2);
fail_if(lseek(fd, 50, SEEK_SET) != 50);
fail_if(write(fd, "42", 2) != 2);
fail_if(lseek(fd, 88, SEEK_SET) != 88);
fail_if(write(fd, "42", 2) != 2);
close(fd);
/* Attempt to open a modified file. */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(ef);
fail_if(unlink(file) != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_identity_open_simple)
{
Eet_Key *k = NULL;
eet_init();
k = eet_identity_open(_cert_pem, _key_pem, NULL);
fail_if(!k);
if (k)
eet_identity_close(k);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_identity_open_pkcs8)
{
Eet_Key *k = NULL;
eet_init();
k = eet_identity_open(_cert_pem, _key_enc_none_pem, NULL);
fail_if(!k);
if (k)
eet_identity_close(k);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_identity_open_pkcs8_enc)
{
Eet_Key *k = NULL;
eet_init();
k = eet_identity_open(_cert_pem, _key_enc_pem, NULL);
fail_if(k);
if (k)
eet_identity_close(k);
k = eet_identity_open(_cert_pem, _key_enc_pem, &badpass_get);
fail_if(k);
if (k)
eet_identity_close(k);
k = eet_identity_open(_cert_pem, _key_enc_pem, &pass_get);
fail_if(!k);
if (k)
eet_identity_close(k);
eet_shutdown();
}
END_TEST
static const char *_cert_dir_find(const char *argv0)
{
static char base[PATH_MAX] = "";
char path[PATH_MAX];
struct stat st;
eina_strlcpy(base, TESTS_SRC_DIR, sizeof(base));
eina_str_join(path, sizeof(path), '/', base, "key.pem");
if (stat(path, &st) == 0)
return base;
if (base[0] != '/')
{
snprintf(base, sizeof(base), "%s/%s", TESTS_WD, TESTS_SRC_DIR);
eina_str_join(path, sizeof(path), '/', base, "key.pem");
if (stat(path, &st) == 0)
return base;
}
eina_strlcpy(base, argv0, sizeof(base));
do
{
char *p = strrchr(base, '/');
if (!p)
{
base[0] = '\0';
break;
}
*p = '\0';
eina_str_join(path, sizeof(path), '/', base, "key.pem");
}
while (stat(path, &st) != 0);
return base;
}
void eet_test_identity(TCase *tc)
{
const char *base;
base = _cert_dir_find(argv0);
eina_str_join(_key_pem, sizeof(_key_pem), '/', base, "key.pem");
eina_str_join(_cert_pem, sizeof(_cert_pem), '/', base,"cert.pem");
eina_str_join(_key_enc, sizeof(_key_enc), '/', base, "key.enc");
eina_str_join(_key_enc_pem, sizeof(_key_enc_pem), '/', base, "key_enc.pem");
eina_str_join(_key_enc_none_pem, sizeof(_key_enc_none_pem), '/',
base, "key_enc_none.pem");
tcase_add_test(tc, eet_test_identity_simple);
tcase_add_test(tc, eet_test_identity_open_simple);
tcase_add_test(tc, eet_test_identity_open_pkcs8);
tcase_add_test(tc, eet_test_identity_open_pkcs8_enc);
}

View File

@ -0,0 +1,502 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <Eina.h>
#include <Eet.h>
#include "eet_suite.h"
#include "eet_test_common.h"
#define IM0 0x00112233
#define IM1 0x44556677
#define IM2 0x8899aabb
#define IM3 0xccddeeff
typedef struct _Eet_Test_Image Eet_Test_Image;
struct _Eet_Test_Image
{
unsigned int w;
unsigned int h;
int alpha;
unsigned int color[64];
};
static const Eet_Test_Image test_noalpha = {
8, 8, 0,
{
0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00,
0x000000AA, 0x00110000,
0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA,
0x00110000, 0x00AA0000,
0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000,
0x00AA0000, 0x0000AA00,
0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000,
0x0000AA00, 0x000000AA,
0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00,
0x000000AA, 0x00110000,
0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA,
0x00110000, 0x00AA0000,
0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000,
0x00AA0000, 0x0000AA00,
0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000,
0x0000AA00, 0x000000AA
}
};
static const Eet_Test_Image test_alpha = {
8, 8, 1,
{
0x0FAA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00,
0x000000AA, 0x0F110000,
0x0000AA00, 0x0F0000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA,
0x0F110000, 0x00AA0000,
0x000000AA, 0x00110000, 0x0FAA0000, 0x0000AA00, 0x000000AA, 0x0F110000,
0x00AA0000, 0x0000AA00,
0x00110000, 0x00AA0000, 0x0000AA00, 0x0F0000AA, 0x0F110000, 0x00AA0000,
0x0000AA00, 0x000000AA,
0x00AA0000, 0x0000AA00, 0x000000AA, 0x0F110000, 0x0FAA0000, 0x0000AA00,
0x000000AA, 0x00110000,
0x0000AA00, 0x000000AA, 0x0F110000, 0x00AA0000, 0x0000AA00, 0x0F0000AA,
0x00110000, 0x00AA0000,
0x000000AA, 0x0F110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000,
0x0FAA0000, 0x0000AA00,
0x0F110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000,
0x0000AA00, 0x0F0000AA
}
};
START_TEST(eet_test_image_normal)
{
Eet_File *ef;
char *file;
unsigned int *data;
int compress;
int quality;
int result;
Eet_Image_Encoding lossy;
int alpha;
unsigned int w;
unsigned int h;
int tmpfd;
file = strdup("/tmp/eet_suite_testXXXXXX");
eet_init();
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
/* Save the encoded data in a file. */
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
fail_if(!ef);
result = eet_data_image_write(ef,
EET_TEST_FILE_IMAGE "0",
test_noalpha.color,
test_noalpha.w,
test_noalpha.h,
test_noalpha.alpha,
0,
100,
0);
fail_if(result == 0);
result = eet_data_image_write(ef,
EET_TEST_FILE_IMAGE "1",
test_noalpha.color,
test_noalpha.w,
test_noalpha.h,
test_noalpha.alpha,
5,
100,
0);
fail_if(result == 0);
result = eet_data_image_write(ef,
EET_TEST_FILE_IMAGE "2",
test_noalpha.color,
test_noalpha.w,
test_noalpha.h,
test_noalpha.alpha,
9,
100,
0);
fail_if(result == 0);
result = eet_data_image_write(ef,
EET_TEST_FILE_IMAGE "3",
test_noalpha.color,
test_noalpha.w,
test_noalpha.h,
test_noalpha.alpha,
0,
100,
1);
fail_if(result == 0);
result = eet_data_image_write(ef,
EET_TEST_FILE_IMAGE "4",
test_noalpha.color,
test_noalpha.w,
test_noalpha.h,
test_noalpha.alpha,
0,
60,
1);
fail_if(result == 0);
result = eet_data_image_write(ef,
EET_TEST_FILE_IMAGE "5",
test_noalpha.color,
test_noalpha.w,
test_noalpha.h,
test_noalpha.alpha,
0,
10,
1);
fail_if(result == 0);
result = eet_data_image_write(ef,
EET_TEST_FILE_IMAGE "6",
test_noalpha.color,
test_noalpha.w,
test_noalpha.h,
test_noalpha.alpha,
0,
0,
1);
fail_if(result == 0);
result = eet_data_image_write(ef, EET_TEST_FILE_IMAGE "7", test_alpha.color,
test_alpha.w, test_alpha.h, test_alpha.alpha,
9, 100, 0);
fail_if(result == 0);
result = eet_data_image_write(ef, EET_TEST_FILE_IMAGE "8", test_alpha.color,
test_alpha.w, test_alpha.h, test_alpha.alpha,
0, 80, 1);
fail_if(result == 0);
result = eet_data_image_write(ef, EET_TEST_FILE_IMAGE "9", test_alpha.color,
test_alpha.w, test_alpha.h, test_alpha.alpha,
0, 100, 1);
fail_if(result == 0);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "2",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(compress != 9);
fail_if(lossy != 0);
fail_if(data[0] != test_noalpha.color[0]);
free(data);
result = eet_data_image_header_read(ef,
EET_TEST_FILE_IMAGE "2",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(result == 0);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(compress != 9);
fail_if(lossy != 0);
eet_close(ef);
/* Test read of image */
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
result = eet_data_image_header_read(ef,
EET_TEST_FILE_IMAGE "0",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(result == 0);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(compress != 0);
fail_if(lossy != 0);
data = malloc(w * h * 4);
fail_if(data == NULL);
result = eet_data_image_read_to_surface(ef,
EET_TEST_FILE_IMAGE "0",
4,
4,
data,
2,
2,
w * 4,
&alpha,
&compress,
&quality,
&lossy);
fail_if(result != 1);
fail_if(alpha != test_noalpha.alpha);
fail_if(compress != 0);
fail_if(quality != 100);
fail_if(lossy != 0);
fail_if(data[0] != test_noalpha.color[4 + 4 * w]);
free(data);
data = malloc(w * h * 4);
fail_if(data == NULL);
result = eet_data_image_read_to_surface(ef,
EET_TEST_FILE_IMAGE "0",
0,
0,
data,
w,
h,
w * 4,
&alpha,
&compress,
&quality,
&lossy);
fail_if(result != 1);
fail_if(alpha != test_noalpha.alpha);
fail_if(compress != 0);
fail_if(quality != 100);
fail_if(lossy != 0);
fail_if(data[0] != test_noalpha.color[0]);
free(data);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "1",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(compress != 5);
fail_if(quality != 100);
fail_if(lossy != 0);
fail_if(data[0] != test_noalpha.color[0]);
free(data);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "2",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(compress != 9);
fail_if(lossy != 0);
fail_if(data[0] != test_noalpha.color[0]);
free(data);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "3",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(lossy != 1);
free(data);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "5",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(lossy != 1);
free(data);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "6",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_noalpha.w);
fail_if(h != test_noalpha.h);
fail_if(alpha != test_noalpha.alpha);
fail_if(lossy != 1);
free(data);
result = eet_data_image_header_read(ef,
EET_TEST_FILE_IMAGE "7",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(result == 0);
fail_if(w != test_alpha.w);
fail_if(h != test_alpha.h);
fail_if(alpha != test_alpha.alpha);
fail_if(compress != 9);
fail_if(lossy != 0);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "7",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_alpha.w);
fail_if(h != test_alpha.h);
fail_if(alpha != test_alpha.alpha);
fail_if(compress != 9);
fail_if(lossy != 0);
fail_if(data[0] != test_alpha.color[0]);
free(data);
result = eet_data_image_header_read(ef,
EET_TEST_FILE_IMAGE "9",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(result == 0);
fail_if(w != test_alpha.w);
fail_if(h != test_alpha.h);
fail_if(alpha != test_alpha.alpha);
fail_if(lossy != 1);
data = eet_data_image_read(ef,
EET_TEST_FILE_IMAGE "9",
&w,
&h,
&alpha,
&compress,
&quality,
&lossy);
fail_if(data == NULL);
fail_if(w != test_alpha.w);
fail_if(h != test_alpha.h);
fail_if(alpha != test_alpha.alpha);
fail_if(lossy != 1);
free(data);
eet_close(ef);
fail_if(unlink(file) != 0);
eet_shutdown();
}
END_TEST
START_TEST(eet_test_image_small)
{
char *file;
unsigned int image[4];
unsigned int *data;
Eet_File *ef;
unsigned int w;
unsigned int h;
int alpha;
int compression;
int quality;
Eet_Image_Encoding lossy;
int result;
int tmpfd;
file = strdup("/tmp/eet_suite_testXXXXXX");
image[0] = IM0;
image[1] = IM1;
image[2] = IM2;
image[3] = IM3;
eet_init();
fail_if(-1 == (tmpfd = mkstemp(file)));
fail_if(!!close(tmpfd));
ef = eet_open(file, EET_FILE_MODE_WRITE);
fail_if(!ef);
result = eet_data_image_write(ef, "/images/test", image, 2, 2, 1, 9, 100, 0);
fail_if(result == 0);
eet_close(ef);
ef = eet_open(file, EET_FILE_MODE_READ);
fail_if(!ef);
data = (unsigned int *)eet_data_image_read(ef,
"/images/test",
&w,
&h,
&alpha,
&compression,
&quality,
&lossy);
fail_if(data == NULL);
eet_close(ef);
fail_if(unlink(file) != 0);
fail_if(data[0] != IM0);
fail_if(data[1] != IM1);
fail_if(data[2] != IM2);
fail_if(data[3] != IM3);
free(data);
eet_shutdown();
}
END_TEST
void eet_test_image(TCase *tc)
{
tcase_add_test(tc, eet_test_image_normal);
tcase_add_test(tc, eet_test_image_small);
}

View File

@ -0,0 +1,24 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Eet.h>
#include "eet_suite.h"
START_TEST(_eet_test_init)
{
int ret;
ret = eet_init();
fail_if(ret != 1);
ret = eet_shutdown();
fail_if(ret != 0);
}
END_TEST
void eet_test_init(TCase *tc)
{
tcase_add_test(tc, _eet_test_init);
}

View File

@ -1,110 +1,26 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Eet.hh"
#include <Eina.h>
#include "eet_cxx_suite.h"
#include "../efl_check.h"
#include <cassert>
#include <algorithm>
#include <check.h>
void eet_test_descriptors(TCase* tc);
typedef struct _Eet_Test_Case Eet_Test_Case;
struct _Eet_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static const Eet_Test_Case etc[] = {
{ "Descriptors", eet_test_descriptors },
static const Efl_Test_Case etc[] = {
{ "Descriptors", eet_cxx_test_descriptors },
{ NULL, NULL }
};
static void
_list_tests(void)
{
const Eet_Test_Case *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;
}
Suite *
eet_build_suite(int argc, const char **argv)
{
TCase *tc;
Suite *s;
int i;
s = suite_create("Eet C++");
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);
#ifndef _WIN32
tcase_set_timeout(tc, 0);
#endif
etc[i].build(tc);
suite_add_tcase(s, tc);
}
return s;
}
int main(int argc, char* argv[])
{
Suite *s;
SRunner *sr;
int i, failed_count;
int 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;
}
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
s = eet_build_suite(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);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Eet C++", etc);
return (failed_count == 0) ? 0 : 255;
}

View File

@ -0,0 +1,11 @@
#ifndef _EET_CXX_SUITE_H
#define _EET_CXX_SUITE_H
#include <cassert>
#include <algorithm>
#include <check.h>
void eet_cxx_test_descriptors(TCase* tc);
#endif /* _EET_CXX_SUITE_H */

View File

@ -1,15 +1,13 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Eet.hh"
#include <algorithm>
#include <iostream>
#include <check.h>
#include <Eet.hh>
#include "eet_cxx_suite.h"
struct pod_type
{
@ -141,7 +139,7 @@ START_TEST(eet_cxx_descriptors_composition)
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
ck_assert(file != 0);
::pod_composited pod_composited {new pod_type{5, 'a'}};
int s = eet_data_write(file, d.native_handle(), "foo", &pod_composited, false);
@ -170,7 +168,7 @@ START_TEST(eet_cxx_descriptors_composition)
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
ck_assert(file != 0);
::pod_composited_with_non_pod pod_composited_with_non_pod {new non_pod};
int s = eet_data_write(file, d.native_handle(), "foo", &pod_composited_with_non_pod, false);
@ -205,7 +203,7 @@ START_TEST(eet_cxx_descriptors_composition)
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
ck_assert(file != 0);
::pod_value_composited pod_value_composited {{5, 'a'}};
int s = eet_data_write(file, d.native_handle(), "foo", &pod_value_composited, false);
@ -227,7 +225,7 @@ START_TEST(eet_cxx_descriptors_composition)
END_TEST
void
eet_test_descriptors(TCase* tc)
eet_cxx_test_descriptors(TCase* tc)
{
tcase_add_test(tc, eet_cxx_descriptors);
tcase_add_test(tc, eet_cxx_descriptors_non_pod);

View File

@ -2,684 +2,29 @@
# include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#include <stdlib.h>
#include <stdio.h>
#include <Eina.h>
#include <check.h>
#include <Eeze.h>
#include <Eeze_Sensor.h>
#include <Eeze_Net.h>
#include "eeze_udev_private.h"
#include "eeze_sensor_private.h"
START_TEST(eeze_test_init)
{
int ret;
ret = eeze_init();
fail_if(ret != 1);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
static void
catch_events(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED,
void *data EINA_UNUSED, Eeze_Udev_Watch *watch EINA_UNUSED)
{
}
#if 0
// FIXME split udev tests into pieces here
START_TEST(eeze_test_udev_types)
{
Eina_List *type;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NONE, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_CDROM, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_AC, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_BAT, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BLUETOOTH, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(0, NULL);
type = eeze_udev_find_unlisted_similar(type);
eeze_shutdown();
}
END_TEST
#endif
START_TEST(eeze_test_udev_watch)
{
Eeze_Udev_Watch *watch;
ecore_init();
eeze_init();
/* watch never gets triggered as this is run without user interaction */
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_DRIVE_INTERNAL, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_POWER_AC, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NET, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_V4L, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_BLUETOOTH, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NONE, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
eeze_udev_watch_del(watch);
eeze_shutdown();
ecore_shutdown();
}
END_TEST
START_TEST(eeze_test_udev_syspath)
{
Eina_List *type, *l;
const char *name;
Eina_Bool r;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
eeze_udev_syspath_get_devpath(name);
eeze_udev_find_similar_from_syspath(name);
eeze_udev_find_similar_from_syspath(NULL);
eeze_udev_syspath_get_parent(name);
eeze_udev_syspath_get_parent(NULL);
eeze_udev_syspath_get_parents(name);
eeze_udev_syspath_get_parents(NULL);
eeze_udev_syspath_get_devname(name);
eeze_udev_syspath_get_devname(NULL);
eeze_udev_syspath_get_subsystem(name);
eeze_udev_syspath_get_sysattr(name, "manufacturer");
eeze_udev_syspath_is_mouse(name);
eeze_udev_syspath_is_kbd(name);
eeze_udev_syspath_is_touchpad(name);
eeze_udev_syspath_is_joystick(name);
eeze_udev_walk_get_sysattr(name, "manufacturer");
eeze_udev_find_by_sysattr("manufacturer", NULL);
eeze_udev_find_by_sysattr(NULL, NULL);
eeze_udev_walk_check_sysattr(name, "manufacturer", NULL);
eeze_udev_walk_check_sysattr(name, "manufacturer", "foo");
eeze_udev_walk_get_sysattr(NULL, "manufacturer");
eeze_udev_walk_get_sysattr(name, NULL);
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
r = eeze_udev_syspath_is_mouse(name);
fail_unless(r);
eeze_udev_syspath_is_touchpad(name);
eeze_udev_syspath_is_joystick(name);
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
r = eeze_udev_syspath_is_touchpad(name);
fail_unless(r);
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
r = eeze_udev_syspath_is_joystick(name);
fail_unless(r);
}
eeze_udev_devpath_get_syspath("/dev/null");
eeze_shutdown();
}
END_TEST
START_TEST(eeze_test_udev_attr)
{
Eina_List *type;
const char *name, *check, *check2;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
type = eeze_udev_find_unlisted_similar(type);
eeze_udev_find_by_filter("backlight", NULL, NULL);
eeze_udev_find_by_filter(NULL, NULL, NULL);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
check = eeze_udev_syspath_get_property(name, "INTERFACE");
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
check = eeze_udev_syspath_get_property(name, "ID_SERIAL");
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
if ((check = eeze_udev_syspath_get_sysattr(name, "model")))
{
check2 = eeze_udev_syspath_get_subsystem(name);
}
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
if ((check = eeze_udev_syspath_get_property(name, "DEVNAME")))
{
if ((check2 = eeze_udev_syspath_get_sysattr(name, "name")))
{
eina_stringshare_del(check2);
}
eina_stringshare_del(check);
}
eina_stringshare_del(name);
}
eeze_shutdown();
}
END_TEST
/*
START_TEST(eeze_test_udev_device)
{
Eina_List *type, *l;
_udev_device *device, *device2;
const char *name;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
fail_if(type == NULL);
type = eeze_udev_find_unlisted_similar(type);
fail_if(type == NULL);
EINA_LIST_FOREACH(type, l, name)
{
device = _new_device(name);
fail_if(device == NULL);
_walk_parents_get_attr(device, "FOO", EINA_FALSE);
_walk_parents_get_attr(device, "FOO", EINA_TRUE);
_walk_children_get_attr(name, "FOO", "BAR", EINA_FALSE);
_walk_children_get_attr(name, "FOO", "BAR", EINA_TRUE);
}
device = _new_device("Wrong path");
fail_if(device != NULL);
device2 = _copy_device(device);
fail_if(device2 != NULL);
eeze_shutdown();
}
END_TEST
*/
START_TEST(eeze_test_net_list)
{
int ret;
Eina_List *list = NULL;
ret = eeze_init();
fail_if(ret != 1);
list = eeze_net_list();
fail_if(list == NULL);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
START_TEST(eeze_test_net_attr)
{
int ret;
int idx = 0;
Eeze_Net *net = NULL;
const char *tmp = NULL;
ret = eeze_init();
fail_if(ret != 1);
net = eeze_net_new("lo");
fail_if(net == NULL);
tmp = eeze_net_mac_get(net);
fail_if(tmp == NULL);
tmp = NULL;
idx = eeze_net_idx_get(net);
fail_if(!idx);
eeze_net_scan(net);
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_attribute_get(net, "carrier");
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_syspath_get(net);
fail_if(tmp == NULL);
eeze_net_free(net);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
/*
#ifdef HAVE_IPV6
START_TEST(eeze_test_net_attr_ipv6)
{
int ret;
Eeze_Net *net = NULL;
const char *tmp = NULL;
ret = eeze_init();
fail_if(ret != 1);
net = eeze_net_new("lo");
fail_if(net == NULL);
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP6);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST6);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK6);
fail_if(tmp == NULL);
eeze_net_free(net);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
#endif
*/
START_TEST(eeze_test_sensor_read)
{
Eeze_Sensor_Obj *sens = NULL;
int ret = 0;
float x, y, z;
int acc;
double timestamp;
Eina_Bool rc = EINA_FALSE;
ecore_init();
ret = eeze_init();
fail_if(ret != 1);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
/* Use gyro with xy here even if it offers xzy */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xy_get(sens, &x, &y);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_x_get(sens, &x);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_x_get(sens, &x);
fail_if(rc == EINA_FALSE);
/* Call non existing type */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LAST + 1);
fail_if(sens != NULL);
/* Give NULL as sensor object */
rc = eeze_sensor_read(NULL);
fail_if(rc != EINA_FALSE);
/* Change sensor type after creation but before read */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST + 1;
rc = eeze_sensor_read(sens);
fail_if(rc != EINA_FALSE);
/* Try to read from a type you can't read from */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST;
rc = eeze_sensor_read(sens);
fail_if(rc != EINA_FALSE);
/* Try all getter functions with a NULL sensor object */
rc = eeze_sensor_xyz_get(NULL, &x, &y, &z);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_xy_get(NULL, &x, &y);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_x_get(NULL, &x);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_accuracy_get(NULL, &acc);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_timestamp_get(NULL, &timestamp);
fail_if(rc != EINA_FALSE);
eeze_sensor_free(sens);
/* Try free on NULL */
eeze_sensor_free(NULL);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
static int cb_count = 0;
static Eina_Bool
event_cb(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
{
Eeze_Sensor_Obj *sens = NULL;
int acc;
double timestamp;
Eina_Bool rc = EINA_FALSE;
sens = event;
fail_if(sens == NULL);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
/* We expect 5 callbacks from async reads right now */
if (++cb_count == 5)
ecore_main_loop_quit();
return ECORE_CALLBACK_DONE;
}
START_TEST(eeze_test_sensor_async_read)
{
Ecore_Event_Handler *handler;
Eeze_Sensor_Obj *sens = NULL;
int ret = 0;
Eina_Bool rc = EINA_FALSE;
ecore_init();
ret = eeze_init();
fail_if(ret != 1);
handler = ecore_event_handler_add(EEZE_SENSOR_EVENT_ACCELEROMETER, event_cb, NULL);
fail_if(handler == NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_MAGNETIC, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_ORIENTATION, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_GYROSCOPE, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_PROXIMITY, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_LIGHT, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
/* Error case */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LAST + 1);
fail_if(sens != NULL);
rc = eeze_sensor_async_read(NULL, NULL);
fail_if(rc != EINA_FALSE);
/* Change sensor type after creation but before read */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST + 1;
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc != EINA_FALSE);
/* Try to read from a type you can't read from */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST;
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc != EINA_FALSE);
ecore_main_loop_begin();
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
START_TEST(eeze_test_sensor_obj_get)
{
Eeze_Sensor_Obj *obj = NULL, *obj_tmp = NULL;
int ret = 0;
ecore_init();
ret = eeze_init();
fail_if(ret != 1);
obj = calloc(1, sizeof(Eeze_Sensor_Obj));
fail_if(obj == NULL);
obj_tmp = obj;
obj = eeze_sensor_obj_get(EEZE_SENSOR_TYPE_ACCELEROMETER);
fail_if(obj == obj_tmp);
free(obj);
/* Try to get non existing obj */
obj_tmp = eeze_sensor_obj_get(EEZE_SENSOR_TYPE_LAST + 1);
fail_if(obj_tmp != NULL);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
Suite *
eeze_suite(void)
{
Suite *s;
TCase *tc;
s = suite_create("Eeze");
tc = tcase_create("Eeze_Init");
tcase_add_test(tc, eeze_test_init);
suite_add_tcase(s, tc);
tc = tcase_create("Eeze_Udev");
//FIXME This also fails all the time. Enable this once we verify it's not completely useless
//tcase_add_test(tc, eeze_test_udev_types);
tcase_add_test(tc, eeze_test_udev_watch);
tcase_add_test(tc, eeze_test_udev_syspath);
tcase_add_test(tc, eeze_test_udev_attr);
//FIXME Tested functions here are hidden (not EAPI) and thus can not be tested like this with
//-fvisibility=hidden turned on.
//tcase_add_test(tc, eeze_test_udev_device);
suite_add_tcase(s, tc);
tc = tcase_create("Eeze_Net");
tcase_add_test(tc, eeze_test_net_list);
tcase_add_test(tc, eeze_test_net_attr);
#ifdef HAVE_IPV6
//FIXME Figure out why we fail for the ipv6 tests here (code or test)
//tcase_add_test(tc, eeze_test_net_attr_ipv6);
#endif
suite_add_tcase(s, tc);
tc = tcase_create("Eeze Sensor");
tcase_add_test(tc, eeze_test_sensor_read);
tcase_add_test(tc, eeze_test_sensor_async_read);
tcase_add_test(tc, eeze_test_sensor_obj_get);
suite_add_tcase(s, tc);
tcase_set_timeout(tc, 0);
return s;
}
#include "eeze_suite.h"
#include "../efl_check.h"
static const Efl_Test_Case etc[] = {
{ "Init", eeze_test_init },
{ "UDev", eeze_test_udev },
{ "Net", eeze_test_net },
{ "Sensor", eeze_test_sensor },
{ NULL, NULL }
};
int
main(void)
main(int argc, char *argv[])
{
Suite *s;
SRunner *sr;
int failed_count;
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv("EFL_RUN_IN_TREE=1");
s = eeze_suite();
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);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Eeze", etc);
return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -0,0 +1,11 @@
#ifndef _EEZE_SUITE_H
#define _EEZE_SUITE_H
#include <check.h>
void eeze_test_init(TCase *tc);
void eeze_test_udev(TCase *tc);
void eeze_test_net(TCase *tc);
void eeze_test_sensor(TCase *tc);
#endif /* _EEZE_SUITE_H */

View File

@ -0,0 +1,24 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Eeze.h>
#include "eeze_suite.h"
START_TEST(eeze_test_eeze_init)
{
int ret;
ret = eeze_init();
fail_if(ret != 1);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
void eeze_test_init(TCase *tc)
{
tcase_add_test(tc, eeze_test_eeze_init);
}

View File

@ -0,0 +1,116 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Eeze.h>
#include <Eeze_Net.h>
#include "eeze_suite.h"
START_TEST(eeze_test_net_list)
{
int ret;
Eina_List *list = NULL;
ret = eeze_init();
fail_if(ret != 1);
list = eeze_net_list();
fail_if(list == NULL);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
START_TEST(eeze_test_net_attr)
{
int ret;
int idx = 0;
Eeze_Net *net = NULL;
const char *tmp = NULL;
ret = eeze_init();
fail_if(ret != 1);
net = eeze_net_new("lo");
fail_if(net == NULL);
tmp = eeze_net_mac_get(net);
fail_if(tmp == NULL);
tmp = NULL;
idx = eeze_net_idx_get(net);
fail_if(!idx);
eeze_net_scan(net);
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_attribute_get(net, "carrier");
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_syspath_get(net);
fail_if(tmp == NULL);
eeze_net_free(net);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
/*
#ifdef HAVE_IPV6
START_TEST(eeze_test_net_attr_ipv6)
{
int ret;
Eeze_Net *net = NULL;
const char *tmp = NULL;
ret = eeze_init();
fail_if(ret != 1);
net = eeze_net_new("lo");
fail_if(net == NULL);
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP6);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST6);
fail_if(tmp == NULL);
tmp = NULL;
tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK6);
fail_if(tmp == NULL);
eeze_net_free(net);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
#endif
*/
void eeze_test_net(TCase *tc)
{
tcase_add_test(tc, eeze_test_net_list);
tcase_add_test(tc, eeze_test_net_attr);
#ifdef HAVE_IPV6
//FIXME Figure out why we fail for the ipv6 tests here (code or test)
//tcase_add_test(tc, eeze_test_net_attr_ipv6);
#endif
}

View File

@ -0,0 +1,280 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Ecore.h>
#include <Eeze.h>
#include <Eeze_Sensor.h>
#include "eeze_suite.h"
#include "eeze_sensor_private.h"
static int cb_count = 0;
static Eina_Bool
event_cb(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
{
Eeze_Sensor_Obj *sens = NULL;
int acc;
double timestamp;
Eina_Bool rc = EINA_FALSE;
sens = event;
fail_if(sens == NULL);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
/* We expect 5 callbacks from async reads right now */
if (++cb_count == 5)
ecore_main_loop_quit();
return ECORE_CALLBACK_DONE;
}
START_TEST(eeze_test_sensor_read)
{
Eeze_Sensor_Obj *sens = NULL;
int ret = 0;
float x, y, z;
int acc;
double timestamp;
Eina_Bool rc = EINA_FALSE;
ecore_init();
ret = eeze_init();
fail_if(ret != 1);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
fail_if(rc == EINA_FALSE);
/* Use gyro with xy here even if it offers xzy */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_xy_get(sens, &x, &y);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_x_get(sens, &x);
fail_if(rc == EINA_FALSE);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
rc = eeze_sensor_read(sens);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_accuracy_get(sens, &acc);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_timestamp_get(sens, &timestamp);
fail_if(rc == EINA_FALSE);
rc = eeze_sensor_x_get(sens, &x);
fail_if(rc == EINA_FALSE);
/* Call non existing type */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LAST + 1);
fail_if(sens != NULL);
/* Give NULL as sensor object */
rc = eeze_sensor_read(NULL);
fail_if(rc != EINA_FALSE);
/* Change sensor type after creation but before read */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST + 1;
rc = eeze_sensor_read(sens);
fail_if(rc != EINA_FALSE);
/* Try to read from a type you can't read from */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST;
rc = eeze_sensor_read(sens);
fail_if(rc != EINA_FALSE);
/* Try all getter functions with a NULL sensor object */
rc = eeze_sensor_xyz_get(NULL, &x, &y, &z);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_xy_get(NULL, &x, &y);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_x_get(NULL, &x);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_accuracy_get(NULL, &acc);
fail_if(rc != EINA_FALSE);
rc = eeze_sensor_timestamp_get(NULL, &timestamp);
fail_if(rc != EINA_FALSE);
eeze_sensor_free(sens);
/* Try free on NULL */
eeze_sensor_free(NULL);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
START_TEST(eeze_test_sensor_async_read)
{
Ecore_Event_Handler *handler;
Eeze_Sensor_Obj *sens = NULL;
int ret = 0;
Eina_Bool rc = EINA_FALSE;
ecore_init();
ret = eeze_init();
fail_if(ret != 1);
handler = ecore_event_handler_add(EEZE_SENSOR_EVENT_ACCELEROMETER, event_cb, NULL);
fail_if(handler == NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_MAGNETIC, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_ORIENTATION, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_GYROSCOPE, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_PROXIMITY, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
ecore_event_handler_add(EEZE_SENSOR_EVENT_LIGHT, event_cb, NULL);
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc == EINA_FALSE);
/* Error case */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LAST + 1);
fail_if(sens != NULL);
rc = eeze_sensor_async_read(NULL, NULL);
fail_if(rc != EINA_FALSE);
/* Change sensor type after creation but before read */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST + 1;
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc != EINA_FALSE);
/* Try to read from a type you can't read from */
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
fail_if(sens == NULL);
sens->type = EEZE_SENSOR_TYPE_LAST;
rc = eeze_sensor_async_read(sens, NULL);
fail_if(rc != EINA_FALSE);
ecore_main_loop_begin();
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
START_TEST(eeze_test_sensor_obj_get)
{
Eeze_Sensor_Obj *obj = NULL, *obj_tmp = NULL;
int ret = 0;
ecore_init();
ret = eeze_init();
fail_if(ret != 1);
obj = calloc(1, sizeof(Eeze_Sensor_Obj));
fail_if(obj == NULL);
obj_tmp = obj;
obj = eeze_sensor_obj_get(EEZE_SENSOR_TYPE_ACCELEROMETER);
fail_if(obj == obj_tmp);
free(obj);
/* Try to get non existing obj */
obj_tmp = eeze_sensor_obj_get(EEZE_SENSOR_TYPE_LAST + 1);
fail_if(obj_tmp != NULL);
ret = eeze_shutdown();
fail_if(ret != 0);
}
END_TEST
void eeze_test_sensor(TCase *tc)
{
tcase_add_test(tc, eeze_test_sensor_read);
tcase_add_test(tc, eeze_test_sensor_async_read);
tcase_add_test(tc, eeze_test_sensor_obj_get);
}

View File

@ -0,0 +1,254 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Ecore.h>
#include <Eeze.h>
#include "eeze_suite.h"
/* #include "eeze_udev_private.h" */
static void
catch_events(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED,
void *data EINA_UNUSED, Eeze_Udev_Watch *watch EINA_UNUSED)
{
}
#if 0
// FIXME split udev tests into pieces here
START_TEST(eeze_test_udev_types)
{
Eina_List *type;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NONE, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_CDROM, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_AC, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_BAT, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BLUETOOTH, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
type = eeze_udev_find_unlisted_similar(type);
type = eeze_udev_find_by_type(0, NULL);
type = eeze_udev_find_unlisted_similar(type);
eeze_shutdown();
}
END_TEST
#endif
START_TEST(eeze_test_udev_watch)
{
Eeze_Udev_Watch *watch;
ecore_init();
eeze_init();
/* watch never gets triggered as this is run without user interaction */
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_DRIVE_INTERNAL, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_POWER_AC, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NET, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_V4L, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_BLUETOOTH, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NONE, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
eeze_udev_watch_del(watch);
eeze_shutdown();
ecore_shutdown();
}
END_TEST
START_TEST(eeze_test_udev_syspath)
{
Eina_List *type, *l;
const char *name;
Eina_Bool r;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
eeze_udev_syspath_get_devpath(name);
eeze_udev_find_similar_from_syspath(name);
eeze_udev_find_similar_from_syspath(NULL);
eeze_udev_syspath_get_parent(name);
eeze_udev_syspath_get_parent(NULL);
eeze_udev_syspath_get_parents(name);
eeze_udev_syspath_get_parents(NULL);
eeze_udev_syspath_get_devname(name);
eeze_udev_syspath_get_devname(NULL);
eeze_udev_syspath_get_subsystem(name);
eeze_udev_syspath_get_sysattr(name, "manufacturer");
eeze_udev_syspath_is_mouse(name);
eeze_udev_syspath_is_kbd(name);
eeze_udev_syspath_is_touchpad(name);
eeze_udev_syspath_is_joystick(name);
eeze_udev_walk_get_sysattr(name, "manufacturer");
eeze_udev_find_by_sysattr("manufacturer", NULL);
eeze_udev_find_by_sysattr(NULL, NULL);
eeze_udev_walk_check_sysattr(name, "manufacturer", NULL);
eeze_udev_walk_check_sysattr(name, "manufacturer", "foo");
eeze_udev_walk_get_sysattr(NULL, "manufacturer");
eeze_udev_walk_get_sysattr(name, NULL);
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
r = eeze_udev_syspath_is_mouse(name);
fail_unless(r);
eeze_udev_syspath_is_touchpad(name);
eeze_udev_syspath_is_joystick(name);
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
r = eeze_udev_syspath_is_touchpad(name);
fail_unless(r);
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FOREACH(type, l, name)
{
r = eeze_udev_syspath_is_joystick(name);
fail_unless(r);
}
eeze_udev_devpath_get_syspath("/dev/null");
eeze_shutdown();
}
END_TEST
START_TEST(eeze_test_udev_attr)
{
Eina_List *type;
const char *name, *check, *check2;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
type = eeze_udev_find_unlisted_similar(type);
eeze_udev_find_by_filter("backlight", NULL, NULL);
eeze_udev_find_by_filter(NULL, NULL, NULL);
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
check = eeze_udev_syspath_get_property(name, "INTERFACE");
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
check = eeze_udev_syspath_get_property(name, "ID_SERIAL");
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
if ((check = eeze_udev_syspath_get_sysattr(name, "model")))
{
check2 = eeze_udev_syspath_get_subsystem(name);
}
}
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
type = eeze_udev_find_unlisted_similar(type);
EINA_LIST_FREE(type, name)
{
if ((check = eeze_udev_syspath_get_property(name, "DEVNAME")))
{
if ((check2 = eeze_udev_syspath_get_sysattr(name, "name")))
{
eina_stringshare_del(check2);
}
eina_stringshare_del(check);
}
eina_stringshare_del(name);
}
eeze_shutdown();
}
END_TEST
/*
START_TEST(eeze_test_udev_device)
{
Eina_List *type, *l;
_udev_device *device, *device2;
const char *name;
eeze_init();
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
fail_if(type == NULL);
type = eeze_udev_find_unlisted_similar(type);
fail_if(type == NULL);
EINA_LIST_FOREACH(type, l, name)
{
device = _new_device(name);
fail_if(device == NULL);
_walk_parents_get_attr(device, "FOO", EINA_FALSE);
_walk_parents_get_attr(device, "FOO", EINA_TRUE);
_walk_children_get_attr(name, "FOO", "BAR", EINA_FALSE);
_walk_children_get_attr(name, "FOO", "BAR", EINA_TRUE);
}
device = _new_device("Wrong path");
fail_if(device != NULL);
device2 = _copy_device(device);
fail_if(device2 != NULL);
eeze_shutdown();
}
END_TEST
*/
void eeze_test_udev(TCase *tc)
{
//FIXME This also fails all the time. Enable this once we verify it's not completely useless
//tcase_add_test(tc, eeze_test_udev_types);
tcase_add_test(tc, eeze_test_udev_watch);
tcase_add_test(tc, eeze_test_udev_syspath);
tcase_add_test(tc, eeze_test_udev_attr);
//FIXME Tested functions here are hidden (not EAPI) and thus can not be tested like this with
//-fvisibility=hidden turned on.
//tcase_add_test(tc, eeze_test_udev_device);
}

117
src/tests/efl_check.h Normal file
View File

@ -0,0 +1,117 @@
#ifndef EFL_CHECK_H
#define EFL_CHECK_H
#include <stdlib.h> /* getenv */
#include <stdio.h> /* fprintf, fputs */
#include <string.h> /* strcmp */
typedef struct _Efl_Test_Case Efl_Test_Case;
struct _Efl_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static void
_efl_tests_list(const Efl_Test_Case *etc)
{
const Efl_Test_Case *itr = etc;
fputs("Available Test Cases:\n", stderr);
for (; itr->test_case; itr++)
fprintf(stderr, "\t%s\n", itr->test_case);
}
static int
_efl_test_option_disp(int argc, char **argv, const Efl_Test_Case *etc)
{
int i;
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]);
_efl_tests_list(etc);
return 0;
}
else if ((strcmp(argv[i], "-l") == 0) ||
(strcmp(argv[i], "--list") == 0))
{
_efl_tests_list(etc);
return 0;
}
}
return 1;
}
static int
_efl_test_use(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 int
_efl_test_fork_has(SRunner *sr)
{
if (srunner_fork_status(sr) == CK_FORK)
return 1;
else if (srunner_fork_status(sr) == CK_NOFORK)
return 0;
else if (srunner_fork_status(sr) == CK_FORK_GETENV)
{
char *res;
res = getenv("CF_FORK");
if (res && (strcmp(res, "no") == 0))
return 0;
else
return 1;
}
/* should never get there */
return 0;
}
static int
_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc)
{
Suite *s;
SRunner *sr;
TCase *tc;
int i, failed_count;
s = suite_create(suite_name);
sr = srunner_create(s);
for (i = 0; etc[i].test_case; ++i)
{
if (!_efl_test_use(argc, argv, etc[i].test_case))
continue;
tc = tcase_create(etc[i].test_case);
if (_efl_test_fork_has(sr))
tcase_set_timeout(tc, 0);
etc[i].build(tc);
suite_add_tcase(s, tc);
}
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;
}
#endif

View File

@ -1,13 +1,12 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <Ecore.h>
#include "Efreet.h"
#include <Ecore.h>
#include <Efreet.h>
#include "ef_test.h"
#if 0

View File

@ -1,15 +1,13 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#include <Ecore_File.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <Ecore_File.h>
#include <Efreet.h>
int
ef_cb_efreet_data_home(void)

View File

@ -1,16 +1,15 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <Efreet.h>
#include "ef_test.h"
typedef struct

View File

@ -1,16 +1,15 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Efreet.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <Ecore.h>
#include <Ecore_File.h>
#include <Efreet.h>
#define SIZE 128
#define THEME "Tango"

View File

@ -1,14 +1,13 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <Efreet.h>
#include "ef_test.h"
int

View File

@ -1,16 +1,15 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#define EFREET_MODULE_LOG_DOM /* no logging in this file */
#include "efreet_private.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Efreet.h>
#define EFREET_MODULE_LOG_DOM /* no logging in this file */
#include "efreet_private.h"
int
ef_cb_locale(void)
{

View File

@ -1,13 +1,12 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include <Efreet.h>
#include "ef_test.h"
#if 0

View File

@ -1,16 +1,15 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#include "Efreet_Mime.h"
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <Ecore.h>
#include <Efreet.h>
#include <Efreet_Mime.h>
#include "ef_test.h"
#define THEME "Tango"

View File

@ -1,8 +1,6 @@
#ifndef EF_TEST
#define EF_TEST
#include "config.h"
#include <eina_types.h>
#define IF_FREE(x) do { if (x) free(x); x = NULL; } while (0);

View File

@ -1,8 +1,11 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#include <stdio.h>
#include <Efreet.h>
int
ef_cb_utils(void)
{

View File

@ -1,6 +1,9 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <unistd.h>
#include <Eina.h>
#include <Ecore.h>
#include <Efreet.h>

View File

@ -1,10 +1,9 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <limits.h>
#include <stdio.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
@ -18,7 +17,7 @@
#define EFREET_MODULE_LOG_DOM /* no logging in this file */
#include "Efreet.h"
#include <Efreet.h>
#include "efreet_private.h"
#include "efreet_cache_private.h"

View File

@ -1,12 +1,11 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Efreet.h>
#include <stdio.h>
#include <limits.h>
#include <Efreet.h>
#include "ef_test.h"
static void dump(Efreet_Menu *menu, const char *path);

View File

@ -1,111 +1,28 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <Efreet.h>
#include "efreet_suite.h"
#include "../efl_check.h"
typedef struct _Efreet_Test_Case Efreet_Test_Case;
struct _Efreet_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static const Efreet_Test_Case etc[] = {
static const Efl_Test_Case etc[] = {
{ "Efreet", efreet_test_efreet },
{ "Efreet Cache", efreet_test_efreet_cache },
{ NULL, NULL }
};
static void
_list_tests(void)
{
const Efreet_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 *
efreet_suite_build(int argc, const char **argv)
{
TCase *tc;
Suite *s;
int i;
s = suite_create("Efreet");
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);
#ifndef _WIN32
tcase_set_timeout(tc, 0);
#endif
}
return s;
}
int
main(int argc, char **argv)
{
Suite *s;
SRunner *sr;
int i, failed_count;
int 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;
}
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv("EFL_RUN_IN_TREE=1");
s = efreet_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_NORMAL);
failed_count = srunner_ntests_failed(sr);
srunner_free(sr);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Efreet", etc);
return (failed_count == 0) ? 0 : 255;
}

View File

@ -1,5 +1,3 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -1,5 +1,3 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -1,5 +1,3 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -1,15 +1,17 @@
#include "config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Efreet.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Ecore.h>
#include <Efreet.h>
#include <Efreet_Mime.h>
/* no logging */
#define EFREET_MODULE_LOG_DOM
#include "efreet_private.h"
#include "Efreet_Mime.h"
#include "config.h"
#include <Ecore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int ef_cb_efreet_data_home(void);
int ef_cb_efreet_config_home(void);

View File

@ -20,19 +20,12 @@
# include "config.h"
#endif
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
#include <stdio.h>
#include <string.h>
#include "../efl_check.h"
typedef struct _Eina_Test_Case Eina_Test_Case;
struct _Eina_Test_Case
{
const char *test_case;
void (*build)(TCase *tc);
};
static const Eina_Test_Case etc[] = {
static const Efl_Test_Case etc[] = {
{ "FixedPoint", eina_test_fp },
{ "Inarray", eina_test_inarray },
{ "Array", eina_test_array },
@ -88,54 +81,6 @@ static const Eina_Test_Case etc[] = {
{ NULL, NULL }
};
static void
_list_tests(void)
{
const Eina_Test_Case *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;
}
Suite *
eina_build_suite(int argc, const char **argv)
{
TCase *tc;
Suite *s;
int i;
s = suite_create("Eina");
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);
#ifndef _WIN32
tcase_set_timeout(tc, 0);
#endif
etc[i].build(tc);
suite_add_tcase(s, tc);
}
return s;
}
/* FIXME this is a copy from eina_test_mempool
* we should remove the duplication
*/
@ -156,7 +101,7 @@ static void _mempool_shutdown(void)
{
unsigned int i;
Eina_Array_Iterator it;
Eina_Module *module;
Eina_Module *module;
eina_module_list_free(_modules);
if (_modules)
{
@ -170,38 +115,17 @@ static void _mempool_shutdown(void)
int
main(int argc, char **argv)
{
Suite *s;
SRunner *sr;
int i, failed_count;
int 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;
}
if (!_efl_test_option_disp(argc, argv, etc))
return 0;
putenv("EFL_RUN_IN_TREE=1");
s = eina_build_suite(argc - 1, (const char **)argv + 1);
sr = srunner_create(s);
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
_mempool_init();
srunner_run_all(sr, CK_ENV);
failed_count = srunner_ntests_failed(sr);
srunner_free(sr);
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
"Eina", etc);
_mempool_shutdown();

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static Eina_Bool
eina_accessor_check(EINA_UNUSED const Eina_Array *array,

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_array_simple)
{

View File

@ -22,8 +22,9 @@
#include <unistd.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static Eina_Thread wk1, wk2, wk3, wk4, wk5;
static Eina_Barrier barrier;

View File

@ -20,11 +20,12 @@
# include "config.h"
#endif
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_bezier_test_values)
{

View File

@ -21,8 +21,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(binbuf_simple)
{

View File

@ -25,8 +25,9 @@
#include <string.h>
#include <time.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
#define TEST0 "te\0st/0"
#define TEST0_SIZE 7

View File

@ -6,7 +6,8 @@
#include <string.h>
#include <assert.h>
#include "Eina.h"
#include <Eina.h>
#include "eina_suite.h"
Eina_Clist string_list = EINA_CLIST_INIT(string_list);

View File

@ -26,8 +26,9 @@
#include <float.h>
#include <limits.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_convert_simple)
{

View File

@ -23,10 +23,11 @@
#include <stdio.h>
#include <stdlib.h>
#include "eina_suite.h"
#include "Eina.h"
#include <Eina.h>
#include "eina_safety_checks.h"
#include "eina_suite.h"
#ifdef EINA_SAFETY_CHECKS
struct log_ctx {
const char *msg;

View File

@ -20,8 +20,9 @@
# include "config.h"
#endif
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
typedef struct _Eina_Cow_Test Eina_Cow_Test;
struct _Eina_Cow_Test

View File

@ -6,8 +6,9 @@
#include <stdio.h>
#include <string.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_crc_simple)
{

View File

@ -28,8 +28,9 @@
# include <Evil.h>
#endif
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
#define TEST_TEXT "The big test\n"

View File

@ -27,11 +27,12 @@
#include <unistd.h>
#include <fcntl.h>
#include "eina_suite.h"
#include "Eina.h"
#include <Eina.h>
#include "eina_safety_checks.h"
#include "eina_file_common.h"
#include "eina_suite.h"
#ifdef _WIN32
# define PATH_SEP_C '\\'
#else

View File

@ -20,11 +20,12 @@
# include "config.h"
#endif
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_fp_cos)
{

View File

@ -24,10 +24,11 @@
#include <stdio.h>
#include <string.h>
#include "eina_suite.h"
#include "Eina.h"
#include <Eina.h>
#include "eina_hash.h"
#include "eina_suite.h"
#define EINA_HASH_BUCKET_SIZE 8
static unsigned int

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_inarray_test_simple)
{

View File

@ -23,10 +23,11 @@
#include <stdlib.h>
#include <stdio.h>
#include "eina_suite.h"
#include "Eina.h"
#include <Eina.h>
#include "eina_safety_checks.h"
#include "eina_suite.h"
typedef struct _Eina_Test_Inlist Eina_Test_Inlist;
struct _Eina_Test_Inlist
{

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static Eina_Bool
eina_iterator_array_check(EINA_UNUSED const Eina_Array *array,

View File

@ -23,8 +23,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
typedef struct _Eina_Lazy_Allocator_Test Eina_Lazy_Allocator_Test;
struct _Eina_Lazy_Allocator_Test

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static Eina_Bool eina_list_sorted_check(const Eina_List *list)
{

View File

@ -22,8 +22,9 @@
#include <time.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
#ifdef __MACH__
# include <mach/clock.h>

View File

@ -24,8 +24,9 @@
#include <stdio.h>
#include <string.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
struct log_ctx {
int level;

View File

@ -26,10 +26,11 @@
#define EINA_MAGIC_DEBUG
#include "eina_suite.h"
#include "Eina.h"
#include <Eina.h>
#include "eina_safety_checks.h"
#include "eina_suite.h"
#define EINA_MAGIC_TEST 0x7781fee7
#define EINA_MAGIC_TEST2 0x42241664
#define EINA_MAGIC_STRING "Eina Magic Test"

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_simple)
{

View File

@ -22,11 +22,12 @@
#define DBL_EPSILON 0.0000001
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_matrix2)
{

View File

@ -4,8 +4,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
#define MAX_ROWS 10
#define MAX_COLS 10

View File

@ -20,8 +20,9 @@
# include "config.h"
#endif
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static Eina_Array *_modules;
@ -43,7 +44,7 @@ _mempool_shutdown(void)
{
unsigned int i;
Eina_Array_Iterator it;
Eina_Module *module;
Eina_Module *module;
eina_module_list_free(_modules);
if (_modules)
{
@ -191,5 +192,3 @@ eina_test_mempool(TCase *tc)
tcase_add_test(tc, eina_mempool_ememoa_unknown);
#endif
}

View File

@ -23,8 +23,9 @@
#include <stdio.h>
#include <inttypes.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static void
_eina_test_model_check_safety_null(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static Eina_Bool list_cb(Eina_Module *m, void *data EINA_UNUSED)
{

View File

@ -4,7 +4,7 @@
#include <stdio.h>
#include "Eina.h"
#include <Eina.h>
Eina_Bool dummy_module_init(void)
{

View File

@ -2,11 +2,12 @@
# include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <assert.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
START_TEST(eina_quad_simple)
{

View File

@ -20,11 +20,12 @@
# include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <assert.h>
#include <Eina.h>
#include "eina_suite.h"
#include "Eina.h"
static Eina_Quad_Direction
_eina_quadtree_rectangle_vert(const void *object, size_t middle)

Some files were not shown because too many files have changed in this diff Show More