tests/elm: add util function for detecting whether current test is forked

Summary:
this is useful for determining whether we can use extra hacks because nobody's
supervising our pointer (ab)use
Depends on D10568

Reviewers: cedric

Reviewed By: cedric

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10569
This commit is contained in:
Mike Blumenkrantz 2019-10-31 09:02:47 -04:00
parent e9e0f79956
commit 9c71ce2c00
2 changed files with 11 additions and 4 deletions

View File

@ -34,7 +34,7 @@ SUITE_INIT(elm)
void
_elm2_suite_init(void)
{
if (getpid() != main_pid)
if (is_forked())
{
if (abort_on_warnings)
fail_on_errors_setup();
@ -59,7 +59,7 @@ _elm_suite_shutdown(void)
/* verify that ecore was de-initialized completely */
ck_assert_int_eq(ecore_init(), 1);
/* avoid slowdowns in fork mode */
if (getpid() != main_pid) return;
if (is_forked()) return;
ck_assert_int_eq(ecore_shutdown(), 0);
}
@ -236,7 +236,7 @@ win_add(void)
evas_font_path_global_append(TEST_FONT_DIR);
font_path = EINA_TRUE;
}
if (getpid() != main_pid)
if (is_forked())
{
if (global_win) return global_win;
}
@ -261,7 +261,7 @@ win_add_focused()
{
Evas_Object *win;
if (getpid() != main_pid)
if (is_forked())
{
if (global_win) return global_win;
}
@ -271,6 +271,12 @@ win_add_focused()
return win;
}
Eina_Bool
is_forked(void)
{
return getpid() != main_pid;
}
int
suite_setup(Eina_Bool legacy)
{

View File

@ -11,6 +11,7 @@ void _elm_suite_shutdown(void);
void *real_timer_add(double in, Ecore_Task_Cb cb, void *data);
void fail_on_errors_teardown(void);
void fail_on_errors_setup(void);
Eina_Bool is_forked(void);
void get_me_to_those_events(Eo *obj);
void click_object(Eo *obj);