dbus/test/glib run-test.sh, 1.4, 1.5 test-dbus-glib.c, 1.8, 1.9 test-profile.c, 1.14, 1.15 test-thread-client.c, 1.3, 1.4 test-thread-server.c, 1.3, 1.4

Havoc Pennington hp@freedesktop.org
Fri Jan 14 23:15:41 PST 2005


Update of /cvs/dbus/dbus/test/glib
In directory gabe:/tmp/cvs-serv28195/test/glib

Modified Files:
	run-test.sh test-dbus-glib.c test-profile.c 
	test-thread-client.c test-thread-server.c 
Log Message:
2005-01-15  Havoc Pennington  <hp@redhat.com>

	* Land the new message args API and type system.

	This patch is huge, but the public API change is not 
	really large. The set of D-BUS types has changed somewhat, 
	and the arg "getters" are more geared toward language bindings;
	they don't make a copy, etc.

	There are also some known issues. See these emails for details
	on this huge patch:
	http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
        http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
	
	* dbus/dbus-marshal-*: all the new stuff

	* dbus/dbus-message.c: basically rewritten

	* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
	freed blocks to be all non-nul bytes so using freed memory is less
	likely to work right

	* dbus/dbus-internals.c (_dbus_test_oom_handling): add
	DBUS_FAIL_MALLOC=N environment variable, so you can do
	DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
	DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
	thorough.

	* qt/message.cpp: port to the new message args API
	(operator<<): use str.utf8() rather than str.unicode()
	(pretty sure this is right from the Qt docs?)

	* glib/dbus-gvalue.c: port to the new message args API

	* bus/dispatch.c, bus/driver.c: port to the new message args API

	* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
	"locked" flag to TRUE and align_offset to 0; I guess we never
	looked at these anyhow, but seems cleaner.

	* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
	move allocation padding macro to this header; use it to implement
	(_DBUS_STRING_STATIC): ability to declare a static string.

	* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
	change to return TRUE if the interface is not set.

	* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
	to dbus-marshal-validate.[hc]

	* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
	dbus-internals.c

	* dbus/Makefile.am: cut over from dbus-marshal.[hc]
	to dbus-marshal-*.[hc]

	* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
	function here from dbus-marshal.c



Index: run-test.sh
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/run-test.sh,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- run-test.sh	27 Nov 2004 02:18:36 -0000	1.4
+++ run-test.sh	15 Jan 2005 07:15:38 -0000	1.5
@@ -61,9 +61,9 @@
   if test x$PROFILE_TYPE = x ; then
       PROFILE_TYPE=all
   fi
-  $DEBUG $DBUS_TOP_BUILDDIR/test/glib/test-profile $PROFILE_TYPE || die "test-profile failed"
+  libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/glib/test-profile $PROFILE_TYPE || die "test-profile failed"
 else
-  $DEBUG $DBUS_TOP_BUILDDIR/test/glib/test-dbus-glib || die "test-dbus-glib failed"
+  libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/glib/test-dbus-glib || die "test-dbus-glib failed"
 fi
 
 ## we kill -TERM so gcov data can be written out

Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- test-dbus-glib.c	20 Jun 2004 15:28:15 -0000	1.8
+++ test-dbus-glib.c	15 Jan 2005 07:15:38 -0000	1.9
@@ -62,8 +62,9 @@
   int service_list_len;
   int i;
   guint32 result;
-  char *str;
-  
+  const char *v_STRING;
+  guint32 v_UINT32;
+    
   g_type_init ();
   
   loop = g_main_loop_new (NULL, FALSE);
@@ -115,12 +116,14 @@
   g_strfreev (service_list);
 
   /* Test handling of unknown method */
+  v_STRING = "blah blah blah blah blah";
+  v_UINT32 = 10;
   call = dbus_g_proxy_begin_call (driver, "ThisMethodDoesNotExist",
-                                 DBUS_TYPE_STRING,
-                                 "blah blah blah blah blah",
-                                 DBUS_TYPE_INT32,
-                                 10,
-                                 DBUS_TYPE_INVALID);
+                                  DBUS_TYPE_STRING,
+                                  &v_STRING,
+                                  DBUS_TYPE_INT32,
+                                  &v_UINT32,
+                                  DBUS_TYPE_INVALID);
 
   error = NULL;
   if (dbus_g_proxy_end_call (driver, call, &error,
@@ -135,17 +138,19 @@
   g_error_free (error);
   
   /* Activate a service */
+  v_STRING = "org.freedesktop.DBus.TestSuiteEchoService";
+  v_UINT32 = 0;
   call = dbus_g_proxy_begin_call (driver, "ActivateService",
-                                 DBUS_TYPE_STRING,
-                                 "org.freedesktop.DBus.TestSuiteEchoService",
-                                 DBUS_TYPE_UINT32,
-                                 0,
-                                 DBUS_TYPE_INVALID);
+                                  DBUS_TYPE_STRING,
+                                  &v_STRING,
+                                  DBUS_TYPE_UINT32,
+                                  &v_UINT32,
+                                  DBUS_TYPE_INVALID);
 
   error = NULL;
   if (!dbus_g_proxy_end_call (driver, call, &error,
-                             DBUS_TYPE_UINT32, &result,
-                             DBUS_TYPE_INVALID))
+                              DBUS_TYPE_UINT32, &result,
+                              DBUS_TYPE_INVALID))
     {
       g_printerr ("Failed to complete Activate call: %s\n",
                   error->message);
@@ -156,12 +161,14 @@
   g_print ("Activation of echo service = 0x%x\n", result);
 
   /* Activate a service again */
+  v_STRING = "org.freedesktop.DBus.TestSuiteEchoService";
+  v_UINT32 = 0;
   call = dbus_g_proxy_begin_call (driver, "ActivateService",
-                                 DBUS_TYPE_STRING,
-                                 "org.freedesktop.DBus.TestSuiteEchoService",
-                                 DBUS_TYPE_UINT32,
-                                 0,
-                                 DBUS_TYPE_INVALID);
+                                  DBUS_TYPE_STRING,
+                                  &v_STRING,
+                                  DBUS_TYPE_UINT32,
+                                  &v_UINT32,
+                                  DBUS_TYPE_INVALID);
 
   error = NULL;
   if (!dbus_g_proxy_end_call (driver, call, &error,
@@ -192,15 +199,16 @@
       exit (1);      
     }
 
+  v_STRING = "my string hello";
   call = dbus_g_proxy_begin_call (proxy, "Echo",
-                                 DBUS_TYPE_STRING,
-                                 "my string hello",
-                                 DBUS_TYPE_INVALID);
+                                  DBUS_TYPE_STRING,
+                                  &v_STRING,
+                                  DBUS_TYPE_INVALID);
 
   error = NULL;
   if (!dbus_g_proxy_end_call (proxy, call, &error,
-                             DBUS_TYPE_STRING, &str,
-                             DBUS_TYPE_INVALID))
+                              DBUS_TYPE_STRING, &v_STRING,
+                              DBUS_TYPE_INVALID))
     {
       g_printerr ("Failed to complete Echo call: %s\n",
                   error->message);
@@ -208,8 +216,7 @@
       exit (1);
     }
 
-  g_print ("String echoed = \"%s\"\n", str);
-  g_free (str);
+  g_print ("String echoed = \"%s\"\n", v_STRING);
 
   /* Test oneway call and signal handling */
 

Index: test-profile.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-profile.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- test-profile.c	27 Nov 2004 07:30:22 -0000	1.14
+++ test-profile.c	15 Jan 2005 07:15:38 -0000	1.15
@@ -48,7 +48,7 @@
  */
 #define N_CLIENT_THREADS 1
 /* It seems like at least 750000 or so iterations reduces the variability to sane levels */
-#define N_ITERATIONS 750000
+#define N_ITERATIONS 7500
 #define N_PROGRESS_UPDATES 20
 /* Don't make PAYLOAD_SIZE too huge because it gets used as a static buffer size */
 #define PAYLOAD_SIZE 0
@@ -103,17 +103,19 @@
 send_echo_method_call (DBusConnection *connection)
 {
   DBusMessage *message;
+  const char *hello = "Hello World!";
+  dbus_int32_t i32 = 123456;
 
   message = dbus_message_new_method_call (ECHO_SERVICE,
                                           ECHO_PATH,
                                           ECHO_INTERFACE,
                                           ECHO_PING_METHOD);
   dbus_message_append_args (message,
-                            DBUS_TYPE_STRING, "Hello World!",
-                            DBUS_TYPE_INT32, 123456,
+                            DBUS_TYPE_STRING, &hello,
+                            DBUS_TYPE_INT32, &i32,
 #if PAYLOAD_SIZE > 0
                             DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                            payload, PAYLOAD_SIZE,
+                            &payload, PAYLOAD_SIZE,
 #endif
                             DBUS_TYPE_INVALID);
   
@@ -277,10 +279,6 @@
 {
   DBusServer *server;
   DBusError error;
-  
-#ifndef DBUS_DISABLE_ASSERT
-  g_printerr ("You should probably --disable-asserts before you profile as they have noticeable overhead\n");
-#endif
 
   dbus_error_init (&error);
   server = dbus_server_listen ("unix:tmpdir="DBUS_TEST_SOCKET_DIR,
@@ -511,14 +509,6 @@
       g_printerr ("You have to run with_bus mode with the run-test.sh script\n");
       exit (1);
     }
-  
-#ifndef DBUS_DISABLE_ASSERT
-  g_printerr ("You should probably --disable-asserts before you profile as they have noticeable overhead\n");
-#endif
-  
-#ifdef DBUS_ENABLE_VERBOSE_MODE
-  g_printerr ("You should probably --disable-verbose-mode before you profile as verbose has noticeable overhead\n");
-#endif
 
   /* Note that we use the standard global bus connection for the
    * server, and the clients open their own connections so they can
@@ -1111,6 +1101,14 @@
   g_thread_init (NULL);
   dbus_g_thread_init ();
   
+#ifndef DBUS_DISABLE_ASSERT
+  g_printerr ("You should probably --disable-asserts before you profile as they have noticeable overhead\n");
+#endif
+  
+#if DBUS_ENABLE_VERBOSE_MODE
+  g_printerr ("You should probably --disable-verbose-mode before you profile as verbose has noticeable overhead\n");
+#endif
+  
   payload = g_malloc (PAYLOAD_SIZE);
 
   /* The actual size of the DBusMessage on the wire, as of Nov 23 2004,

Index: test-thread-client.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-thread-client.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test-thread-client.c	20 Jun 2004 15:28:15 -0000	1.3
+++ test-thread-client.c	15 Jan 2005 07:15:38 -0000	1.4
@@ -26,18 +26,18 @@
 
       dbus_message_append_iter_init (message, &iter);
 
-      if (!dbus_message_iter_append_int32 (&iter, threadnr))
+      if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &threadnr))
 	{
 	  g_print ("thread %d: append threadnr failed\n", threadnr);
 	}
       
-      if (!dbus_message_iter_append_uint32 (&iter, counter))
+      if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &counter))
 	{
 	  g_print ("thread %d: append counter (%d) failed\n", threadnr, counter);
 	}
       
       str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter);
-      if (!dbus_message_iter_append_string (&iter, str))
+      if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &str))
 	{
 	  g_print ("thread %d: append string (%s) failed\n", threadnr, str);
 	}

Index: test-thread-server.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-thread-server.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test-thread-server.c	20 Jun 2004 15:28:15 -0000	1.3
+++ test-thread-server.c	15 Jan 2005 07:15:38 -0000	1.4
@@ -34,7 +34,8 @@
   DBusMessageIter iter;
   gint32 threadnr;
   guint32 counter;
-  char *str, *expected_str;
+  const char *str;
+  char *expected_str;
   GString *counter_str;
   int i;
 
@@ -49,7 +50,7 @@
       g_print ("First arg not right type\n");
       goto out;
     }
-  threadnr = dbus_message_iter_get_int32 (&iter);
+   dbus_message_iter_get_basic (&iter, &threadnr);
   if (threadnr < 0 || threadnr >= N_TEST_THREADS)
     {
       g_print ("Invalid thread nr\n");
@@ -68,7 +69,7 @@
       goto out;
     }
   
-  counter = dbus_message_iter_get_uint32 (&iter);
+   dbus_message_iter_get_basic (&iter, &counter);
 
   if (counter != data->counters[threadnr])
     {
@@ -89,7 +90,7 @@
       goto out;
     }
 
-  str = dbus_message_iter_get_string (&iter);
+  dbus_message_iter_get_basic (&iter, &str);
 
   if (str == NULL)
     {
@@ -103,7 +104,6 @@
       g_print ("Wrong string '%s', expected '%s'\n", str, expected_str);
       goto out;
     }
-  g_free (str);
   g_free (expected_str);
 
   if (dbus_message_iter_next (&iter))



More information about the dbus-commit mailing list