dbus/test/name-test Makefile.am, 1.2, 1.3 run-test.sh, 1.3,
1.4 test-threads-init.c, NONE, 1.1
John Palmieri
johnp at kemper.freedesktop.org
Wed Aug 16 15:30:17 PDT 2006
- Previous message: dbus ChangeLog,1.1082,1.1083
- Next message: dbus/dbus dbus-connection.c, 1.125, 1.126 dbus-dataslot.c, 1.13,
1.14 dbus-dataslot.h, 1.8, 1.9 dbus-message.c, 1.176,
1.177 dbus-pending-call.c, 1.16, 1.17 dbus-server.c, 1.42,
1.43 dbus-threads-internal.h, 1.2, 1.3 dbus-threads.c, 1.24, 1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/dbus/dbus/test/name-test
In directory kemper:/tmp/cvs-serv31677/test/name-test
Modified Files:
Makefile.am run-test.sh
Added Files:
test-threads-init.c
Log Message:
* dbus/dbus-threads.c: Add static DBusList *uninitialized_mutex_list and
static DBusList *uninitialized_condvar_list to support new late
initialization threading model. In this model threads can be initialized
even after the D-Bus API has been used but still needs to be initialized
before the second thread has been started. Mutexes and condvar addresses
are stored in the two static lists and are replaced with actuall locks
when threads are initalized.
(_dbus_mutex_new_at_location): New method for creating a mutex and placing
the location into the static list
(_dbus_mutex_free_at_location): New method for removing a mutex location
from the static list and freeing the mutex
(_dbus_condvar_new_at_location): New method for creating a conditional
variable and placing the location into the static list
(_dbus_condvar_free_at_location): New method for removing a conditional
variable location from the static list and freeing the conditional variable
(init_uninitialized_locks): Atomic method which goes through the static
lists of mutex and condvar location and updates them with actuall locks
(init_global_locks): changed to init_locks
* dbus/dbus-connection.c:
(_dbus_connection_test_get_locks): New method for tests to check connections
(_dbus_connection_new_for_transport): Use the new at_location mutex and
condvar API
(dbus_connection_allocate_data_slot): Pass in the global lock address
to _dbus_data_slot_allocator_alloc
* dbus/dbus-dataslot.c:
(_dbus_data_slot_allocator_alloc): Use the address of the mutex
instead of the mutex itself
* dbus/dbus-message.c:
(dbus_message_allocate_data_slot): Pass in the global lock address
to _dbus_data_slot_allocator_alloc
* dbus/dbus-pending-call.c:
(dbus_pending_call_allocate_data_slot): Pass in the global lock address
to _dbus_data_slot_allocator_alloc
* dbus/dbus-server.c:
(_dbus_server_init_base): Use the new at_location mutex API
(dbus_server_allocate_data_slot): Pass in the global lock address
to _dbus_data_slot_allocator_alloc
* test/name-test/test-threads-init.c: New test case for late thread
initialization
Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/test/name-test/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am 2 Mar 2006 22:24:28 -0000 1.2
+++ Makefile.am 16 Aug 2006 22:30:15 -0000 1.3
@@ -16,10 +16,10 @@
## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
## build even when not doing "make check"
-noinst_PROGRAMS=test-names test-pending-call-dispatch
+noinst_PROGRAMS=test-names test-pending-call-dispatch test-threads-init
test_names_SOURCES= \
- test-names.c
+ test-names.c
test_names_LDADD=$(top_builddir)/dbus/libdbus-1.la $(top_builddir)/dbus/libdbus-convenience.la
@@ -29,5 +29,10 @@
test_pending_call_dispatch_LDADD=$(top_builddir)/dbus/libdbus-1.la $(top_builddir)/dbus/libdbus-convenience.la
+test_threads_init_SOURCES = \
+ test-threads-init.c
+
+test_threads_init_LDADD=$(top_builddir)/dbus/libdbus-1.la $(top_builddir)/dbus/libdbus-convenience.la
+
endif
Index: run-test.sh
===================================================================
RCS file: /cvs/dbus/dbus/test/name-test/run-test.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- run-test.sh 10 Aug 2006 21:44:00 -0000 1.3
+++ run-test.sh 16 Aug 2006 22:30:15 -0000 1.4
@@ -31,3 +31,6 @@
echo "running test-pending-call-dispatch"
libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-pending-call-dispatch || die "test-client failed"
+
+echo "running test-threads-init"
+libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-threads-init || die "test-client failed"
--- NEW FILE: test-threads-init.c ---
/**
* Test to make sure late thread initialization works
**/
#include <dbus/dbus.h>
#include <dbus/dbus-sysdeps.h>
#include <stdio.h>
#include <stdlib.h>
#include <dbus/dbus-internals.h>
static void
_run_iteration (DBusConnection *conn)
{
DBusPendingCall *echo_pending;
DBusPendingCall *dbus_pending;
DBusMessage *method;
DBusMessage *reply;
char *echo = "echo";
/* send the first message */
method = dbus_message_new_method_call ("org.freedesktop.DBus.TestSuiteEchoService",
"/org/freedesktop/TestSuite",
"org.freedesktop.TestSuite",
"Echo");
dbus_message_append_args (method, DBUS_TYPE_STRING, &echo, NULL);
dbus_connection_send_with_reply (conn, method, &echo_pending, -1);
dbus_message_unref (method);
/* send the second message */
method = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
"org.freedesktop.Introspectable",
"Introspect");
dbus_connection_send_with_reply (conn, method, &dbus_pending, -1);
dbus_message_unref (method);
/* block on the second message (should return immediately) */
dbus_pending_call_block (dbus_pending);
/* block on the first message */
/* if it does not return immediately chances
are we hit the block in poll bug */
dbus_pending_call_block (echo_pending);
/* check the reply only to make sure we
are not getting errors unrelated
to the block in poll bug */
reply = dbus_pending_call_steal_reply (echo_pending);
if (reply == NULL)
{
printf ("Failed: Reply is NULL ***\n");
exit (1);
}
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
{
printf ("Failed: Reply is error: %s ***\n", dbus_message_get_error_name (reply));
exit (1);
}
dbus_message_unref (reply);
dbus_pending_call_unref (dbus_pending);
dbus_pending_call_unref (echo_pending);
}
static void
check_mutex_lock (DBusMutex *mutex1,
DBusMutex *mutex2,
dbus_bool_t is_same)
{
_dbus_assert (mutex1 != NULL);
_dbus_assert (mutex2 != NULL);
if (is_same)
{
_dbus_assert (mutex1 == mutex2);
}
else
{
_dbus_assert (mutex1 != mutex2);
}
}
static void
check_condvar_lock (DBusCondVar *condvar1,
DBusCondVar *condvar2,
dbus_bool_t is_same)
{
_dbus_assert (condvar1 != NULL);
_dbus_assert (condvar2 != NULL);
if (is_same)
{
_dbus_assert (condvar1 == condvar2);
}
else
{
_dbus_assert (condvar1 != condvar2);
}
}
int
main (int argc, char *argv[])
{
long start_tv_sec, start_tv_usec;
long end_tv_sec, end_tv_usec;
int i;
DBusMessage *method;
DBusConnection *conn;
DBusError error;
DBusMutex *mutex1, *dispatch_mutex1, *io_path_mutex1;
DBusCondVar *dispatch_cond1, *io_path_cond1;
DBusMutex *mutex2, *dispatch_mutex2, *io_path_mutex2;
DBusCondVar *dispatch_cond2, *io_path_cond2;
printf ("*** Testing late thread init\n");
dbus_error_init (&error);
conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
_dbus_connection_test_get_locks (conn, &mutex1,
&dispatch_mutex1,
&io_path_mutex1,
&dispatch_cond1,
&io_path_cond1);
_run_iteration (conn);
_dbus_connection_test_get_locks (conn, &mutex2,
&dispatch_mutex2,
&io_path_mutex2,
&dispatch_cond2,
&io_path_cond2);
check_mutex_lock (mutex1, mutex2, TRUE);
check_mutex_lock (dispatch_mutex1, dispatch_mutex2, TRUE);
check_mutex_lock (io_path_mutex1, io_path_mutex2, TRUE);
check_condvar_lock (dispatch_cond1, dispatch_cond2, TRUE);
check_condvar_lock (io_path_cond1, io_path_cond2, TRUE);
_dbus_threads_init_debug ();
_dbus_connection_test_get_locks (conn, &mutex1,
&dispatch_mutex1,
&io_path_mutex1,
&dispatch_cond1,
&io_path_cond1);
check_mutex_lock (mutex1, mutex2, FALSE);
check_mutex_lock (dispatch_mutex1, dispatch_mutex2, FALSE);
check_mutex_lock (io_path_mutex1, io_path_mutex2, FALSE);
check_condvar_lock (dispatch_cond1, dispatch_cond2, FALSE);
check_condvar_lock (io_path_cond1, io_path_cond2, FALSE);
_run_iteration (conn);
_dbus_connection_test_get_locks (conn, &mutex2,
&dispatch_mutex2,
&io_path_mutex2,
&dispatch_cond2,
&io_path_cond2);
check_mutex_lock (mutex1, mutex2, TRUE);
check_mutex_lock (dispatch_mutex1, dispatch_mutex2, TRUE);
check_mutex_lock (io_path_mutex1, io_path_mutex2, TRUE);
check_condvar_lock (dispatch_cond1, dispatch_cond2, TRUE);
check_condvar_lock (io_path_cond1, io_path_cond2, TRUE);
method = dbus_message_new_method_call ("org.freedesktop.TestSuiteEchoService",
"/org/freedesktop/TestSuite",
"org.freedesktop.TestSuite",
"Exit");
dbus_connection_send (conn, method, NULL);
dbus_message_unref (method);
printf ("Success ***\n");
exit (0);
}
- Previous message: dbus ChangeLog,1.1082,1.1083
- Next message: dbus/dbus dbus-connection.c, 1.125, 1.126 dbus-dataslot.c, 1.13,
1.14 dbus-dataslot.h, 1.8, 1.9 dbus-message.c, 1.176,
1.177 dbus-pending-call.c, 1.16, 1.17 dbus-server.c, 1.42,
1.43 dbus-threads-internal.h, 1.2, 1.3 dbus-threads.c, 1.24, 1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dbus-commit
mailing list