gtestutils: deprecate g_test_trap_fork()
authorDan Winship <danw@gnome.org>
Wed, 5 Dec 2012 16:28:53 +0000 (11:28 -0500)
committerDan Winship <danw@gnome.org>
Mon, 13 May 2013 16:10:53 +0000 (12:10 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=679683

gio/tests/gdbus-non-socket.c
glib/gtestutils.c
glib/gtestutils.h
glib/tests/testing.c

index 8866b1d..43b681b 100644 (file)
@@ -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 */
 
index c157fe1..aed7908 100644 (file)
@@ -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,
index 3e37197..0051c41 100644 (file)
@@ -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);
 
index 0de05c0..979676a 100644 (file)
@@ -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)
 {