forked from enlightenment/efl
Test rework #1: Ecore
Factorisation of the infra make uniform all the tests
This commit is contained in:
parent
0fa24ee175
commit
da98142de6
|
@ -2,22 +2,10 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Ecore.h>
|
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
#include "ecore_suite.h"
|
||||||
|
#include "../efl_check.h"
|
||||||
|
|
||||||
typedef struct _Ecore_Test_Case Ecore_Test_Case;
|
static const Efl_Test_Case etc[] = {
|
||||||
|
|
||||||
struct _Ecore_Test_Case
|
|
||||||
{
|
|
||||||
const char *test_case;
|
|
||||||
void (*build)(TCase *tc);
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Ecore_Test_Case etc[] = {
|
|
||||||
{ "Ecore", ecore_test_ecore },
|
{ "Ecore", ecore_test_ecore },
|
||||||
#if HAVE_ECORE_X
|
#if HAVE_ECORE_X
|
||||||
{ "Ecore_X", ecore_test_ecore_x },
|
{ "Ecore_X", ecore_test_ecore_x },
|
||||||
|
@ -41,84 +29,18 @@ static const Ecore_Test_Case etc[] = {
|
||||||
{ NULL, NULL }
|
{ 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
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Suite *s;
|
int failed_count;
|
||||||
SRunner *sr;
|
|
||||||
int i, failed_count;
|
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
if (!_efl_test_option_disp(argc, argv, etc))
|
||||||
if ((strcmp(argv[i], "-h") == 0) ||
|
return 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");
|
putenv("EFL_RUN_IN_TREE=1");
|
||||||
|
|
||||||
s = ecore_suite_build(argc - 1, (const char **)argv + 1);
|
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
|
||||||
sr = srunner_create(s);
|
"Ecore", etc);
|
||||||
|
|
||||||
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 == 0) ? 0 : 255;
|
return (failed_count == 0) ? 0 : 255;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
#include "ecore_suite.h"
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
static double prev = 0;
|
static double prev = 0;
|
||||||
static Eina_Bool _anim_cb(void *data EINA_UNUSED, double pos)
|
static Eina_Bool _anim_cb(void *data EINA_UNUSED, double pos)
|
||||||
|
|
|
@ -2,17 +2,15 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
#include <Ecore_Audio.h>
|
#include <Ecore_Audio.h>
|
||||||
#include <Ecore_File.h>
|
#include <Ecore_File.h>
|
||||||
|
|
||||||
#include "ecore_suite.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)
|
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;
|
Eina_Bool *pulse_context_failed = data;
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
|
||||||
#include <Ecore_File.h>
|
|
||||||
#include <Ecore.h>
|
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Ecore_File.h>
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
#include "ecore_suite.h"
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Ecore.h>
|
|
||||||
#include <Eina.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
#include "ecore_suite.h"
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
|
||||||
|
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#include "ecore_suite.h"
|
||||||
|
|
||||||
/* FIXME: Currently disable these tests. They are useless ATM and they just
|
/* 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
|
* make buildbot complain. Once we add useful tests here we'll also bother
|
||||||
* with getting X on the server. */
|
* with getting X on the server. */
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
#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 1;
|
||||||
|
}
|
||||||
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||||
|
(strcmp(argv[i], "--list") == 0))
|
||||||
|
{
|
||||||
|
_efl_tests_list(etc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in New Issue