summaryrefslogtreecommitdiff
path: root/src/tests/ecore
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-12 21:34:27 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-12 21:34:27 +0100
commit06160466e8c54fd31926f7102268a8a6afde537e (patch)
tree8803287a8502e666ee9f1762d850e9c9e978506c /src/tests/ecore
parentd6294fa22b88187e44391c1c8ca64b1ebdf14533 (diff)
Revert "Revert the env object because it's broken portability - please redo"
This reverts commit d6294fa22b88187e44391c1c8ca64b1ebdf14533.
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, 139 insertions, 2 deletions
diff --git a/src/tests/ecore/efl_app_suite.c b/src/tests/ecore/efl_app_suite.c
index b3be09915a..cd26e2d95e 100644
--- a/src/tests/ecore/efl_app_suite.c
+++ b/src/tests/ecore/efl_app_suite.c
@@ -9,7 +9,6 @@
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
13EFL_START_TEST(efl_app_test_efl_build_version) 12EFL_START_TEST(efl_app_test_efl_build_version)
14{ 13{
15 const Efl_Version *ver; 14 const Efl_Version *ver;
@@ -53,6 +52,7 @@ static const Efl_Test_Case etc[] = {
53 { "Promise", efl_app_test_promise_2 }, 52 { "Promise", efl_app_test_promise_2 },
54 { "Promise", efl_app_test_promise_3 }, 53 { "Promise", efl_app_test_promise_3 },
55 { "Promise", efl_app_test_promise_safety }, 54 { "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 29ed8f031f..3a66dcdfcf 100644
--- a/src/tests/ecore/efl_app_suite.h
+++ b/src/tests/ecore/efl_app_suite.h
@@ -11,5 +11,6 @@ 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);
14 15
15#endif /* _EFL_APP_SUITE_H */ 16#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
new file mode 100644
index 0000000000..63bad166a2
--- /dev/null
+++ b/src/tests/ecore/efl_app_test_env.c
@@ -0,0 +1,135 @@
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 4b46814bbe..e3b4f6c851 100644
--- a/src/tests/ecore/meson.build
+++ b/src/tests/ecore/meson.build
@@ -75,7 +75,8 @@ 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'
79] 80]
80 81
81efl_app_suite_deps = [m] 82efl_app_suite_deps = [m]