Migrate platform specific spawn tests into cross platform tests.
authorRalf Habacker <ralf.habacker@freenet.de>
Mon, 16 May 2016 13:35:01 +0000 (15:35 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Fri, 20 May 2016 04:18:20 +0000 (06:18 +0200)
Also enable segfault checks on windows because the reason why it
has been disabled has been fixed with bug #95155.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95191
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
cmake/dbus/CMakeLists.txt
dbus/Makefile.am
dbus/dbus-spawn-test.c [new file with mode: 0644]
dbus/dbus-spawn-win.c
dbus/dbus-spawn.c
dbus/dbus-spawn.h

index 851ec60..c5c5ebd 100644 (file)
@@ -168,6 +168,7 @@ if (DBUS_ENABLE_EMBEDDED_TESTS)
        set (DBUS_UTIL_SOURCES 
                ${DBUS_UTIL_SOURCES}
                ${DBUS_DIR}/dbus-test.c
+               ${DBUS_DIR}/dbus-spawn-test.c
        )
 endif (DBUS_ENABLE_EMBEDDED_TESTS)
 
index a7b3491..0152486 100644 (file)
@@ -268,6 +268,10 @@ DBUS_UTIL_SOURCES=                         \
        dbus-test.c                             \
        dbus-test.h
 
+if DBUS_ENABLE_EMBEDDED_TESTS
+DBUS_UTIL_SOURCES += dbus-spawn-test.c
+endif
+
 libdbus_1_la_SOURCES=                          \
        $(DBUS_LIB_SOURCES)                     \
        $(DBUS_SHARED_SOURCES)
diff --git a/dbus/dbus-spawn-test.c b/dbus/dbus-spawn-test.c
new file mode 100644 (file)
index 0000000..8c90fcc
--- /dev/null
@@ -0,0 +1,285 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* dbus-spawn-test.c
+ *
+ * Copyright (C) 2002, 2003, 2004  Red Hat, Inc.
+ * Copyright (C) 2003 CodeFactory AB
+ * Copyright (C) 2005 Novell, Inc.
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+#include <config.h>
+
+
+#include "dbus-spawn.h"
+#include "dbus-sysdeps.h"
+#include "dbus-test.h"
+
+static char *
+get_test_exec (const char *exe,
+               DBusString *scratch_space)
+{
+  const char *dbus_test_exec;
+
+  dbus_test_exec = _dbus_getenv ("DBUS_TEST_EXEC");
+
+  if (dbus_test_exec == NULL)
+    dbus_test_exec = DBUS_TEST_EXEC;
+
+  if (!_dbus_string_init (scratch_space))
+    return NULL;
+
+  if (!_dbus_string_append_printf (scratch_space, "%s/%s%s",
+                                   dbus_test_exec, exe, DBUS_EXEEXT))
+    {
+      _dbus_string_free (scratch_space);
+      return NULL;
+    }
+
+  return _dbus_string_get_data (scratch_space);
+}
+
+static dbus_bool_t
+check_spawn_nonexistent (void *data)
+{
+  char *argv[4] = { NULL, NULL, NULL, NULL };
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
+
+  /*** Test launching nonexistent binary */
+
+  argv[0] = "/this/does/not/exist/32542sdgafgafdg";
+  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_nonexistent", argv,
+                                         NULL, NULL, NULL,
+                                         &error))
+    {
+      _dbus_babysitter_block_for_child_exit (sitter);
+      _dbus_babysitter_set_child_exit_error (sitter, &error);
+    }
+
+  if (sitter)
+    _dbus_babysitter_unref (sitter);
+
+  if (!dbus_error_is_set (&error))
+    {
+      _dbus_warn ("Did not get an error launching nonexistent executable\n");
+      return FALSE;
+    }
+
+  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
+        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_EXEC_FAILED)))
+    {
+      _dbus_warn ("Not expecting error when launching nonexistent executable: %s: %s\n",
+                  error.name, error.message);
+      dbus_error_free (&error);
+      return FALSE;
+    }
+
+  dbus_error_free (&error);
+
+  return TRUE;
+}
+
+static dbus_bool_t
+check_spawn_segfault (void *data)
+{
+  char *argv[4] = { NULL, NULL, NULL, NULL };
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
+  DBusString argv0;
+
+  /*** Test launching segfault binary */
+
+  argv[0] = get_test_exec ("test-segfault", &argv0);
+
+  if (argv[0] == NULL)
+    {
+      /* OOM was simulated, never mind */
+      return TRUE;
+    }
+
+  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_segfault", argv,
+                                         NULL, NULL, NULL,
+                                         &error))
+    {
+      _dbus_babysitter_block_for_child_exit (sitter);
+      _dbus_babysitter_set_child_exit_error (sitter, &error);
+    }
+
+  _dbus_string_free (&argv0);
+
+  if (sitter)
+    _dbus_babysitter_unref (sitter);
+
+  if (!dbus_error_is_set (&error))
+    {
+      _dbus_warn ("Did not get an error launching segfaulting binary\n");
+      return FALSE;
+    }
+
+  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
+#ifdef DBUS_WIN
+        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED)))
+#else
+        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_SIGNALED)))
+#endif
+    {
+      _dbus_warn ("Not expecting error when launching segfaulting executable: %s: %s\n",
+                  error.name, error.message);
+      dbus_error_free (&error);
+      return FALSE;
+    }
+
+  dbus_error_free (&error);
+
+  return TRUE;
+}
+
+static dbus_bool_t
+check_spawn_exit (void *data)
+{
+  char *argv[4] = { NULL, NULL, NULL, NULL };
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
+  DBusString argv0;
+
+  /*** Test launching exit failure binary */
+
+  argv[0] = get_test_exec ("test-exit", &argv0);
+
+  if (argv[0] == NULL)
+    {
+      /* OOM was simulated, never mind */
+      return TRUE;
+    }
+
+  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_exit", argv,
+                                         NULL, NULL, NULL,
+                                         &error))
+    {
+      _dbus_babysitter_block_for_child_exit (sitter);
+      _dbus_babysitter_set_child_exit_error (sitter, &error);
+    }
+
+  _dbus_string_free (&argv0);
+
+  if (sitter)
+    _dbus_babysitter_unref (sitter);
+
+  if (!dbus_error_is_set (&error))
+    {
+      _dbus_warn ("Did not get an error launching binary that exited with failure code\n");
+      return FALSE;
+    }
+
+  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
+        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED)))
+    {
+      _dbus_warn ("Not expecting error when launching exiting executable: %s: %s\n",
+                  error.name, error.message);
+      dbus_error_free (&error);
+      return FALSE;
+    }
+
+  dbus_error_free (&error);
+
+  return TRUE;
+}
+
+static dbus_bool_t
+check_spawn_and_kill (void *data)
+{
+  char *argv[4] = { NULL, NULL, NULL, NULL };
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
+  DBusString argv0;
+
+  /*** Test launching sleeping binary then killing it */
+
+  argv[0] = get_test_exec ("test-sleep-forever", &argv0);
+
+  if (argv[0] == NULL)
+    {
+      /* OOM was simulated, never mind */
+      return TRUE;
+    }
+
+  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_and_kill", argv,
+                                         NULL, NULL, NULL,
+                                         &error))
+    {
+      _dbus_babysitter_kill_child (sitter);
+
+      _dbus_babysitter_block_for_child_exit (sitter);
+
+      _dbus_babysitter_set_child_exit_error (sitter, &error);
+    }
+
+  _dbus_string_free (&argv0);
+
+  if (sitter)
+    _dbus_babysitter_unref (sitter);
+
+  if (!dbus_error_is_set (&error))
+    {
+      _dbus_warn ("Did not get an error after killing spawned binary\n");
+      return FALSE;
+    }
+
+  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
+#ifdef DBUS_WIN
+        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED)))
+#else
+        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_SIGNALED)))
+#endif
+    {
+      _dbus_warn ("Not expecting error when killing executable: %s: %s\n",
+                  error.name, error.message);
+      dbus_error_free (&error);
+      return FALSE;
+    }
+
+  dbus_error_free (&error);
+
+  return TRUE;
+}
+
+dbus_bool_t
+_dbus_spawn_test (const char *test_data_dir)
+{
+  if (!_dbus_test_oom_handling ("spawn_nonexistent",
+                                check_spawn_nonexistent,
+                                NULL))
+    return FALSE;
+
+  if (!_dbus_test_oom_handling ("spawn_segfault",
+                                check_spawn_segfault,
+                                NULL))
+    return FALSE;
+
+  if (!_dbus_test_oom_handling ("spawn_exit",
+                                check_spawn_exit,
+                                NULL))
+    return FALSE;
+
+  if (!_dbus_test_oom_handling ("spawn_and_kill",
+                                check_spawn_and_kill,
+                                NULL))
+    return FALSE;
+
+  return TRUE;
+}
index f9a4207..5cb3044 100644 (file)
@@ -760,35 +760,9 @@ _dbus_babysitter_set_result_function  (DBusBabysitter             *sitter,
   sitter->finished_data = user_data;
 }
 
-#ifdef DBUS_ENABLE_EMBEDDED_TESTS
-
-static char *
-get_test_exec (const char *exe,
-               DBusString *scratch_space)
-{
-  const char *dbus_test_exec;
-
-  dbus_test_exec = _dbus_getenv ("DBUS_TEST_EXEC");
-
-  if (dbus_test_exec == NULL)
-    dbus_test_exec = DBUS_TEST_EXEC;
-
-  if (!_dbus_string_init (scratch_space))
-    return NULL;
-
-  if (!_dbus_string_append_printf (scratch_space, "%s/%s%s",
-                                   dbus_test_exec, exe, DBUS_EXEEXT))
-    {
-      _dbus_string_free (scratch_space);
-      return NULL;
-    }
-
-  return _dbus_string_get_data (scratch_space);
-}
-
 #define LIVE_CHILDREN(sitter) ((sitter)->child_handle != NULL)
 
-static void
+void
 _dbus_babysitter_block_for_child_exit (DBusBabysitter *sitter)
 {
   /* The thread terminates after the child does. We want to wait for the thread,
@@ -796,247 +770,3 @@ _dbus_babysitter_block_for_child_exit (DBusBabysitter *sitter)
    * its memory. */
   WaitForSingleObject (sitter->thread_handle, INFINITE);
 }
-
-static dbus_bool_t
-check_spawn_nonexistent (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
-
-  /*** Test launching nonexistent binary */
-
-  argv[0] = "/this/does/not/exist/32542sdgafgafdg";
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_nonexistent", argv, NULL,
-                                         NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_block_for_child_exit (sitter);
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error launching nonexistent executable\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_EXEC_FAILED)))
-    {
-      _dbus_warn ("Not expecting error when launching nonexistent executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-
-  return TRUE;
-}
-
-static dbus_bool_t
-check_spawn_segfault (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-  DBusString argv0;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
-
-  /*** Test launching segfault binary */
-
-  argv[0] = get_test_exec ("test-segfault", &argv0);
-
-  if (argv[0] == NULL)
-    {
-      /* OOM was simulated, never mind */
-      return TRUE;
-    }
-
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_segfault", argv, NULL,
-                                         NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_block_for_child_exit (sitter);
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  _dbus_string_free (&argv0);
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error launching segfaulting binary\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED)))
-    {
-      _dbus_warn ("Not expecting error when launching segfaulting executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-
-  return TRUE;
-}
-
-static dbus_bool_t
-check_spawn_exit (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-  DBusString argv0;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
-
-  /*** Test launching exit failure binary */
-
-  argv[0] = get_test_exec ("test-exit", &argv0);
-
-  if (argv[0] == NULL)
-    {
-      /* OOM was simulated, never mind */
-      return TRUE;
-    }
-
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_exit", argv, NULL,
-                                         NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_block_for_child_exit (sitter);
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  _dbus_string_free (&argv0);
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error launching binary that exited with failure code\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED)))
-    {
-      _dbus_warn ("Not expecting error when launching exiting executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-
-  return TRUE;
-}
-
-static dbus_bool_t
-check_spawn_and_kill (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-  DBusString argv0;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
-
-  /*** Test launching sleeping binary then killing it */
-
-  argv[0] = get_test_exec ("test-sleep-forever", &argv0);
-
-  if (argv[0] == NULL)
-    {
-      /* OOM was simulated, never mind */
-      return TRUE;
-    }
-
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_and_kill", argv, NULL,
-                                         NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_kill_child (sitter);
-
-      _dbus_babysitter_block_for_child_exit (sitter);
-
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  _dbus_string_free (&argv0);
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error after killing spawned binary\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED)))
-    {
-      _dbus_warn ("Not expecting error when killing executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-
-  return TRUE;
-}
-
-dbus_bool_t
-_dbus_spawn_test (const char *test_data_dir)
-{
-  if (!_dbus_test_oom_handling ("spawn_nonexistent",
-                                check_spawn_nonexistent,
-                                NULL))
-    return FALSE;
-
-  /* Don't run the obnoxious segfault test by default,
-   * it's a pain to have to click all those error boxes.
-   */
-  if (getenv ("DO_SEGFAULT_TEST"))
-    if (!_dbus_test_oom_handling ("spawn_segfault",
-                                  check_spawn_segfault,
-                                  NULL))
-      return FALSE;
-
-  if (!_dbus_test_oom_handling ("spawn_exit",
-                                check_spawn_exit,
-                                NULL))
-    return FALSE;
-
-  if (!_dbus_test_oom_handling ("spawn_and_kill",
-                                check_spawn_and_kill,
-                                NULL))
-    return FALSE;
-
-  return TRUE;
-}
-#endif
index e591e69..afdcd68 100644 (file)
@@ -1450,259 +1450,9 @@ _dbus_babysitter_set_result_function  (DBusBabysitter             *sitter,
 
 /** @} */
 
-#ifdef DBUS_ENABLE_EMBEDDED_TESTS
-
-static char *
-get_test_exec (const char *exe,
-               DBusString *scratch_space)
-{
-  const char *dbus_test_exec;
-
-  dbus_test_exec = _dbus_getenv ("DBUS_TEST_EXEC");
-
-  if (dbus_test_exec == NULL)
-    dbus_test_exec = DBUS_TEST_EXEC;
-
-  if (!_dbus_string_init (scratch_space))
-    return NULL;
-
-  if (!_dbus_string_append_printf (scratch_space, "%s/%s%s",
-                                   dbus_test_exec, exe, DBUS_EXEEXT))
-    {
-      _dbus_string_free (scratch_space);
-      return NULL;
-    }
-
-  return _dbus_string_get_data (scratch_space);
-}
-
-static void
+void
 _dbus_babysitter_block_for_child_exit (DBusBabysitter *sitter)
 {
   while (LIVE_CHILDREN (sitter))
     babysitter_iteration (sitter, TRUE);
 }
-
-static dbus_bool_t
-check_spawn_nonexistent (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter = NULL;
-  DBusError error = DBUS_ERROR_INIT;
-
-  /*** Test launching nonexistent binary */
-  
-  argv[0] = "/this/does/not/exist/32542sdgafgafdg";
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_nonexistent", argv,
-                                         NULL, NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_block_for_child_exit (sitter);
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error launching nonexistent executable\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_EXEC_FAILED)))
-    {
-      _dbus_warn ("Not expecting error when launching nonexistent executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-  
-  return TRUE;
-}
-
-static dbus_bool_t
-check_spawn_segfault (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter = NULL;
-  DBusError error = DBUS_ERROR_INIT;
-  DBusString argv0;
-
-  /*** Test launching segfault binary */
-
-  argv[0] = get_test_exec ("test-segfault", &argv0);
-
-  if (argv[0] == NULL)
-    {
-      /* OOM was simulated, never mind */
-      return TRUE;
-    }
-
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_segfault", argv,
-                                         NULL, NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_block_for_child_exit (sitter);
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  _dbus_string_free (&argv0);
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error launching segfaulting binary\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_SIGNALED)))
-    {
-      _dbus_warn ("Not expecting error when launching segfaulting executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-  
-  return TRUE;
-}
-
-static dbus_bool_t
-check_spawn_exit (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter = NULL;
-  DBusError error = DBUS_ERROR_INIT;
-  DBusString argv0;
-
-  /*** Test launching exit failure binary */
-
-  argv[0] = get_test_exec ("test-exit", &argv0);
-
-  if (argv[0] == NULL)
-    {
-      /* OOM was simulated, never mind */
-      return TRUE;
-    }
-
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_exit", argv,
-                                         NULL, NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_block_for_child_exit (sitter);
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  _dbus_string_free (&argv0);
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error launching binary that exited with failure code\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED)))
-    {
-      _dbus_warn ("Not expecting error when launching exiting executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-  
-  return TRUE;
-}
-
-static dbus_bool_t
-check_spawn_and_kill (void *data)
-{
-  char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter = NULL;
-  DBusError error = DBUS_ERROR_INIT;
-  DBusString argv0;
-
-  /*** Test launching sleeping binary then killing it */
-
-  argv[0] = get_test_exec ("test-sleep-forever", &argv0);
-
-  if (argv[0] == NULL)
-    {
-      /* OOM was simulated, never mind */
-      return TRUE;
-    }
-
-  if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_and_kill", argv,
-                                         NULL, NULL, NULL,
-                                         &error))
-    {
-      _dbus_babysitter_kill_child (sitter);
-      
-      _dbus_babysitter_block_for_child_exit (sitter);
-      
-      _dbus_babysitter_set_child_exit_error (sitter, &error);
-    }
-
-  _dbus_string_free (&argv0);
-
-  if (sitter)
-    _dbus_babysitter_unref (sitter);
-
-  if (!dbus_error_is_set (&error))
-    {
-      _dbus_warn ("Did not get an error after killing spawned binary\n");
-      return FALSE;
-    }
-
-  if (!(dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY) ||
-        dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_SIGNALED)))
-    {
-      _dbus_warn ("Not expecting error when killing executable: %s: %s\n",
-                  error.name, error.message);
-      dbus_error_free (&error);
-      return FALSE;
-    }
-
-  dbus_error_free (&error);
-  
-  return TRUE;
-}
-
-dbus_bool_t
-_dbus_spawn_test (const char *test_data_dir)
-{
-  if (!_dbus_test_oom_handling ("spawn_nonexistent",
-                                check_spawn_nonexistent,
-                                NULL))
-    return FALSE;
-
-  if (!_dbus_test_oom_handling ("spawn_segfault",
-                                check_spawn_segfault,
-                                NULL))
-    return FALSE;
-
-  if (!_dbus_test_oom_handling ("spawn_exit",
-                                check_spawn_exit,
-                                NULL))
-    return FALSE;
-
-  if (!_dbus_test_oom_handling ("spawn_and_kill",
-                                check_spawn_and_kill,
-                                NULL))
-    return FALSE;
-  
-  return TRUE;
-}
-#endif
index e6baae9..12ea586 100644 (file)
@@ -62,6 +62,7 @@ dbus_bool_t _dbus_babysitter_set_watch_functions  (DBusBabysitter            *si
                                                    DBusWatchToggledFunction   toggled_function,
                                                    void                      *data,
                                                    DBusFreeFunction           free_data_function);
+void        _dbus_babysitter_block_for_child_exit (DBusBabysitter            *sitter);
 
 DBUS_END_DECLS