summaryrefslogtreecommitdiff
path: root/src/tests/efreet/efreet_suite.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-29 23:04:40 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-29 23:04:40 +0000
commit4bc0210bd31ed1de6554441562bd93ea863ee9d9 (patch)
tree5d83be12538f8c8d3816bbf65916ce383d050c2e /src/tests/efreet/efreet_suite.c
parent727ddbeaf0c53f31cd62c254fdebe26823d537eb (diff)
efl: merge efreet.
seems to be fine, pass distcheck and friends. please report. changes: - documentation hierarchy fixes - replaced __UNUSED__ with EINA_UNUSED - replaced PKG_DATA_DIR with PACKAGE_DATA_DIR"/efreet" SVN revision: 81889
Diffstat (limited to 'src/tests/efreet/efreet_suite.c')
-rw-r--r--src/tests/efreet/efreet_suite.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/tests/efreet/efreet_suite.c b/src/tests/efreet/efreet_suite.c
new file mode 100644
index 0000000000..7424435b5f
--- /dev/null
+++ b/src/tests/efreet/efreet_suite.c
@@ -0,0 +1,103 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Efreet.h>
9
10#include "efreet_suite.h"
11
12typedef struct _Efreet_Test_Case Efreet_Test_Case;
13
14struct _Efreet_Test_Case
15{
16 const char *test_case;
17 void (*build)(TCase *tc);
18};
19
20static const Efreet_Test_Case etc[] = {
21 { "Efreet", efreet_test_efreet },
22 { "Efreet Cache", efreet_test_efreet_cache },
23 { NULL, NULL }
24};
25
26static void
27_list_tests(void)
28{
29 const Efreet_Test_Case *itr;
30
31 itr = etc;
32 fputs("Available Test Cases:\n", stderr);
33 for (; itr->test_case; itr++)
34 fprintf(stderr, "\t%s\n", itr->test_case);
35}
36
37static Eina_Bool
38_use_test(int argc, const char **argv, const char *test_case)
39{
40 if (argc < 1)
41 return 1;
42
43 for (; argc > 0; argc--, argv++)
44 if (strcmp(test_case, *argv) == 0)
45 return 1;
46 return 0;
47}
48
49static Suite *
50efreet_suite_build(int argc, const char **argv)
51{
52 TCase *tc;
53 Suite *s;
54 int i;
55
56 s = suite_create("Efreet");
57
58 for (i = 0; etc[i].test_case; ++i)
59 {
60 if (!_use_test(argc, argv, etc[i].test_case)) continue;
61 tc = tcase_create(etc[i].test_case);
62
63 etc[i].build(tc);
64
65 suite_add_tcase(s, tc);
66 tcase_set_timeout(tc, 0);
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
79 for (i = 1; i < argc; i++)
80 if ((strcmp(argv[i], "-h") == 0) ||
81 (strcmp(argv[i], "--help") == 0))
82 {
83 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
84 argv[0]);
85 _list_tests();
86 return 0;
87 }
88 else if ((strcmp(argv[i], "-l") == 0) ||
89 (strcmp(argv[i], "--list") == 0))
90 {
91 _list_tests();
92 return 0;
93 }
94
95 s = efreet_suite_build(argc - 1, (const char **)argv + 1);
96 sr = srunner_create(s);
97
98 srunner_run_all(sr, CK_NORMAL);
99 failed_count = srunner_ntests_failed(sr);
100 srunner_free(sr);
101
102 return (failed_count == 0) ? 0 : 255;
103}