2013-01-15 13:50:57 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
#include <Eldbus.h>
|
2013-01-15 13:50:57 -08:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
#include "eldbus_suite.h"
|
2013-01-15 13:50:57 -08:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
typedef struct _Eldbus_Test_Case Eldbus_Test_Case;
|
2013-01-15 13:50:57 -08:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
struct _Eldbus_Test_Case
|
2013-01-15 13:50:57 -08:00
|
|
|
{
|
|
|
|
const char *test_case;
|
|
|
|
void (*build)(TCase *tc);
|
|
|
|
};
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
static const Eldbus_Test_Case etc[] = {
|
|
|
|
{ "eldbus_init", eldbus_test_eldbus_init },
|
2013-01-15 13:50:57 -08:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_list_tests(void)
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
const Eldbus_Test_Case *itr;
|
2013-01-15 13:50:57 -08:00
|
|
|
|
|
|
|
itr = etc;
|
|
|
|
fputs("Available Test Cases:\n", stderr);
|
|
|
|
for (; itr->test_case; itr++)
|
|
|
|
printf("\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 *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_suite_build(int argc, const char **argv)
|
2013-01-15 13:50:57 -08:00
|
|
|
{
|
|
|
|
TCase *tc;
|
|
|
|
Suite *s;
|
|
|
|
int i;
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
s = suite_create("Eldbus");
|
2013-01-15 13:50:57 -08: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;
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
if ((strcmp(argv[i], "-h") == 0) ||
|
|
|
|
(strcmp(argv[i], "--help") == 0))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
|
|
|
|
argv[0]);
|
|
|
|
_list_tests();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
|
|
|
(strcmp(argv[i], "--list") == 0))
|
|
|
|
{
|
|
|
|
_list_tests();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
putenv("EFL_RUN_IN_TREE=1");
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
s = eldbus_suite_build(argc - 1, (const char **)argv + 1);
|
2013-01-15 13:50:57 -08: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
|
|
|
|
2013-01-15 13:50:57 -08:00
|
|
|
srunner_run_all(sr, CK_ENV);
|
|
|
|
failed_count = srunner_ntests_failed(sr);
|
|
|
|
srunner_free(sr);
|
|
|
|
|
|
|
|
return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|