summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-06-03 16:59:55 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-06-03 17:00:12 -0700
commitb7facb2f0b684f168aa4b9565f9c7b8d42844252 (patch)
tree6bf6e2df1f14a659125d44cffdfb2adf2f3d3716 /src/tests
parent58c477a30a513b15f2c10e2e61bdb80018ef8fdb (diff)
ecore: add a test for detecting the double free problem.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/ecore/ecore_test_timer.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_timer.c b/src/tests/ecore/ecore_test_timer.c
index 25018bd99e..747e33ed6f 100644
--- a/src/tests/ecore/ecore_test_timer.c
+++ b/src/tests/ecore/ecore_test_timer.c
@@ -208,8 +208,43 @@ START_TEST(ecore_test_timeout)
208} 208}
209END_TEST 209END_TEST
210 210
211static void
212_ecore_promise_then(void *data EINA_UNUSED, void *value EINA_UNUSED)
213{
214 abort();
215}
216
217static void
218_ecore_promise_cancel(void *data, Eina_Error error)
219{
220 Eina_Bool *bob = data;
221
222 fail_if(error != EINA_ERROR_PROMISE_CANCEL);
223 *bob = EINA_TRUE;
224}
225
226START_TEST(ecore_test_timeout_cancel)
227{
228 Eina_Promise *timeout = NULL;
229 Eina_Bool bob = EINA_FALSE;
230 double start;
231
232 ecore_init();
233
234 start = ecore_time_get();
235 timeout = efl_loop_timeout(ecore_main_loop_get(), 0.2, &start);
236 eina_promise_then(timeout, &_ecore_promise_then, &_ecore_promise_cancel, &bob);
237 eina_promise_cancel(timeout);
238
239 fail_if(bob != EINA_TRUE);
240
241 ecore_shutdown();
242}
243END_TEST
244
211void ecore_test_timer(TCase *tc) 245void ecore_test_timer(TCase *tc)
212{ 246{
213 tcase_add_test(tc, ecore_test_timers); 247 tcase_add_test(tc, ecore_test_timers);
214 tcase_add_test(tc, ecore_test_timeout); 248 tcase_add_test(tc, ecore_test_timeout);
249 tcase_add_test(tc, ecore_test_timeout_cancel);
215} 250}