summaryrefslogtreecommitdiff
path: root/src/tests/elua
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2016-02-04 14:57:14 +0100
committerTom Hacohen <tom@stosb.com>2016-02-16 12:41:06 +0000
commit9dcad9fd9ea0636ecad32ef44b03cd5c10c1d587 (patch)
treeb6e2bb6341320e1335f3523beb4f0e77d3212820 /src/tests/elua
parent7555493b909515fd2fa6c7f23ef7390578b32ac8 (diff)
Test rework #15: Elua
Diffstat (limited to 'src/tests/elua')
-rw-r--r--src/tests/elua/elua_lib.c5
-rw-r--r--src/tests/elua/elua_suite.c95
-rw-r--r--src/tests/elua/elua_suite.h1
3 files changed, 11 insertions, 90 deletions
diff --git a/src/tests/elua/elua_lib.c b/src/tests/elua/elua_lib.c
index ef043bab63..c6a5b6341f 100644
--- a/src/tests/elua/elua_lib.c
+++ b/src/tests/elua/elua_lib.c
@@ -5,8 +5,9 @@
5#include <stdlib.h> 5#include <stdlib.h>
6#include <stdio.h> 6#include <stdio.h>
7 7
8#include<Eina.h> 8#include <Eina.h>
9#include "Elua.h" 9#include <Elua.h>
10
10#include "elua_suite.h" 11#include "elua_suite.h"
11 12
12START_TEST(elua_api) 13START_TEST(elua_api)
diff --git a/src/tests/elua/elua_suite.c b/src/tests/elua/elua_suite.c
index 13a6df8f85..1bf0ec81c3 100644
--- a/src/tests/elua/elua_suite.c
+++ b/src/tests/elua/elua_suite.c
@@ -2,107 +2,28 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include<Eina.h>
9#include "elua_suite.h" 5#include "elua_suite.h"
6#include "../efl_check.h"
10 7
11typedef struct _Elua_Test_Case Elua_Test_Case; 8static const Efl_Test_Case etc[] = {
12
13struct _Elua_Test_Case
14{
15 const char *test_case;
16 void (*build)(TCase *tc);
17};
18
19static const Elua_Test_Case etc[] = {
20 { "Elua Library", elua_lib_test}, 9 { "Elua Library", elua_lib_test},
21 { NULL, NULL } 10 { NULL, NULL }
22}; 11};
23 12
24static void
25_list_tests(void)
26{
27 const Elua_Test_Case *itr;
28
29 itr = etc;
30 fputs("Available Test Cases:\n", stderr);
31 for (; itr->test_case; itr++)
32 fprintf(stderr, "\t%s\n", itr->test_case);
33}
34
35static Eina_Bool
36_use_test(int argc, const char **argv, const char *test_case)
37{
38 if (argc < 1)
39 return 1;
40
41 for (; argc > 0; argc--, argv++)
42 if (strcmp(test_case, *argv) == 0)
43 return 1;
44 return 0;
45}
46
47static Suite *
48elua_suite_build(int argc, const char **argv)
49{
50 TCase *tc;
51 Suite *s;
52 int i;
53
54 s = suite_create("Elua");
55
56 for (i = 0; etc[i].test_case; ++i)
57 {
58 if (!_use_test(argc, argv, etc[i].test_case)) continue;
59 tc = tcase_create(etc[i].test_case);
60
61 etc[i].build(tc);
62
63 suite_add_tcase(s, tc);
64#ifndef _WIN32
65 tcase_set_timeout(tc, 0);
66#endif
67 }
68
69 return s;
70}
71
72int 13int
73main(int argc, char **argv) 14main(int argc, char **argv)
74{ 15{
75 Suite *s; 16 int failed_count;
76 SRunner *sr; 17
77 int i, failed_count;
78 setenv("CK_FORK", "no", 0); 18 setenv("CK_FORK", "no", 0);
79 19
80 for (i = 1; i < argc; i++) 20 if (!_efl_test_option_disp(argc, argv, etc))
81 if ((strcmp(argv[i], "-h" ) == 0) || 21 return 0;
82 (strcmp(argv[i], "--help") == 0))
83 {
84 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
85 argv[0]);
86 _list_tests();
87 return 0;
88 }
89 else if ((strcmp(argv[i], "-l" ) == 0) ||
90 (strcmp(argv[i], "--list") == 0))
91 {
92 _list_tests();
93 return 0;
94 }
95 22
96 putenv("EFL_RUN_IN_TREE=1"); 23 putenv("EFL_RUN_IN_TREE=1");
97 24
98 s = elua_suite_build(argc - 1, (const char **)argv + 1); 25 failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
99 sr = srunner_create(s); 26 "Elua", etc);
100
101 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
102
103 srunner_run_all(sr, CK_ENV);
104 failed_count = srunner_ntests_failed(sr);
105 srunner_free(sr);
106 27
107 return (failed_count == 0) ? 0 : 255; 28 return (failed_count == 0) ? 0 : 255;
108} 29}
diff --git a/src/tests/elua/elua_suite.h b/src/tests/elua/elua_suite.h
index 0d48d02617..7485f5346b 100644
--- a/src/tests/elua/elua_suite.h
+++ b/src/tests/elua/elua_suite.h
@@ -6,4 +6,3 @@
6void elua_lib_test(TCase *tc); 6void elua_lib_test(TCase *tc);
7 7
8#endif /* _ELUA_SUITE_H */ 8#endif /* _ELUA_SUITE_H */
9