[glib] gtestutils: deprecate g_test_trap_fork()



commit e9284ed29731365415992d8c9ed72f10e67cf056
Author: Dan Winship <danw gnome org>
Date:   Wed Dec 5 11:28:53 2012 -0500

    gtestutils: deprecate g_test_trap_fork()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679683

 gio/tests/gdbus-non-socket.c |    2 ++
 glib/gtestutils.c            |    6 ++++--
 glib/gtestutils.h            |    3 ++-
 glib/tests/testing.c         |    6 ++++++
 4 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gio/tests/gdbus-non-socket.c b/gio/tests/gdbus-non-socket.c
index 8866b1d..43b681b 100644
--- a/gio/tests/gdbus-non-socket.c
+++ b/gio/tests/gdbus-non-socket.c
@@ -220,6 +220,7 @@ test_non_socket (void)
     }
 
   /* This is #ifdef G_OS_UNIX anyway, so just use g_test_trap_fork() */
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   if (!g_test_trap_fork (0, 0))
     {
       /* parent */
@@ -230,6 +231,7 @@ test_non_socket (void)
       g_assert_cmpint (kill (first_child, SIGTERM), ==, 0);
       return;
     }
+  G_GNUC_END_IGNORE_DEPRECATIONS;
 
   /* second child */
 
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index c157fe1..aed7908 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -2384,11 +2384,13 @@ wait_for_child (GPid pid,
  *   }
  * ]|
  *
- * This function is implemented only on Unix platforms.
- *
  * Returns: %TRUE for the forked child and %FALSE for the executing parent process.
  *
  * Since: 2.16
+ *
+ * Deprecated: This function is implemented only on Unix platforms,
+ * and is not always reliable due to problems inherent in
+ * fork-without-exec. Use g_test_trap_subprocess() instead.
  */
 gboolean
 g_test_trap_fork (guint64        usec_timeout,
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 3e37197..0051c41 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -172,7 +172,8 @@ typedef enum {
   G_TEST_TRAP_SILENCE_STDERR    = 1 << 8,
   G_TEST_TRAP_INHERIT_STDIN     = 1 << 9
 } GTestTrapFlags;
-GLIB_AVAILABLE_IN_ALL
+
+GLIB_DEPRECATED_IN_2_38_FOR (g_test_trap_subprocess)
 gboolean g_test_trap_fork               (guint64              usec_timeout,
                                          GTestTrapFlags       test_trap_flags);
 
diff --git a/glib/tests/testing.c b/glib/tests/testing.c
index 0de05c0..979676a 100644
--- a/glib/tests/testing.c
+++ b/glib/tests/testing.c
@@ -85,6 +85,9 @@ test_timer (void)
   g_test_maximized_result (5, "bogus-quantity: %ddummies", 5); /* simple API test */
 }
 
+#ifdef G_OS_UNIX
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 /* fork out for a failing test */
 static void
 test_fork_fail (void)
@@ -127,6 +130,9 @@ test_fork_timeout (void)
   g_assert (g_test_trap_reached_timeout());
 }
 
+G_GNUC_END_IGNORE_DEPRECATIONS
+#endif /* G_OS_UNIX */
+
 static void
 test_subprocess_fail_child (void)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]