summaryrefslogtreecommitdiff
path: root/src/tests/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-16 10:55:27 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:20 +0100
commitdbe34d803c37a1e9b85b787fba4f6e015c66c134 (patch)
treed6adf49a97fa213fd2777f6b500664fbaedb6ea8 /src/tests/elua
parent7f05cfc0e6795f4dee66c0b9175c658f40d14ab4 (diff)
elua lib: add test suite
Diffstat (limited to 'src/tests/elua')
-rw-r--r--src/tests/elua/elua_lib.c21
-rw-r--r--src/tests/elua/elua_suite.c108
-rw-r--r--src/tests/elua/elua_suite.h9
3 files changed, 138 insertions, 0 deletions
diff --git a/src/tests/elua/elua_lib.c b/src/tests/elua/elua_lib.c
new file mode 100644
index 0000000000..702aed50fe
--- /dev/null
+++ b/src/tests/elua/elua_lib.c
@@ -0,0 +1,21 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include<Eina.h>
9#include "Elua.h"
10#include "elua_suite.h"
11
12/*START_TEST(test_name)
13{
14}
15END_TEST*/
16
17void elua_lib_test(TCase *tc)
18{
19 //tcase_add_test(tc, test_name);
20}
21
diff --git a/src/tests/elua/elua_suite.c b/src/tests/elua/elua_suite.c
new file mode 100644
index 0000000000..13a6df8f85
--- /dev/null
+++ b/src/tests/elua/elua_suite.c
@@ -0,0 +1,108 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include<Eina.h>
9#include "elua_suite.h"
10
11typedef struct _Elua_Test_Case Elua_Test_Case;
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},
21 { NULL, NULL }
22};
23
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
73main(int argc, char **argv)
74{
75 Suite *s;
76 SRunner *sr;
77 int i, failed_count;
78 setenv("CK_FORK", "no", 0);
79
80 for (i = 1; i < argc; i++)
81 if ((strcmp(argv[i], "-h" ) == 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
96 putenv("EFL_RUN_IN_TREE=1");
97
98 s = elua_suite_build(argc - 1, (const char **)argv + 1);
99 sr = srunner_create(s);
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
107 return (failed_count == 0) ? 0 : 255;
108}
diff --git a/src/tests/elua/elua_suite.h b/src/tests/elua/elua_suite.h
new file mode 100644
index 0000000000..0d48d02617
--- /dev/null
+++ b/src/tests/elua/elua_suite.h
@@ -0,0 +1,9 @@
1#ifndef _ELUA_SUITE_H
2#define _ELUA_SUITE_H
3
4#include <check.h>
5
6void elua_lib_test(TCase *tc);
7
8#endif /* _ELUA_SUITE_H */
9