tests/elm: add util function for detecting whether current test is forked
authorMike Blumenkrantz <zmike@samsung.com>
Thu, 31 Oct 2019 13:02:47 +0000 (09:02 -0400)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 11 Nov 2019 02:20:40 +0000 (11:20 +0900)
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

src/tests/elementary/suite_helpers.c
src/tests/elementary/suite_helpers.h

index 67aac9d..a8ecb59 100644 (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)
 {
index 34660a6..05150b4 100644 (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);