gtestutils: deprecate g_test_trap_fork()

https://bugzilla.gnome.org/show_bug.cgi?id=679683
This commit is contained in:
Dan Winship 2012-12-05 11:28:53 -05:00
parent e3d1869ee3
commit e9284ed297
4 changed files with 14 additions and 3 deletions

View File

@ -220,6 +220,7 @@ test_non_socket (void)
} }
/* This is #ifdef G_OS_UNIX anyway, so just use g_test_trap_fork() */ /* 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)) if (!g_test_trap_fork (0, 0))
{ {
/* parent */ /* parent */
@ -230,6 +231,7 @@ test_non_socket (void)
g_assert_cmpint (kill (first_child, SIGTERM), ==, 0); g_assert_cmpint (kill (first_child, SIGTERM), ==, 0);
return; return;
} }
G_GNUC_END_IGNORE_DEPRECATIONS;
/* second child */ /* second child */

View 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. * Returns: %TRUE for the forked child and %FALSE for the executing parent process.
* *
* Since: 2.16 * 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 gboolean
g_test_trap_fork (guint64 usec_timeout, g_test_trap_fork (guint64 usec_timeout,

View File

@ -172,7 +172,8 @@ typedef enum {
G_TEST_TRAP_SILENCE_STDERR = 1 << 8, G_TEST_TRAP_SILENCE_STDERR = 1 << 8,
G_TEST_TRAP_INHERIT_STDIN = 1 << 9 G_TEST_TRAP_INHERIT_STDIN = 1 << 9
} GTestTrapFlags; } GTestTrapFlags;
GLIB_AVAILABLE_IN_ALL
GLIB_DEPRECATED_IN_2_38_FOR (g_test_trap_subprocess)
gboolean g_test_trap_fork (guint64 usec_timeout, gboolean g_test_trap_fork (guint64 usec_timeout,
GTestTrapFlags test_trap_flags); GTestTrapFlags test_trap_flags);

View File

@ -85,6 +85,9 @@ test_timer (void)
g_test_maximized_result (5, "bogus-quantity: %ddummies", 5); /* simple API test */ 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 */ /* fork out for a failing test */
static void static void
test_fork_fail (void) test_fork_fail (void)
@ -127,6 +130,9 @@ test_fork_timeout (void)
g_assert (g_test_trap_reached_timeout()); g_assert (g_test_trap_reached_timeout());
} }
G_GNUC_END_IGNORE_DEPRECATIONS
#endif /* G_OS_UNIX */
static void static void
test_subprocess_fail_child (void) test_subprocess_fail_child (void)
{ {