docs: Fix broken gtk-doc formatting
[platform/upstream/glib.git] / gio / tests / gdbus-connection-slow.c
index f94e386..9c2f59a 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  *
  * Author: David Zeuthen <davidz@redhat.com>
  */
@@ -28,8 +26,6 @@
 
 #include "gdbus-tests.h"
 
-static const gchar *binpath;
-
 /* all tests rely on a shared mainloop */
 static GMainLoop *loop = NULL;
 
@@ -63,6 +59,7 @@ test_connection_flush (void)
   GError *error;
   guint n;
   guint signal_handler_id;
+  const gchar *flush_helper;
 
   session_bus_up ();
 
@@ -83,16 +80,15 @@ test_connection_flush (void)
                                                           NULL);
   g_assert_cmpint (signal_handler_id, !=, 0);
 
+  flush_helper = g_test_get_filename (G_TEST_BUILT, "gdbus-connection-flush-helper", NULL);
   for (n = 0; n < 50; n++)
     {
       gboolean ret;
       gint exit_status;
       guint timeout_mainloop_id;
-      gchar *path;
 
       error = NULL;
-      path = g_build_filename (binpath, "gdbus-connection-flush-helper", NULL);
-      ret = g_spawn_command_line_sync (path,
+      ret = g_spawn_command_line_sync (flush_helper,
                                        NULL, /* stdout */
                                        NULL, /* stderr */
                                        &exit_status,
@@ -101,7 +97,6 @@ test_connection_flush (void)
       g_spawn_check_exit_status (exit_status, &error);
       g_assert_no_error (error);
       g_assert (ret);
-      g_free (path);
 
       timeout_mainloop_id = g_timeout_add (1000, test_connection_flush_on_timeout, GUINT_TO_POINTER (n));
       g_main_loop_run (loop);
@@ -188,15 +183,12 @@ static void
 test_connection_large_message (void)
 {
   guint watcher_id;
-  gchar *path;
   guint timeout_id;
 
   session_bus_up ();
 
   /* this is safe; testserver will exit once the bus goes away */
-  path = g_build_filename (binpath, "gdbus-testserver", NULL);
-  g_assert (g_spawn_command_line_async (path, NULL));
-  g_free (path);
+  g_assert (g_spawn_command_line_async (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
 
   timeout_id = g_timeout_add_seconds (LARGE_MESSAGE_TIMEOUT_SECONDS,
                                       large_message_timeout_cb,
@@ -221,10 +213,7 @@ int
 main (int   argc,
       char *argv[])
 {
-  if (g_getenv ("G_TEST_DATA"))
-    binpath = g_getenv ("G_TEST_DATA");
-  else
-    binpath = ".";
+  gint ret;
 
   g_test_init (&argc, &argv, NULL);
 
@@ -235,5 +224,8 @@ main (int   argc,
 
   g_test_add_func ("/gdbus/connection/flush", test_connection_flush);
   g_test_add_func ("/gdbus/connection/large_message", test_connection_large_message);
-  return g_test_run();
+
+  ret = g_test_run();
+  g_main_loop_unref (loop);
+  return ret;
 }