summaryrefslogtreecommitdiff
path: root/src/tests/efreet
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-14 21:04:22 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-14 21:04:22 +0000
commit2d7e10363d7d209a605329ba692a3e788b37dc68 (patch)
treebb3dacbf2857d97de7aba15b9ab9d7494798b6b4 /src/tests/efreet
parent3d856e9600bccf2610ad9b6f23a5ebb62a1aaf15 (diff)
efl/efreet: remove clearenv usage
This improves the tests on freebsd, which doesn't have clearenv() ( though this commit was untested on such environement). clearenv was rejected from POSIX so we better aim to stop its usage. However since tests use setenv() this may lead to leaks, but it's better a leak than a failing test. On Linux all tests that were passing continue to pass. SVN revision: 82779
Diffstat (limited to 'src/tests/efreet')
-rw-r--r--src/tests/efreet/main.c40
1 files changed, 4 insertions, 36 deletions
diff --git a/src/tests/efreet/main.c b/src/tests/efreet/main.c
index 0833744..8ba4f0a 100644
--- a/src/tests/efreet/main.c
+++ b/src/tests/efreet/main.c
@@ -72,11 +72,10 @@ static Efreet_Test tests[] = {
72#endif 72#endif
73 {"Utils", ef_cb_utils}, 73 {"Utils", ef_cb_utils},
74 {"Mime", ef_mime_cb_get}, 74 {"Mime", ef_mime_cb_get},
75 {NULL, NULL} 75 { }
76}; 76};
77 77
78extern char **environ; 78extern char **environ;
79static Eina_List *environment = NULL;
80 79
81const char *ef_test_path_get(const char *component) 80const char *ef_test_path_get(const char *component)
82{ 81{
@@ -104,39 +103,12 @@ const char *ef_test_path_get(const char *component)
104 return buf; 103 return buf;
105} 104}
106 105
107void
108environment_store(void)
109{
110 char *env;
111 char **e;
112#ifdef HAVE_CLEARENV
113 EINA_LIST_FREE(environment, env)
114 free(env);
115 for (e = environ; *e; e++)
116 environment = eina_list_append(environment, strdup(*e));
117#endif
118}
119
120void
121environment_restore(void)
122{
123 Eina_List *l;
124 char *e;
125 if (!environment) return;
126#ifdef HAVE_CLEARENV
127 clearenv();
128 EINA_LIST_FOREACH(environment, l, e)
129 putenv(e);
130#endif
131}
132
133int 106int
134main(int argc, char ** argv) 107main(int argc, char ** argv)
135{ 108{
136 int i, passed = 0, num_tests = 0; 109 int i, passed = 0, num_tests = 0;
137 Eina_List *run = NULL; 110 Eina_List *run = NULL;
138 double total; 111 double total;
139 char *env;
140 112
141 eina_init(); 113 eina_init();
142 ecore_init(); 114 ecore_init();
@@ -160,7 +132,6 @@ main(int argc, char ** argv)
160 } 132 }
161 133
162 efreet_cache_update = 0; 134 efreet_cache_update = 0;
163 environment_store();
164 for (i = 0; tests[i].name; i++) 135 for (i = 0; tests[i].name; i++)
165 { 136 {
166 int ret; 137 int ret;
@@ -182,21 +153,18 @@ main(int argc, char ** argv)
182 printf("%s:\t\t", tests[i].name); 153 printf("%s:\t\t", tests[i].name);
183 fflush(stdout); 154 fflush(stdout);
184 start = ecore_time_get(); 155 start = ecore_time_get();
156
157 environ = NULL;
185 ret = tests[i].cb(); 158 ret = tests[i].cb();
159
186 printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"), 160 printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"),
187 ecore_time_get() - start); 161 ecore_time_get() - start);
188 passed += ret; 162 passed += ret;
189 163
190 efreet_shutdown(); 164 efreet_shutdown();
191 environment_restore();
192 } 165 }
193 166
194 printf("\n-----------------\n"); 167 printf("\n-----------------\n");
195#ifdef HAVE_CLEARENV
196 clearenv();
197 EINA_LIST_FREE(environment, env)
198 free(env);
199#endif
200 printf("Passed %d of %d tests.\n", passed, num_tests); 168 printf("Passed %d of %d tests.\n", passed, num_tests);
201 169
202 while (run) 170 while (run)