summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2013-02-20 17:49:50 +0900
committerCedric BAIL <cedric.bail@samsung.com>2013-02-20 17:50:19 +0900
commit1637e999317a07c5c7c26ebeed21fdd942cd432e (patch)
tree65a5c5c63e496668645b89ffbef3a1e40cc9871c
parentc5ade50c9f9a7297db69f47fc12787b266a76b41 (diff)
eina: make that test not depend on efl configuration.
-rw-r--r--src/tests/eina/eina_test_log.c159
1 files changed, 111 insertions, 48 deletions
diff --git a/src/tests/eina/eina_test_log.c b/src/tests/eina/eina_test_log.c
index f922281e66..fb9c06fd07 100644
--- a/src/tests/eina/eina_test_log.c
+++ b/src/tests/eina/eina_test_log.c
@@ -102,6 +102,7 @@ START_TEST(eina_log_macro)
102{ 102{
103 struct log_ctx ctx; 103 struct log_ctx ctx;
104 int oldlevel; 104 int oldlevel;
105 int maxlevel;
105 106
106 fail_if(!eina_init()); 107 fail_if(!eina_init());
107 108
@@ -116,25 +117,46 @@ START_TEST(eina_log_macro)
116 ctx.fnc = __FUNCTION__; \ 117 ctx.fnc = __FUNCTION__; \
117 ctx.did = EINA_FALSE 118 ctx.did = EINA_FALSE
118 119
119 TEST_LOG_CTX(EINA_LOG_LEVEL_CRITICAL, "Critical message"); 120#ifdef EINA_LOG_LEVEL_MAXIMUM
120 EINA_LOG_CRIT("Critical message"); 121 maxlevel = EINA_LOG_LEVEL_MAXIMUM;
121 fail_unless(ctx.did); 122#else
123 maxlevel = EINA_LOG_LEVEL_DBG;
124#endif
122 125
123 TEST_LOG_CTX(EINA_LOG_LEVEL_ERR, "An error"); 126 if (EINA_LOG_LEVEL_CRITICAL <= maxlevel)
124 EINA_LOG_ERR("An error"); 127 {
125 fail_unless(ctx.did); 128 TEST_LOG_CTX(EINA_LOG_LEVEL_CRITICAL, "Critical message");
129 EINA_LOG_CRIT("Critical message");
130 fail_unless(ctx.did);
131 }
126 132
127 TEST_LOG_CTX(EINA_LOG_LEVEL_WARN, "A warning"); 133 if (EINA_LOG_LEVEL_ERR <= maxlevel)
128 EINA_LOG_WARN("A warning"); 134 {
129 fail_unless(ctx.did); 135 TEST_LOG_CTX(EINA_LOG_LEVEL_ERR, "An error");
136 EINA_LOG_ERR("An error");
137 fail_unless(ctx.did);
138 }
130 139
131 TEST_LOG_CTX(EINA_LOG_LEVEL_INFO, "An info"); 140 if (EINA_LOG_LEVEL_WARN <= maxlevel)
132 EINA_LOG_INFO("An info"); 141 {
133 fail_unless(ctx.did); 142 TEST_LOG_CTX(EINA_LOG_LEVEL_WARN, "A warning");
143 EINA_LOG_WARN("A warning");
144 fail_unless(ctx.did);
145 }
134 146
135 TEST_LOG_CTX(EINA_LOG_LEVEL_DBG, "A debug"); 147 if (EINA_LOG_LEVEL_INFO <= maxlevel)
136 EINA_LOG_DBG("A debug"); 148 {
137 fail_unless(ctx.did); 149 TEST_LOG_CTX(EINA_LOG_LEVEL_INFO, "An info");
150 EINA_LOG_INFO("An info");
151 fail_unless(ctx.did);
152 }
153
154 if (EINA_LOG_LEVEL_DBG <= maxlevel)
155 {
156 TEST_LOG_CTX(EINA_LOG_LEVEL_DBG, "A debug");
157 EINA_LOG_DBG("A debug");
158 fail_unless(ctx.did);
159 }
138 160
139#undef TEST_LOG_CTX 161#undef TEST_LOG_CTX
140 162
@@ -149,6 +171,7 @@ START_TEST(eina_log_domains_macros)
149{ 171{
150 struct log_ctx ctx; 172 struct log_ctx ctx;
151 int oldlevel; 173 int oldlevel;
174 int maxlevel;
152 175
153 fail_if(!eina_init()); 176 fail_if(!eina_init());
154 177
@@ -171,25 +194,46 @@ START_TEST(eina_log_domains_macros)
171 ctx.dom = "MyDomain"; \ 194 ctx.dom = "MyDomain"; \
172 ctx.did = EINA_FALSE 195 ctx.did = EINA_FALSE
173 196
174 TEST_LOG_CTX(EINA_LOG_LEVEL_CRITICAL, "A critical message"); 197#ifdef EINA_LOG_LEVEL_MAXIMUM
175 EINA_LOG_DOM_CRIT(d, "A critical message"); 198 maxlevel = EINA_LOG_LEVEL_MAXIMUM;
176 fail_unless(ctx.did); 199#else
200 maxlevel = EINA_LOG_LEVEL_DBG;
201#endif
177 202
178 TEST_LOG_CTX(EINA_LOG_LEVEL_ERR, "An error"); 203 if (EINA_LOG_LEVEL_CRITICAL <= maxlevel)
179 EINA_LOG_DOM_ERR(d, "An error"); 204 {
180 fail_unless(ctx.did); 205 TEST_LOG_CTX(EINA_LOG_LEVEL_CRITICAL, "A critical message");
206 EINA_LOG_DOM_CRIT(d, "A critical message");
207 fail_unless(ctx.did);
208 }
181 209
182 TEST_LOG_CTX(EINA_LOG_LEVEL_WARN, "A warning"); 210 if (EINA_LOG_LEVEL_ERR <= maxlevel)
183 EINA_LOG_DOM_WARN(d, "A warning"); 211 {
184 fail_unless(ctx.did); 212 TEST_LOG_CTX(EINA_LOG_LEVEL_ERR, "An error");
213 EINA_LOG_DOM_ERR(d, "An error");
214 fail_unless(ctx.did);
215 }
185 216
186 TEST_LOG_CTX(EINA_LOG_LEVEL_INFO, "An info"); 217 if (EINA_LOG_LEVEL_WARN <= maxlevel)
187 EINA_LOG_DOM_INFO(d, "An info"); 218 {
188 fail_unless(ctx.did); 219 TEST_LOG_CTX(EINA_LOG_LEVEL_WARN, "A warning");
220 EINA_LOG_DOM_WARN(d, "A warning");
221 fail_unless(ctx.did);
222 }
189 223
190 TEST_LOG_CTX(EINA_LOG_LEVEL_DBG, "A debug"); 224 if (EINA_LOG_LEVEL_INFO <= maxlevel)
191 EINA_LOG_DOM_DBG(d, "A debug"); 225 {
192 fail_unless(ctx.did); 226 TEST_LOG_CTX(EINA_LOG_LEVEL_INFO, "An info");
227 EINA_LOG_DOM_INFO(d, "An info");
228 fail_unless(ctx.did);
229 }
230
231 if (EINA_LOG_LEVEL_DBG <= maxlevel)
232 {
233 TEST_LOG_CTX(EINA_LOG_LEVEL_DBG, "A debug");
234 EINA_LOG_DOM_DBG(d, "A debug");
235 fail_unless(ctx.did);
236 }
193 237
194#undef TEST_LOG_CTX 238#undef TEST_LOG_CTX
195 239
@@ -260,6 +304,7 @@ END_TEST
260START_TEST(eina_log_level_indexes) 304START_TEST(eina_log_level_indexes)
261{ 305{
262 struct log_ctx ctx; 306 struct log_ctx ctx;
307 int maxlevel;
263 308
264 fail_if(!eina_init()); 309 fail_if(!eina_init());
265 fail_if(!eina_threads_init()); 310 fail_if(!eina_threads_init());
@@ -278,27 +323,45 @@ START_TEST(eina_log_level_indexes)
278 ctx.dom = "Levels"; \ 323 ctx.dom = "Levels"; \
279 ctx.did = EINA_FALSE; 324 ctx.did = EINA_FALSE;
280 325
281 // Displayed unless user sets level lower than -1 326#ifdef EINA_LOG_LEVEL_MAXIMUM
282 eina_log_domain_level_set("Levels", -1); 327 maxlevel = EINA_LOG_LEVEL_MAXIMUM;
283 TEST_LOG_CTX(-1, "Negative index message"); 328#else
284 EINA_LOG(d, -1, "Negative index message"); 329 maxlevel = EINA_LOG_LEVEL_DBG;
285 fail_unless(ctx.did); 330#endif
286 331
287 eina_log_domain_level_set("Levels", -2); 332 if (-1 <= maxlevel)
288 TEST_LOG_CTX(-1, "Negative index message"); 333 {
289 EINA_LOG(d, -1, "Negative index message"); 334 // Displayed unless user sets level lower than -1
290 fail_if(ctx.did); 335 eina_log_domain_level_set("Levels", -1);
336 TEST_LOG_CTX(-1, "Negative index message");
337 EINA_LOG(d, -1, "Negative index message");
338 fail_unless(ctx.did);
339 }
291 340
292 // Displayed only if user sets level 6 or higher 341 if (-2 <= maxlevel)
293 eina_log_domain_level_set("Levels", 6); 342 {
294 TEST_LOG_CTX(6, "Higher level debug"); 343 eina_log_domain_level_set("Levels", -2);
295 EINA_LOG(d, 6, "Higher level debug"); 344 TEST_LOG_CTX(-1, "Negative index message");
296 fail_unless(ctx.did); 345 EINA_LOG(d, -1, "Negative index message");
346 fail_if(ctx.did);
347 }
348
349 if (6 <= maxlevel)
350 {
351 // Displayed only if user sets level 6 or higher
352 eina_log_domain_level_set("Levels", 6);
353 TEST_LOG_CTX(6, "Higher level debug");
354 EINA_LOG(d, 6, "Higher level debug");
355 fail_unless(ctx.did);
356 }
297 357
298 eina_log_domain_level_set("Levels", 5); 358 if (5 <= maxlevel)
299 TEST_LOG_CTX(6, "Higher level debug"); 359 {
300 EINA_LOG(d, 6, "Higher level debug"); 360 eina_log_domain_level_set("Levels", 5);
301 fail_if(ctx.did); 361 TEST_LOG_CTX(6, "Higher level debug");
362 EINA_LOG(d, 6, "Higher level debug");
363 fail_if(ctx.did);
364 }
302 365
303#undef TEST_LOG_CTX 366#undef TEST_LOG_CTX
304 367