summaryrefslogtreecommitdiff
path: root/src/tests/ecore
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-02-12 20:11:44 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-02-12 20:22:28 +0000
commitd6294fa22b88187e44391c1c8ca64b1ebdf14533 (patch)
tree793733796eda67fdbea1fde4c83023bf3fe7f579 /src/tests/ecore
parenta57c7f751023fe1d1edeabbf8683574ac7497e5e (diff)
Revert the env object because it's broken portability - please redo
setenv and unsetenv are not portable. i explained to you at fosdem there are issues and it's why i used putenv in the original implementation and even though it's a pain (the string tou pass to putenv is a pointer used literallt from there on in and you get it from getenv, thus making ownership a pain -this is a libc issue we can't readily solve). use putenv like the original code. then put it back in. vtorri now has windows porting issues with the setenv use. i knew there was a reason that still existed... in addition your in_sync stuff is broken. psuedocode: // assuming BLAGH env is not set to anything here c = efl_core_env_get(global_env, "BLAH"); ... putenv("BLAH=10"); ... c = efl_core_env_Get(global_env, "BLAH"); i will get NULL in both cases for c ... but i should get "10" for the 2nd in reality. reality is lots of code across application code and libraries will at times mess with the environment. it has to work with this. the prior implementation did work with this. Revert "ecore: here comes a env object" This reverts commit 2373d5db5b4cd5dfe139aa2a10017ef61b28b5ce. Revert "efl_task: remove env from this object" This reverts commit c3d69f66a69c0def357a5c373a13343e1c01ff5d.
Diffstat (limited to 'src/tests/ecore')
-rw-r--r--src/tests/ecore/efl_app_suite.c2
-rw-r--r--src/tests/ecore/efl_app_suite.h1
-rw-r--r--src/tests/ecore/efl_app_test_env.c135
-rw-r--r--src/tests/ecore/meson.build3
4 files changed, 2 insertions, 139 deletions
diff --git a/src/tests/ecore/efl_app_suite.c b/src/tests/ecore/efl_app_suite.c
index cd26e2d95e..b3be09915a 100644
--- a/src/tests/ecore/efl_app_suite.c
+++ b/src/tests/ecore/efl_app_suite.c
@@ -9,6 +9,7 @@
9#include "efl_app_suite.h" 9#include "efl_app_suite.h"
10#include "../efl_check.h" 10#include "../efl_check.h"
11 11
12
12EFL_START_TEST(efl_app_test_efl_build_version) 13EFL_START_TEST(efl_app_test_efl_build_version)
13{ 14{
14 const Efl_Version *ver; 15 const Efl_Version *ver;
@@ -52,7 +53,6 @@ static const Efl_Test_Case etc[] = {
52 { "Promise", efl_app_test_promise_2 }, 53 { "Promise", efl_app_test_promise_2 },
53 { "Promise", efl_app_test_promise_3 }, 54 { "Promise", efl_app_test_promise_3 },
54 { "Promise", efl_app_test_promise_safety }, 55 { "Promise", efl_app_test_promise_safety },
55 { "Env", efl_test_efl_env },
56 { NULL, NULL } 56 { NULL, NULL }
57}; 57};
58 58
diff --git a/src/tests/ecore/efl_app_suite.h b/src/tests/ecore/efl_app_suite.h
index 3a66dcdfcf..29ed8f031f 100644
--- a/src/tests/ecore/efl_app_suite.h
+++ b/src/tests/ecore/efl_app_suite.h
@@ -11,6 +11,5 @@ void efl_app_test_promise(TCase *tc);
11void efl_app_test_promise_2(TCase *tc); 11void efl_app_test_promise_2(TCase *tc);
12void efl_app_test_promise_3(TCase *tc); 12void efl_app_test_promise_3(TCase *tc);
13void efl_app_test_promise_safety(TCase *tc); 13void efl_app_test_promise_safety(TCase *tc);
14void efl_test_efl_env(TCase *tc);
15 14
16#endif /* _EFL_APP_SUITE_H */ 15#endif /* _EFL_APP_SUITE_H */
diff --git a/src/tests/ecore/efl_app_test_env.c b/src/tests/ecore/efl_app_test_env.c
deleted file mode 100644
index 63bad166a2..0000000000
--- a/src/tests/ecore/efl_app_test_env.c
+++ /dev/null
@@ -1,135 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdio.h>
6#include <unistd.h>
7#define EFL_NOLEGACY_API_SUPPORT
8#include <Efl_Core.h>
9#include "efl_app_suite.h"
10#include "../efl_check.h"
11
12EFL_START_TEST(efl_core_env_test_set_get)
13{
14 Efl_Core_Env *env = efl_add_ref(EFL_CORE_ENV_CLASS, NULL);
15
16 efl_core_env_set(env, "FOO", "bar");
17 efl_core_env_set(env, "going", "home");
18 efl_core_env_set(env, "Merry", "christmas");
19
20 ck_assert_str_eq(efl_core_env_get(env, "FOO"), "bar");
21 ck_assert_str_eq(efl_core_env_get(env, "going"), "home");
22 ck_assert_str_eq(efl_core_env_get(env, "Merry"), "christmas");
23
24 efl_core_env_unset(env, "Merry");
25
26 ck_assert_str_eq(efl_core_env_get(env, "FOO"), "bar");
27 ck_assert_str_eq(efl_core_env_get(env, "going"), "home");
28 ck_assert_ptr_eq(efl_core_env_get(env, "Merry"), NULL);
29
30 efl_unref(env);
31}
32EFL_END_TEST
33
34EFL_START_TEST(efl_core_env_test_invalid_keys)
35{
36 Efl_Core_Env *env = efl_add_ref(EFL_CORE_ENV_CLASS, NULL);
37
38#define CHECK(val) \
39 efl_core_env_set(env, val, "TEST"); \
40 ck_assert_ptr_eq(efl_core_env_get(env, val), NULL);
41
42 CHECK("0foo");
43 CHECK("foo bar");
44 CHECK("foo!bar");
45
46#undef CHECK
47
48
49#define CHECK(val) \
50 efl_core_env_set(env, val, "TEST"); \
51 ck_assert_str_eq(efl_core_env_get(env, val), "TEST");
52
53 CHECK("foo0");
54 CHECK("foo_bar");
55
56#undef CHECK
57
58}
59EFL_END_TEST
60
61EFL_START_TEST(efl_core_env_test_clear)
62{
63 Efl_Core_Env *env = efl_add_ref(EFL_CORE_ENV_CLASS, NULL);
64
65 efl_core_env_set(env, "FOO", "bar");
66 efl_core_env_set(env, "going", "home");
67 efl_core_env_set(env, "Merry", "christmas");
68
69 efl_core_env_clear(env);
70
71 ck_assert_ptr_eq(efl_core_env_get(env, "FOO"), NULL);
72 ck_assert_ptr_eq(efl_core_env_get(env, "going"), NULL);
73 ck_assert_ptr_eq(efl_core_env_get(env, "Merry"), NULL);
74
75 efl_unref(env);
76}
77EFL_END_TEST
78
79EFL_START_TEST(efl_core_env_test_fork)
80{
81 Efl_Core_Env *env_fork, *env = efl_add_ref(EFL_CORE_ENV_CLASS, NULL);
82
83 efl_core_env_set(env, "FOO", "bar");
84 efl_core_env_set(env, "going", "home");
85 efl_core_env_set(env, "Merry", "christmas");
86
87 env_fork = efl_duplicate(env);
88
89 ck_assert_str_eq(efl_core_env_get(env_fork, "FOO"), "bar");
90 ck_assert_str_eq(efl_core_env_get(env_fork, "going"), "home");
91 ck_assert_str_eq(efl_core_env_get(env_fork, "Merry"), "christmas");
92
93 efl_unref(env);
94}
95EFL_END_TEST
96
97EFL_START_TEST(efl_core_env_test_process)
98{
99 Efl_Core_Env *env_fork, *env = efl_env_self(EFL_CORE_PROC_ENV_CLASS);
100
101 ck_assert(env);
102
103 ck_assert_str_eq(efl_core_env_get(env, "PATH"), getenv("PATH"));
104 env_fork = efl_duplicate(env);
105 ck_assert_str_eq(efl_core_env_get(env_fork, "PATH"), getenv("PATH"));
106
107 efl_unref(env);
108}
109EFL_END_TEST
110
111EFL_START_TEST(efl_core_env_test_undepend_fork)
112{
113 Efl_Core_Env *env_fork, *env = efl_env_self(EFL_CORE_PROC_ENV_CLASS);
114
115 ck_assert(env);
116
117 ck_assert_str_eq(efl_core_env_get(env, "PATH"), getenv("PATH"));
118 env_fork = efl_duplicate(env);
119 efl_core_env_set(env_fork, "PATH", "abc");
120 ck_assert_str_eq(efl_core_env_get(env, "PATH"), getenv("PATH"));
121
122 efl_unref(env);
123 efl_unref(env_fork);
124}
125EFL_END_TEST
126
127void efl_test_efl_env(TCase *tc)
128{
129 tcase_add_test(tc, efl_core_env_test_set_get);
130 tcase_add_test(tc, efl_core_env_test_invalid_keys);
131 tcase_add_test(tc, efl_core_env_test_clear);
132 tcase_add_test(tc, efl_core_env_test_fork);
133 tcase_add_test(tc, efl_core_env_test_process);
134 tcase_add_test(tc, efl_core_env_test_undepend_fork);
135}
diff --git a/src/tests/ecore/meson.build b/src/tests/ecore/meson.build
index e3b4f6c851..4b46814bbe 100644
--- a/src/tests/ecore/meson.build
+++ b/src/tests/ecore/meson.build
@@ -75,8 +75,7 @@ efl_app_suite_src = [
75 'efl_app_test_loop.c', 75 'efl_app_test_loop.c',
76 'efl_app_test_loop_fd.c', 76 'efl_app_test_loop_fd.c',
77 'efl_app_test_loop_timer.c', 77 'efl_app_test_loop_timer.c',
78 'efl_app_test_promise.c', 78 'efl_app_test_promise.c'
79 'efl_app_test_env.c'
80] 79]
81 80
82efl_app_suite_deps = [m] 81efl_app_suite_deps = [m]