forked from enlightenment/efl
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
This commit is contained in:
parent
3d856e9600
commit
2d7e10363d
|
@ -536,7 +536,6 @@ AC_SUBST([SSE3_CFLAGS])
|
||||||
AC_CHECK_FUNCS([\
|
AC_CHECK_FUNCS([\
|
||||||
backtrace \
|
backtrace \
|
||||||
backtrace_symbols \
|
backtrace_symbols \
|
||||||
clearenv \
|
|
||||||
execvp \
|
execvp \
|
||||||
fpathconf \
|
fpathconf \
|
||||||
fstatat \
|
fstatat \
|
||||||
|
|
|
@ -72,11 +72,10 @@ static Efreet_Test tests[] = {
|
||||||
#endif
|
#endif
|
||||||
{"Utils", ef_cb_utils},
|
{"Utils", ef_cb_utils},
|
||||||
{"Mime", ef_mime_cb_get},
|
{"Mime", ef_mime_cb_get},
|
||||||
{NULL, NULL}
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
static Eina_List *environment = NULL;
|
|
||||||
|
|
||||||
const char *ef_test_path_get(const char *component)
|
const char *ef_test_path_get(const char *component)
|
||||||
{
|
{
|
||||||
|
@ -104,39 +103,12 @@ const char *ef_test_path_get(const char *component)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
int
|
||||||
main(int argc, char ** argv)
|
main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
int i, passed = 0, num_tests = 0;
|
int i, passed = 0, num_tests = 0;
|
||||||
Eina_List *run = NULL;
|
Eina_List *run = NULL;
|
||||||
double total;
|
double total;
|
||||||
char *env;
|
|
||||||
|
|
||||||
eina_init();
|
eina_init();
|
||||||
ecore_init();
|
ecore_init();
|
||||||
|
@ -160,7 +132,6 @@ main(int argc, char ** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
efreet_cache_update = 0;
|
efreet_cache_update = 0;
|
||||||
environment_store();
|
|
||||||
for (i = 0; tests[i].name; i++)
|
for (i = 0; tests[i].name; i++)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -182,21 +153,18 @@ main(int argc, char ** argv)
|
||||||
printf("%s:\t\t", tests[i].name);
|
printf("%s:\t\t", tests[i].name);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
start = ecore_time_get();
|
start = ecore_time_get();
|
||||||
|
|
||||||
|
environ = NULL;
|
||||||
ret = tests[i].cb();
|
ret = tests[i].cb();
|
||||||
|
|
||||||
printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"),
|
printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"),
|
||||||
ecore_time_get() - start);
|
ecore_time_get() - start);
|
||||||
passed += ret;
|
passed += ret;
|
||||||
|
|
||||||
efreet_shutdown();
|
efreet_shutdown();
|
||||||
environment_restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n-----------------\n");
|
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);
|
printf("Passed %d of %d tests.\n", passed, num_tests);
|
||||||
|
|
||||||
while (run)
|
while (run)
|
||||||
|
|
Loading…
Reference in New Issue