diff options
author | Olliver Schinagl <oliver@schinagl.nl> | 2015-01-24 13:53:43 (GMT) |
---|---|---|
committer | Olliver Schinagl <oliver@schinagl.nl> | 2015-01-24 14:18:21 (GMT) |
commit | 08cfb908c22c0c7b5aeb788569950718939b7465 (patch) | |
tree | 6602640dc6b8dafaa3605d9cc3e955e66581d1e9 /src | |
parent | e13c3bc4aeba38f4f70754d8e73985eafb23a290 (diff) | |
download | eulogium-08cfb908c22c0c7b5aeb788569950718939b7465.zip eulogium-08cfb908c22c0c7b5aeb788569950718939b7465.tar.gz eulogium-08cfb908c22c0c7b5aeb788569950718939b7465.tar.bz2 |
EFL empty project
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/bin/Makefile.am | 19 | ||||
-rw-r--r-- | src/bin/eulogium_main.c | 118 | ||||
-rw-r--r-- | src/bin/eulogium_private.h | 6 | ||||
-rw-r--r-- | src/bin/gettext.h | 280 | ||||
-rw-r--r-- | src/lib/Eulogium.h | 111 | ||||
-rw-r--r-- | src/lib/Makefile.am | 18 | ||||
-rw-r--r-- | src/lib/eulogium.c | 64 | ||||
-rw-r--r-- | src/lib/eulogium_private.h | 27 | ||||
-rw-r--r-- | src/tests/Makefile.am | 17 | ||||
-rw-r--r-- | src/tests/test_eulogium.c | 124 |
11 files changed, 788 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..15871c9 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,4 @@ +MAINTAINERCLEANFILES = Makefile.in + +SUBDIRS = lib bin tests + diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am new file mode 100644 index 0000000..589f68d --- /dev/null +++ b/src/bin/Makefile.am @@ -0,0 +1,19 @@ +MAINTAINERCLEANFILES = Makefile.in + +bin_PROGRAMS = eulogium + +AM_CPPFLAGS = -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +-I$(top_builddir)/src/bin/ \ +-I$(top_srcdir)/src/bin/ \ +-I$(top_builddir)/src/lib/ \ +-I$(top_srcdir)/src/lib/ \ +@EFL_CFLAGS@ + +eulogium_SOURCES = eulogium_main.c +eulogium_LDADD = @EFL_LIBS@ $(top_builddir)/src/lib/libeulogium.la + +localedir = $(datadir)/locale +DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ + +EXTRA_DIST = eulogium_private.h + diff --git a/src/bin/eulogium_main.c b/src/bin/eulogium_main.c new file mode 100644 index 0000000..b8a83e1 --- /dev/null +++ b/src/bin/eulogium_main.c @@ -0,0 +1,118 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +/* NOTE: Respecting header order is important for portability. + * Always put system first, then EFL, then your public header, + * and finally your private one. */ + +#include <Ecore_Getopt.h> +#include <Elementary.h> + +#include "gettext.h" + +#include "Eulogium.h" + +#include "eulogium_private.h" + +#define COPYRIGHT "Copyright © 2013 oliver <o.schinagl@ultimaker.com> and various contributors (see AUTHORS)." + +static void +_eulogium_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + elm_exit(); +} + +static Evas_Object * +eulogium_win_setup(void) +{ + Evas_Object *win; + Evas_Object *label; + + win = elm_win_util_standard_add("main", "Eulogium"); + if (!win) return NULL; + + elm_win_focus_highlight_enabled_set(win, EINA_TRUE); + evas_object_smart_callback_add(win, "delete,request", _eulogium_win_del, NULL); + + label = elm_label_add(win); + elm_object_text_set(label, " Hello World !"); + evas_object_size_hint_weight_set(label, 0.0, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(label, 0.0, EVAS_HINT_FILL); + evas_object_show(label); + + elm_win_resize_object_add(win, label); + + evas_object_show(win); + + return win; +} + +static const Ecore_Getopt optdesc = { + "eulogium", + "%prog [options]", + PACKAGE_VERSION, + COPYRIGHT, + "BSD with advertisement clause", + "An EFL eulogium program", + 0, + { + ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + +EAPI_MAIN int +elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) +{ + Evas_Object *win; + int args; + Eina_Bool quit_option = EINA_FALSE; + + Ecore_Getopt_Value values[] = { + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_NONE + }; + +#if ENABLE_NLS + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + bind_textdomain_codeset(PACKAGE, "UTF-8"); + textdomain(PACKAGE); +#endif + + eulogium_init(); + + args = ecore_getopt_parse(&optdesc, values, argc, argv); + if (args < 0) + { + EINA_LOG_CRIT("Could not parse arguments."); + goto end; + } + else if (quit_option) + { + goto end; + } + + elm_app_info_set(elm_main, "eulogium", "images/eulogium.png"); + + if (!(win = eulogium_win_setup())) + goto end; + + eulogium_library_call(); + + elm_run(); + + end: + eulogium_shutdown(); + elm_shutdown(); + + return 0; +} +ELM_MAIN() diff --git a/src/bin/eulogium_private.h b/src/bin/eulogium_private.h new file mode 100644 index 0000000..aa968c6 --- /dev/null +++ b/src/bin/eulogium_private.h @@ -0,0 +1,6 @@ +#ifndef EULOGIUM_PRIVATE_H_ +# define EULOGIUM_PRIVATE_H_ + +// FIXME: put some private stuff related to your binary + +#endif diff --git a/src/bin/gettext.h b/src/bin/gettext.h new file mode 100644 index 0000000..e76b592 --- /dev/null +++ b/src/bin/gettext.h @@ -0,0 +1,280 @@ +/* Convenience header for conditional use of GNU <libintl.h>. + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 + +/* NLS can be disabled through the configure --disable-nls option. */ +#if ENABLE_NLS + +/* Get declarations of GNU message catalog functions. */ +# include <libintl.h> + +/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by + the gettext() and ngettext() macros. This is an alternative to calling + textdomain(), and is useful for libraries. */ +# ifdef DEFAULT_TEXT_DOMAIN +# undef gettext +# define gettext(Msgid) \ + dgettext (DEFAULT_TEXT_DOMAIN, Msgid) +# undef ngettext +# define ngettext(Msgid1, Msgid2, N) \ + dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) +# endif + +#else + +/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which + chokes if dcgettext is defined as a macro. So include it now, to make + later inclusions of <locale.h> a NOP. We don't include <libintl.h> + as well because people using "gettext.h" will not include <libintl.h>, + and also including <libintl.h> would fail on SunOS 4, whereas <locale.h> + is OK. */ +#if defined(__sun) +# include <locale.h> +#endif + +/* Many header files from the libstdc++ coming with g++ 3.3 or newer include + <libintl.h>, which chokes if dcgettext is defined as a macro. So include + it now, to make later inclusions of <libintl.h> a NOP. */ +#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) +# include <cstdlib> +# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H +# include <libintl.h> +# endif +#endif + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# undef gettext +# define gettext(Msgid) ((const char *) (Msgid)) +# undef dgettext +# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) +# undef dcgettext +# define dcgettext(Domainname, Msgid, Category) \ + ((void) (Category), dgettext (Domainname, Msgid)) +# undef ngettext +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 \ + ? ((void) (Msgid2), (const char *) (Msgid1)) \ + : ((void) (Msgid1), (const char *) (Msgid2))) +# undef dngettext +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) +# undef dcngettext +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N)) +# undef textdomain +# define textdomain(Domainname) ((const char *) (Domainname)) +# undef bindtextdomain +# define bindtextdomain(Domainname, Dirname) \ + ((void) (Domainname), (const char *) (Dirname)) +# undef bind_textdomain_codeset +# define bind_textdomain_codeset(Domainname, Codeset) \ + ((void) (Domainname), (const char *) (Codeset)) + +#endif + +/* A pseudo function call that serves as a marker for the automated + extraction of messages, but does not call gettext(). The run-time + translation is done at a different place in the code. + The argument, String, should be a literal string. Concatenated strings + and other string expressions won't work. + The macro's expansion is not parenthesized, so that it is suitable as + initializer for static 'char[]' or 'const char[]' variables. */ +#define gettext_noop(String) String + +/* The separator between msgctxt and msgid in a .mo file. */ +#define GETTEXT_CONTEXT_GLUE "\004" + +/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a + MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be + short and rarely need to change. + The letter 'p' stands for 'particular' or 'special'. */ +#ifdef DEFAULT_TEXT_DOMAIN +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#else +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#endif +#define dpgettext(Domainname, Msgctxt, Msgid) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) +#ifdef DEFAULT_TEXT_DOMAIN +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#else +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#endif +#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +pgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + int category) +{ + const char *translation = dcgettext (domain, msg_ctxt_id, category); + if (translation == msg_ctxt_id) + return msgid; + else + return translation; +} + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +npgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + const char *translation = + dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); + if (translation == msg_ctxt_id || translation == msgid_plural) + return (n == 1 ? msgid : msgid_plural); + else + return translation; +} + +/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID + can be arbitrary expressions. But for string literals these macros are + less efficient than those above. */ + +#include <string.h> + +#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ + (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ + /* || __STDC_VERSION__ >= 199901L */ ) + +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS +#include <stdlib.h> +#endif + +#define pgettext_expr(Msgctxt, Msgid) \ + dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) +#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ + dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcgettext (domain, msg_ctxt_id, category); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (translation != msg_ctxt_id) + return translation; + } + return msgid; +} + +#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcnpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (!(translation == msg_ctxt_id || translation == msgid_plural)) + return translation; + } + return (n == 1 ? msgid : msgid_plural); +} + +#endif /* _LIBGETTEXT_H */ diff --git a/src/lib/Eulogium.h b/src/lib/Eulogium.h new file mode 100644 index 0000000..7ef7c0d --- /dev/null +++ b/src/lib/Eulogium.h @@ -0,0 +1,111 @@ +#ifndef EULOGIUM_H_ +# define EULOGIUM_H_ + +#include <Elementary.h> + +#ifdef EAPI +# undef EAPI +#endif + +#ifdef _WIN32 +# ifdef EFL_EULOGIUM_BUILD +# ifdef DLL_EXPORT +# define EAPI __declspec(dllexport) +# else +# define EAPI +# endif /* ! DLL_EXPORT */ +# else +# define EAPI __declspec(dllimport) +# endif /* ! EFL_EULOGIUM_BUILD */ +#else +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif +# else +# define EAPI +# endif +#endif /* ! _WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * @brief These routines are used for Eulogium library interaction. + */ + +/** + * @brief Init / shutdown functions. + * @defgroup Init Init / Shutdown + * + * @{ + * + * Functions of obligatory usage, handling proper initialization + * and shutdown routines. + * + * Before the usage of any other function, Eulogium should be properly + * initialized with @ref eulogium_init() and the last call to Eulogium's + * functions should be @ref eulogium_shutdown(), so everything will + * be correctly freed. + * + * Eulogium logs everything with Eina Log, using the "eulogium" log domain. + * + */ + +/** + * Initialize Eulogium. + * + * Initializes Eulogium, its dependencies and modules. Should be the first + * function of Eulogium to be called. + * + * @return The init counter value. + * + * @see eulogium_shutdown(). + * + * @ingroup Init + */ +EAPI int eulogium_init(void); + +/** + * Shutdown Eulogium + * + * Shutdown Eulogium. If init count reaches 0, all the internal structures will + * be freed. Any Eulogium library call after this point will leads to an error. + * + * @return Eulogium's init counter value. + * + * @see eulogium_init(). + * + * @ingroup Init + */ +EAPI int eulogium_shutdown(void); + +/** + * @} + */ + +/** + * @brief Main group API that wont do anything + * @defgroup Main Main + * + * @{ + * + * @brief A function that doesn't do any good nor any bad + * + * @ingroup Main + */ +EAPI void eulogium_library_call(void); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* EULOGIUM_H_ */ diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 0000000..56d5c22 --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,18 @@ +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +@EFL_CFLAGS@ \ +-DEFL_EFL_BUILD + +lib_LTLIBRARIES = libeulogium.la + +includes_HEADERS = Eulogium.h +includesdir = $(includedir)/eulogium-@VMAJ@ + +libeulogium_la_SOURCES = eulogium.c +libeulogium_la_LIBADD = @EFL_LIBS@ -lm +libeulogium_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ diff --git a/src/lib/eulogium.c b/src/lib/eulogium.c new file mode 100644 index 0000000..8e19356 --- /dev/null +++ b/src/lib/eulogium.c @@ -0,0 +1,64 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "Eulogium.h" + +#include "eulogium_private.h" + +static int _eulogium_init = 0; +int _eulogium_lib_log_dom = -1; + +EAPI int +eulogium_init(void) +{ + _eulogium_init++; + if (_eulogium_init > 1) return _eulogium_init; + + eina_init(); + + _eulogium_lib_log_dom = eina_log_domain_register("eulogium", EINA_COLOR_CYAN); + if (_eulogium_lib_log_dom < 0) + { + EINA_LOG_ERR("Eulogium can not create its log domain."); + goto shutdown_eina; + } + + // Put here your initialization logic of your library + + eina_log_timing(_eulogium_lib_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT); + + return _eulogium_init; + + shutdown_eina: + eina_shutdown(); + _eulogium_init--; + + return _eulogium_init; +} + +EAPI int +eulogium_shutdown(void) +{ + _eulogium_init--; + if (_eulogium_init != 0) return _eulogium_init; + + eina_log_timing(_eulogium_lib_log_dom, + EINA_LOG_STATE_START, + EINA_LOG_STATE_SHUTDOWN); + + // Put here your shutdown logic + + eina_log_domain_unregister(_eulogium_lib_log_dom); + _eulogium_lib_log_dom = -1; + + eina_shutdown(); + + return _eulogium_init; +} + +EAPI void +eulogium_library_call(void) +{ + INF("Not really doing anything useful."); +} diff --git a/src/lib/eulogium_private.h b/src/lib/eulogium_private.h new file mode 100644 index 0000000..ff03439 --- /dev/null +++ b/src/lib/eulogium_private.h @@ -0,0 +1,27 @@ +#ifndef EULOGIUM_PRIVATE_H +# define EULOGIUM_PRIVATE_H + +extern int _eulogium_lib_log_dom; + +#ifdef ERR +# undef ERR +#endif +#define ERR(...) EINA_LOG_DOM_ERR(_eulogium_lib_log_dom, __VA_ARGS__) +#ifdef INF +# undef INF +#endif +#define INF(...) EINA_LOG_DOM_INFO(_eulogium_lib_log_dom, __VA_ARGS__) +#ifdef WRN +# undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_eulogium_lib_log_dom, __VA_ARGS__) +#ifdef CRIT +# undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_eulogium_lib_log_dom, __VA_ARGS__) +#ifdef DBG +# undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_eulogium_lib_log_dom, __VA_ARGS__) + +#endif diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am new file mode 100644 index 0000000..8ae8c20 --- /dev/null +++ b/src/tests/Makefile.am @@ -0,0 +1,17 @@ + +if EFL_HAVE_TESTS + +check_PROGRAMS = eulogium_tests + +eulogium_tests_SOURCES = test_eulogium.c +eulogium_tests_CPPFLAGS = -I$(top_builddir)/src/lib/ \ +-DPACKAGE_TESTS_DIR=\"$(top_srcdir)/src/tests/\" \ +-DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)/src/tests/\" \ +@EFL_CFLAGS@ \ +@CHECK_CFLAGS@ +eulogium_tests_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libeulogium.la +eulogium_tests_DEPENDENCIES = $(top_builddir)/src/lib/libeulogium.la + +endif + +EXTRA_DIST = test_eulogium.c diff --git a/src/tests/test_eulogium.c b/src/tests/test_eulogium.c new file mode 100644 index 0000000..2fce00c --- /dev/null +++ b/src/tests/test_eulogium.c @@ -0,0 +1,124 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <Ecore_Getopt.h> +#include <check.h> + +#include "Eulogium.h" + +#define COPYRIGHT "Copyright © 2013 oliver <o.schinagl@ultimaker.com> and various contributors (see AUTHORS)." + +static void eulogium_test_basic(TCase *tc); + +static const struct { + const char *name; + void (*build)(TCase *tc); +} tests[] = { + { "basic", eulogium_test_basic } +}; + +START_TEST(eulogium_initialization) +{ + fail_if(eulogium_init() != 1); + + eulogium_library_call(); + + fail_if(eulogium_shutdown() != 0); +} +END_TEST + +static void +eulogium_test_basic(TCase *tc) +{ + tcase_add_test(tc, eulogium_initialization); +} + +static const Ecore_Getopt optdesc = { + "eulogium", + "%prog [options]", + PACKAGE_VERSION, + COPYRIGHT, + "BSD with advertisement clause", + "An EFL eulogium program", + 0, + { + ECORE_GETOPT_STORE_TRUE('l', "list", "list available tests"), + ECORE_GETOPT_STORE_STR('t', "test", "test to run"), + ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + +int +main(int argc EINA_UNUSED, char **argv EINA_UNUSED) +{ + Suite *s; + SRunner *sr; + TCase *tc = NULL; + char *test = NULL; + unsigned int i; + int failed_count = -1; + int args; + Eina_Bool quit_option = EINA_FALSE; + Eina_Bool list_option = EINA_FALSE; + + Ecore_Getopt_Value values[] = { + ECORE_GETOPT_VALUE_BOOL(list_option), + ECORE_GETOPT_VALUE_STR(test), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_NONE + }; + + eina_init(); + + args = ecore_getopt_parse(&optdesc, values, argc, argv); + if (args < 0) + { + EINA_LOG_CRIT("Could not parse arguments."); + goto end; + } + else if (quit_option) + { + goto end; + } + else if (list_option) + { + fprintf(stdout, "Available tests :\n"); + for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) + fprintf(stdout, "\t%s\n", tests[i].name); + goto end; + } + + s = suite_create("Eulogium"); + + for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) + { + if (test && strcmp(tests[i].name, test)) + continue ; + + tc = tcase_create(tests[i].name); + tcase_set_timeout(tc, 0); + + tests[i].build(tc); + suite_add_tcase(s, tc); + } + + sr = srunner_create(s); + srunner_set_xml(sr, PACKAGE_BUILD_DIR "/check-results.xml"); + + srunner_run_all(sr, CK_ENV); + failed_count = srunner_ntests_failed(sr); + srunner_free(sr); + + end: + eina_shutdown(); + + return (failed_count == 0) ? 0 : 255; +} |