2012-04-05 08:31:15 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
#include "Eo.h"
|
|
|
|
#include "eo_suite.h"
|
2012-04-05 08:31:15 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
typedef struct _Eo_Test_Case Eo_Test_Case;
|
2012-04-05 08:31:15 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
struct _Eo_Test_Case
|
2012-04-05 08:31:15 -07:00
|
|
|
{
|
|
|
|
const char *test_case;
|
|
|
|
void (*build)(TCase *tc);
|
|
|
|
};
|
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
static const Eo_Test_Case etc[] = {
|
|
|
|
{ "Eo init", eo_test_init },
|
|
|
|
{ "Eo general", eo_test_general },
|
|
|
|
{ "Eo class errors", eo_test_class_errors },
|
2013-04-24 08:45:34 -07:00
|
|
|
{ "Eo eina value", eo_test_value },
|
2012-04-05 08:31:15 -07:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_list_tests(void)
|
|
|
|
{
|
2012-05-01 00:40:14 -07:00
|
|
|
const Eo_Test_Case *itr;
|
2012-04-05 08:31:15 -07:00
|
|
|
|
|
|
|
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 *
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_suite_build(int argc, const char **argv)
|
2012-04-05 08:31:15 -07:00
|
|
|
{
|
|
|
|
TCase *tc;
|
|
|
|
Suite *s;
|
|
|
|
int i;
|
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
s = suite_create("Eo");
|
2012-04-05 08:31:15 -07:00
|
|
|
|
|
|
|
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;
|
2012-05-22 04:13:15 -07:00
|
|
|
eo_init();
|
|
|
|
setenv("CK_FORK", "no", 0);
|
2012-04-05 08:31:15 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-01-04 09:19:43 -08:00
|
|
|
putenv("EFL_RUN_IN_TREE=1");
|
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
s = eo_suite_build(argc - 1, (const char **)argv + 1);
|
2012-04-05 08:31:15 -07:00
|
|
|
sr = srunner_create(s);
|
|
|
|
|
2013-03-12 05:46:06 -07:00
|
|
|
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
2013-03-12 02:47:28 -07:00
|
|
|
|
2012-04-05 08:31:15 -07:00
|
|
|
srunner_run_all(sr, CK_ENV);
|
|
|
|
failed_count = srunner_ntests_failed(sr);
|
|
|
|
srunner_free(sr);
|
|
|
|
|
2012-05-22 04:13:15 -07:00
|
|
|
eo_shutdown();
|
|
|
|
|
2012-04-05 08:31:15 -07:00
|
|
|
return (failed_count == 0) ? 0 : 255;
|
|
|
|
}
|