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/tests | |
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/tests')
-rw-r--r-- | src/tests/Makefile.am | 17 | ||||
-rw-r--r-- | src/tests/test_eulogium.c | 124 |
2 files changed, 141 insertions, 0 deletions
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; +} |