summaryrefslogtreecommitdiff
path: root/src/tests/ector
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2016-02-04 14:20:04 +0100
committerTom Hacohen <tom@stosb.com>2016-02-16 12:41:06 +0000
commit401eba1b53f07fd01309f5798ecaea10f336b323 (patch)
treea61cbecbcd3972f132d88ea4446ca6f58f84b5e5 /src/tests/ector
parent563f616b7c0cf67ee546f0b2939e81f19fbea27a (diff)
Test rework #4: Ector
Diffstat (limited to 'src/tests/ector')
-rw-r--r--src/tests/ector/ector_suite.c84
-rw-r--r--src/tests/ector/ector_test_init.c4
2 files changed, 10 insertions, 78 deletions
diff --git a/src/tests/ector/ector_suite.c b/src/tests/ector/ector_suite.c
index fbae22c..fa491df 100644
--- a/src/tests/ector/ector_suite.c
+++ b/src/tests/ector/ector_suite.c
@@ -18,96 +18,28 @@
18 18
19#ifdef HAVE_CONFIG_H 19#ifdef HAVE_CONFIG_H
20# include <config.h> 20# include <config.h>
21#endif /* ifdef HAVE_CONFIG_H */ 21#endif
22
23#include <stdio.h>
24#include <string.h>
25
26#include <check.h>
27
28#include "Eina.h"
29 22
30#include "ector_suite.h" 23#include "ector_suite.h"
24#include "../efl_check.h"
31 25
32typedef struct _Ector_Test_Case Ector_Test_Case; 26static const Efl_Test_Case etc[] = {
33struct _Ector_Test_Case
34{
35 const char *test_case;
36 void (*build)(TCase *tc);
37};
38
39static const Ector_Test_Case etc[] = {
40 { "init", ector_test_init }, 27 { "init", ector_test_init },
41 { NULL, NULL } 28 { NULL, NULL }
42}; 29};
43 30
44static void
45_list_tests(void)
46{
47 const Ector_Test_Case *itr = etc;
48 fputs("Available Test Cases:\n", stderr);
49 for (; itr->test_case; itr++)
50 fprintf(stderr, "\t%s\n", itr->test_case);
51}
52
53static Eina_Bool
54_use_test(int argc, const char **argv, const char *test_case)
55{
56 if (argc < 1)
57 return 1;
58
59 for (; argc > 0; argc--, argv++)
60 if (strcmp(test_case, *argv) == 0)
61 return 1;
62
63 return 0;
64}
65
66int 31int
67main(int argc, char *argv[]) 32main(int argc, char *argv[])
68{ 33{
69 TCase *tc; 34 int failed_count;
70 Suite *s;
71 SRunner *sr;
72 int failed_count, i;
73 35
74 for (i = 1; i < argc; i++) 36 if (!_efl_test_option_disp(argc, argv, etc))
75 if ((strcmp(argv[i], "-h") == 0) || 37 return 0;
76 (strcmp(argv[i], "--help") == 0))
77 {
78 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
79 argv[0]);
80 _list_tests();
81 return 0;
82 }
83 else if ((strcmp(argv[i], "-l") == 0) ||
84 (strcmp(argv[i], "--list") == 0))
85 {
86 _list_tests();
87 return 0;
88 }
89 38
90 putenv("EFL_RUN_IN_TREE=1"); 39 putenv("EFL_RUN_IN_TREE=1");
91 40
92 s = suite_create("Ector"); 41 failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
93 42 "Ector", etc);
94 for (i = 0; etc[i].test_case; ++i)
95 {
96 if (!_use_test(argc - 1, (const char **) argv + 1, etc[i].test_case))
97 continue;
98
99 tc = tcase_create(etc[i].test_case);
100 tcase_set_timeout(tc, 0);
101
102 etc[i].build(tc);
103 suite_add_tcase(s, tc);
104 }
105
106 sr = srunner_create(s);
107 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
108 srunner_run_all(sr, CK_ENV);
109 failed_count = srunner_ntests_failed(sr);
110 srunner_free(sr);
111 43
112 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 44 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
113} 45}
diff --git a/src/tests/ector/ector_test_init.c b/src/tests/ector/ector_test_init.c
index 1c36e40..5194cbd 100644
--- a/src/tests/ector/ector_test_init.c
+++ b/src/tests/ector/ector_test_init.c
@@ -20,9 +20,9 @@
20# include "config.h" 20# include "config.h"
21#endif 21#endif
22 22
23#include "ector_suite.h" 23#include <Ector.h>
24 24
25#include "Ector.h" 25#include "ector_suite.h"
26 26
27START_TEST(ector_init_simple) 27START_TEST(ector_init_simple)
28{ 28{