dbus/test/glib run-test.sh,1.1,1.2 test-dbus-glib.c,1.3,1.4

Havoc Pennington hp@pdx.freedesktop.org
Wed, 15 Oct 2003 23:34:53 -0700


Update of /cvs/dbus/dbus/test/glib
In directory pdx:/tmp/cvs-serv10532/test/glib

Modified Files:
	run-test.sh test-dbus-glib.c 
Log Message:
2003-10-16  Havoc Pennington  <hp@redhat.com>

	* bus/connection.c (bus_pending_reply_expired): either cancel or
	execute, not both
	(bus_connections_check_reply): use unlink, not remove_link, as we
	don't want to free the link; fixes double free mess

	* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
	where no reply was received

	* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
	fix a refcount leak

	* bus/signals.c (match_rule_matches): add special cases for the
	bus driver, so you can match on sender/destination for it.

	* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
	DBUS_PRINT_BACKTRACE is set

	* dbus/dbus-internals.c: add pid to assertion failure messages

	* dbus/dbus-connection.c: add message type code to the debug spew

	* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
	sender=foo not service=foo

	* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
	session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use 
	DBUS_ACTIVATION_ADDRESS instead

	* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
	DBUS_SYSTEM_BUS_ADDRESS if appropriate

	* bus/bus.c (bus_context_new): handle OOM copying bus type into
	context struct

	* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
	(dbus_message_iter_get_object_path_array): new function (half
	finished, disabled for the moment)
	
	* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
	DBUS_MESSAGE_TYPE_ERROR

	* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
	avoid redirecting stderr to /dev/null
	(babysit): close stdin if not doing the "exit_with_session" thing

	* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
	debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
	stdout/stdin, so things don't get confused
	
	* bus/system.conf.in: fix to allow replies, I modified .conf
	instead of .conf.in again.



Index: run-test.sh
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/run-test.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- run-test.sh	12 Oct 2003 15:35:23 -0000	1.1
+++ run-test.sh	16 Oct 2003 06:34:51 -0000	1.2
@@ -4,6 +4,9 @@
 
 function die() 
 {
+    if ! test -z "$DBUS_SESSION_BUS_PID" ; then
+        kill -9 $DBUS_SESSION_BUS_PID
+    fi
     echo $SCRIPTNAME: $* >&2
     exit 1
 }
@@ -13,11 +16,14 @@
 fi
 
 CONFIG_FILE=./run-test.conf
+SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files"
+ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
+echo "escaped service dir is: $ESCAPED_SERVICE_DIR"
 
 ## create a configuration file based on the standard session.conf
 cat $DBUS_TOP_BUILDDIR/bus/session.conf |  \
-  sed -e 's/<servicedir>.*$//g'         |  \
-  sed -e 's/<include.*$//g'                \
+    sed -e 's/<servicedir>.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' |  \
+    sed -e 's/<include.*$//g'                \
   > $CONFIG_FILE
 
 echo "Created configuration file $CONFIG_FILE"

Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test-dbus-glib.c	12 Oct 2003 05:59:39 -0000	1.3
+++ test-dbus-glib.c	16 Oct 2003 06:34:51 -0000	1.4
@@ -11,11 +11,14 @@
   GMainLoop *loop;
   GError *error;
   DBusGProxy *driver;
+  DBusGProxy *proxy;
   DBusPendingCall *call;
   char **service_list;
   int service_list_len;
   int i;
-
+  dbus_uint32_t result;
+  char *str;
+  
   g_type_init ();
   
   loop = g_main_loop_new (NULL, FALSE);
@@ -66,7 +69,96 @@
   
   dbus_free_string_array (service_list);
 
+  /* Test handling of unknown method */
+  call = dbus_gproxy_begin_call (driver, "ThisMethodDoesNotExist",
+                                 DBUS_TYPE_STRING,
+                                 "blah blah blah blah blah",
+                                 DBUS_TYPE_INT32,
+                                 10,
+                                 DBUS_TYPE_INVALID);
+
+  error = NULL;
+  if (dbus_gproxy_end_call (driver, call, &error,
+                            DBUS_TYPE_INVALID))
+    {
+      g_printerr ("Calling nonexistent method succeeded!\n");
+      exit (1);
+    }
+
+  g_print ("Got EXPECTED error from calling unknown method: %s\n",
+           error->message);
+  g_error_free (error);
+  
+  /* Activate a service */
+  call = dbus_gproxy_begin_call (driver, "ActivateService",
+                                 DBUS_TYPE_STRING,
+                                 "org.freedesktop.DBus.TestSuiteEchoService",
+                                 DBUS_TYPE_UINT32,
+                                 0,
+                                 DBUS_TYPE_INVALID);
+
+  error = NULL;
+  if (!dbus_gproxy_end_call (driver, call, &error,
+                             DBUS_TYPE_UINT32, &result,
+                             DBUS_TYPE_INVALID))
+    {
+      g_printerr ("Failed to complete Activate call: %s\n",
+                  error->message);
+      g_error_free (error);
+      exit (1);
+    }
+
+  g_print ("Activation of echo service = 0x%x\n", result);
+
+  /* Activate a service again */
+  call = dbus_gproxy_begin_call (driver, "ActivateService",
+                                 DBUS_TYPE_STRING,
+                                 "org.freedesktop.DBus.TestSuiteEchoService",
+                                 DBUS_TYPE_UINT32,
+                                 0,
+                                 DBUS_TYPE_INVALID);
+
+  error = NULL;
+  if (!dbus_gproxy_end_call (driver, call, &error,
+                             DBUS_TYPE_UINT32, &result,
+                             DBUS_TYPE_INVALID))
+    {
+      g_printerr ("Failed to complete Activate call: %s\n",
+                  error->message);
+      g_error_free (error);
+      exit (1);
+    }
+
+  g_print ("Duplicate activation of echo service = 0x%x\n", result);
+
+  /* Talk to the new service */
+  
+  proxy = dbus_gproxy_new_for_service (connection,
+                                       "org.freedesktop.DBus.TestSuiteEchoService",
+                                       "/fixme/the/test/service/ignores/this", /* FIXME */
+                                       "org.freedesktop.TestSuite");
+  
+  call = dbus_gproxy_begin_call (proxy, "Echo",
+                                 DBUS_TYPE_STRING,
+                                 "my string hello",
+                                 DBUS_TYPE_INVALID);
+
+  error = NULL;
+  if (!dbus_gproxy_end_call (proxy, call, &error,
+                             DBUS_TYPE_STRING, &str,
+                             DBUS_TYPE_INVALID))
+    {
+      g_printerr ("Failed to complete Echo call: %s\n",
+                  error->message);
+      g_error_free (error);
+      exit (1);
+    }
+
+  g_print ("String echoed = \"%s\"\n", str);
+  dbus_free (str);
+  
   g_object_unref (G_OBJECT (driver));
+  g_object_unref (G_OBJECT (proxy));
   
   g_print ("Successfully completed %s\n", argv[0]);