diff options
author | Havoc Pennington <hp@redhat.com> | 2005-01-15 07:15:38 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2005-01-15 07:15:38 +0000 |
commit | 9c3d566e95c9080f6040c64531b0ccae22bd5d74 (patch) | |
tree | d21a18baa5a5ee9855c8a00eb2c1985bc23ca65f /test | |
parent | 6ec04e917c8b4d477e818aa65ebb5e1fd50e4395 (diff) |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 9 | ||||
-rw-r--r-- | test/break-loader.c | 2 | ||||
-rwxr-xr-x | test/glib/run-test.sh | 4 | ||||
-rw-r--r-- | test/glib/test-dbus-glib.c | 59 | ||||
-rw-r--r-- | test/glib/test-profile.c | 30 | ||||
-rw-r--r-- | test/glib/test-thread-client.c | 6 | ||||
-rw-r--r-- | test/glib/test-thread-server.c | 10 | ||||
-rw-r--r-- | test/test-service.c | 10 |
8 files changed, 68 insertions, 62 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 0579e7f8..4498b7e3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,7 +10,8 @@ INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS) if DBUS_BUILD_TESTS -TEST_BINARIES=test-service break-loader spawn-test test-segfault test-exit test-sleep-forever +## break-loader removed for now +TEST_BINARIES=test-service spawn-test test-segfault test-exit test-sleep-forever else TEST_BINARIES= endif @@ -28,8 +29,8 @@ test_service_SOURCES= \ test-utils.c \ test-utils.h -break_loader_SOURCES= \ - break-loader.c +##break_loader_SOURCES= \ +## break-loader.c spawn_test_SOURCES= \ spawn-test.c @@ -49,7 +50,7 @@ decode_gcov_SOURCES= \ TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la test_service_LDADD=$(TEST_LIBS) -break_loader_LDADD= $(TEST_LIBS) +## break_loader_LDADD= $(TEST_LIBS) spawn_test_LDADD=$(TEST_LIBS) decode_gcov_LDADD=$(TEST_LIBS) diff --git a/test/break-loader.c b/test/break-loader.c index cb7dc19c..f74d5025 100644 --- a/test/break-loader.c +++ b/test/break-loader.c @@ -36,7 +36,7 @@ #include <dbus/dbus-string.h> #include <dbus/dbus-internals.h> #include <dbus/dbus-test.h> -#include <dbus/dbus-marshal.h> +#include <dbus/dbus-marshal-basic.h> #undef DBUS_COMPILATION static DBusString failure_dir; diff --git a/test/glib/run-test.sh b/test/glib/run-test.sh index 5d0317a3..473946a9 100755 --- a/test/glib/run-test.sh +++ b/test/glib/run-test.sh @@ -61,9 +61,9 @@ if test x$MODE = xprofile ; then 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 diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c index 2315c97c..5ebf3b9d 100644 --- a/test/glib/test-dbus-glib.c +++ b/test/glib/test-dbus-glib.c @@ -62,8 +62,9 @@ main (int argc, char **argv) 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 @@ main (int argc, char **argv) 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 @@ main (int argc, char **argv) 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 @@ main (int argc, char **argv) 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 @@ main (int argc, char **argv) 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 @@ main (int argc, char **argv) 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 */ diff --git a/test/glib/test-profile.c b/test/glib/test-profile.c index 8e636d0a..55dc603f 100644 --- a/test/glib/test-profile.c +++ b/test/glib/test-profile.c @@ -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 @@ static void 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 @@ no_bus_init_server (ServerData *sd) { 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 @@ with_bus_init_server (ServerData *sd) 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 @@ main (int argc, char *argv[]) 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, diff --git a/test/glib/test-thread-client.c b/test/glib/test-thread-client.c index 3a370671..07a1b12a 100644 --- a/test/glib/test-thread-client.c +++ b/test/glib/test-thread-client.c @@ -26,18 +26,18 @@ thread_func (gpointer data) 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); } diff --git a/test/glib/test-thread-server.c b/test/glib/test-thread-server.c index 3d8a3544..e61e3a6a 100644 --- a/test/glib/test-thread-server.c +++ b/test/glib/test-thread-server.c @@ -34,7 +34,8 @@ filter_test_message (DBusConnection *connection, 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 @@ filter_test_message (DBusConnection *connection, 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 @@ filter_test_message (DBusConnection *connection, 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 @@ filter_test_message (DBusConnection *connection, goto out; } - str = dbus_message_iter_get_string (&iter); + dbus_message_iter_get_basic (&iter, &str); if (str == NULL) { @@ -103,7 +104,6 @@ filter_test_message (DBusConnection *connection, 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)) diff --git a/test/test-service.c b/test/test-service.c index cb4ff582..3ba16bbf 100644 --- a/test/test-service.c +++ b/test/test-service.c @@ -58,7 +58,7 @@ handle_echo (DBusConnection *connection, die ("No memory\n"); if (!dbus_message_append_args (reply, - DBUS_TYPE_STRING, s, + DBUS_TYPE_STRING, &s, DBUS_TYPE_INVALID)) die ("No memory"); @@ -67,8 +67,6 @@ handle_echo (DBusConnection *connection, fprintf (stderr, "Echo service echoed string: \"%s\"\n", s); - dbus_free (s); - dbus_message_unref (reply); return DBUS_HANDLER_RESULT_HANDLED; @@ -104,6 +102,7 @@ path_message_func (DBusConnection *connection, { /* Emit the Foo signal */ DBusMessage *signal; + double v_DOUBLE; _dbus_verbose ("emitting signal Foo\n"); @@ -112,9 +111,10 @@ path_message_func (DBusConnection *connection, "Foo"); if (signal == NULL) die ("No memory\n"); - + + v_DOUBLE = 42.6; if (!dbus_message_append_args (signal, - DBUS_TYPE_DOUBLE, 42.6, + DBUS_TYPE_DOUBLE, &v_DOUBLE, DBUS_TYPE_INVALID)) die ("No memory"); |