1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
#include "Efreet.h"
/* no logging */
#define EFREET_MODULE_LOG_DOM
#include "efreet_private.h"
#include "Efreet_Mime.h"
#include "config.h"
#include <Ecore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int ef_cb_efreet_data_home(void);
int ef_cb_efreet_config_home(void);
int ef_cb_efreet_cache_home(void);
int ef_cb_efreet_data_dirs(void);
int ef_cb_efreet_config_dirs(void);
int ef_cb_efreet_icon_theme(void);
int ef_cb_efreet_icon_theme_list(void);
int ef_cb_efreet_icon_match(void);
int ef_cb_ini_parse(void);
int ef_cb_ini_long_line(void);
int ef_cb_ini_garbage(void);
#if DEFAULT_VISIBILITY
int ef_cb_locale(void);
#endif
int ef_cb_desktop_parse(void);
int ef_cb_desktop_save(void);
int ef_cb_desktop_command_get(void);
int ef_cb_desktop_type_parse(void);
#if 0
int ef_cb_desktop_file_id(void);
#endif
int ef_cb_menu_get(void);
int ef_cb_menu_with_slashes(void);
int ef_cb_menu_save(void);
#if 0
int ef_cb_menu_edit(void);
#endif
int ef_cb_utils(void);
int ef_mime_cb_get(void);
typedef struct Efreet_Test Efreet_Test;
struct Efreet_Test
{
char *name;
int (*cb)(void);
};
static Efreet_Test tests[] = {
{"Data Home", ef_cb_efreet_data_home},
{"Config Home", ef_cb_efreet_config_home},
{"Cache Home", ef_cb_efreet_cache_home},
{"Data Directories", ef_cb_efreet_data_dirs},
{"Config Directories", ef_cb_efreet_config_dirs},
{"Icon Theme Basic", ef_cb_efreet_icon_theme},
{"Icon Theme List", ef_cb_efreet_icon_theme_list},
{"Icon Matching", ef_cb_efreet_icon_match},
{"INI Parsing", ef_cb_ini_parse},
{"INI Long Line Parsing", ef_cb_ini_long_line},
{"INI Garbage Parsing", ef_cb_ini_garbage},
#if DEFAULT_VISIBILITY
{"Locale Parsing", ef_cb_locale},
#endif
{"Desktop Parsing", ef_cb_desktop_parse},
{"Desktop Type Parsing", ef_cb_desktop_type_parse},
{"Desktop Save", ef_cb_desktop_save},
{"Desktop Command", ef_cb_desktop_command_get},
#if 0
{"Desktop File ID", ef_cb_desktop_file_id},
#endif
{"Menu Parsing", ef_cb_menu_get},
{"Menu Incorrect Names", ef_cb_menu_with_slashes},
{"Menu Save", ef_cb_menu_save},
#if 0
{"Menu Edit", ef_cb_menu_edit},
#endif
{"Utils", ef_cb_utils},
{"Mime", ef_mime_cb_get},
{NULL, NULL}
};
extern char **environ;
static Eina_List *environment = NULL;
void
environment_store(void)
{
char *env;
char **e;
#ifdef HAVE_CLEARENV
EINA_LIST_FREE(environment, env)
free(env);
for (e = environ; *e; e++)
environment = eina_list_append(environment, strdup(*e));
#endif
}
void
environment_restore(void)
{
Eina_List *l;
char *e;
if (!environment) return;
#ifdef HAVE_CLEARENV
clearenv();
EINA_LIST_FOREACH(environment, l, e)
putenv(e);
#endif
}
int
main(int argc, char ** argv)
{
int i, passed = 0, num_tests = 0;
Eina_List *run = NULL;
double total;
char *env;
eina_init();
ecore_init();
total = ecore_time_get();
if (argc > 1)
{
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-h")) ||
(!strcmp(argv[i], "--help")))
{
for (i = 0; tests[i].name; i++)
{
printf("%s\n", tests[i].name);
}
return 1;
}
run = eina_list_append(run, argv[i]);
}
}
efreet_cache_update = 0;
environment_store();
for (i = 0; tests[i].name; i++)
{
int ret;
double start;
/* we've been given specific tests and it isn't in the list */
if (run && !eina_list_search_unsorted(run, EINA_COMPARE_CB(strcasecmp),
tests[i].name))
continue;
if (!efreet_init())
{
printf("Error initializing Efreet\n");
continue;
}
num_tests ++;
printf("%s:\t\t", tests[i].name);
fflush(stdout);
start = ecore_time_get();
ret = tests[i].cb();
printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"),
ecore_time_get() - start);
passed += ret;
efreet_shutdown();
environment_restore();
}
printf("\n-----------------\n");
#ifdef HAVE_CLEARENV
clearenv();
EINA_LIST_FREE(environment, env)
free(env);
#endif
printf("Passed %d of %d tests.\n", passed, num_tests);
while (run)
run = eina_list_remove_list(run, run);
printf("Total run: %.3f seconds\n", ecore_time_get() - total);
ecore_shutdown();
eina_shutdown();
return 0;
}
|