Added a test-autolaunch.
authorColin Walters <walters@verbum.org>
Wed, 11 Jun 2008 22:01:16 +0000 (18:01 -0400)
committerRalf Habacker <ralf.habacker@freenet.de>
Sat, 4 Dec 2010 22:03:13 +0000 (23:03 +0100)
* test/name-test/test-autolaunch.c: New file,
unsets DBUS_SESSION_BUS_ADDRESS so we should
fall back to autolaunch:.
* test/name-test/run-test.sh: Run it.
* test/name-test/Makefile.am: Build it.

test/name-test/Makefile.am
test/name-test/run-test.sh
test/name-test/test-autolaunch.c [new file with mode: 0644]

index 11dc56d..1b5722b 100644 (file)
@@ -16,7 +16,13 @@ if DBUS_BUILD_TESTS
 
 ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
 ## build even when not doing "make check"
-noinst_PROGRAMS=test-pending-call-dispatch test-pending-call-timeout test-threads-init test-ids test-shutdown test-privserver test-privserver-client
+noinst_PROGRAMS=test-pending-call-dispatch test-pending-call-timeout test-threads-init test-ids test-shutdown test-privserver test-privserver-client test-autolaunch
+
+test_names_SOURCES=                            \
+       test-names.c
+
+test_names_LDADD=$(top_builddir)/dbus/libdbus-convenience.la $(DBUS_TEST_LIBS)
+test_names_LDFLAGS=@R_DYNAMIC_LDFLAG@
 
 AM_CPPFLAGS = -DDBUS_STATIC_BUILD
 test_pending_call_dispatch_SOURCES =           \
@@ -64,4 +70,11 @@ test_privserver_client_CFLAGS=
 test_privserver_client_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la $(DBUS_TEST_LIBS)
 test_privserver_client_LDFLAGS=@R_DYNAMIC_LDFLAG@
 
+test_autolaunch_SOURCES =            \
+       test-autolaunch.c
+
+test_autolaunch_CFLAGS=
+test_autolaunch_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la $(DBUS_TEST_LIBS)
+test_autolaunch_LDFLAGS=@R_DYNAMIC_LDFLAG@
+
 endif
index 832ce0a..a70055b 100755 (executable)
@@ -53,3 +53,6 @@ if ! python $DBUS_TOP_SRCDIR/test/name-test/test-activation-forking.py; then
   echo "Failed test-activation-forking"
   exit 1
 fi
+
+echo "running test-autolaunch"
+${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-autolaunch || die "test-autolaunch failed"
diff --git a/test/name-test/test-autolaunch.c b/test/name-test/test-autolaunch.c
new file mode 100644 (file)
index 0000000..d3f42e3
--- /dev/null
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <dbus/dbus.h>
+#include "dbus/dbus-sysdeps.h"
+
+int
+main (int argc, char *argv[])
+{
+  DBusConnection *conn = NULL;
+  DBusError error;
+
+  _dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", NULL);
+
+  dbus_error_init (&error);
+
+  conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
+  if (dbus_error_is_set (&error))
+    {
+      fprintf (stderr, "*** Failed to autolaunch session bus: %s\n",
+               error.message);
+      dbus_error_free (&error);
+      return 1;
+    }
+
+  return 0;
+}