From ed97c7fff3f69514c32749ffcd4435abce21ad37 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 11 Jun 2008 18:01:16 -0400 Subject: [PATCH 5/7] Add a test-autolaunch * 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 | 9 ++++++++- test/name-test/run-test.sh | 3 +++ test/name-test/test-autolaunch.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletions(-) create mode 100644 test/name-test/test-autolaunch.c diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 1c73b87..9e56d0b 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -16,7 +16,7 @@ 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-names test-pending-call-dispatch test-pending-call-timeout test-threads-init test-ids test-shutdown test-privserver test-privserver-client +noinst_PROGRAMS=test-names 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 @@ -69,4 +69,11 @@ test_privserver_client_CFLAGS= test_privserver_client_LDADD=$(top_builddir)/dbus/libdbus-convenience.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-convenience.la ../libdbus-testutils.la $(DBUS_TEST_LIBS) +test_autolaunch_LDFLAGS=@R_DYNAMIC_LDFLAG@ + endif diff --git a/test/name-test/run-test.sh b/test/name-test/run-test.sh index fba4558..998c424 100755 --- a/test/name-test/run-test.sh +++ b/test/name-test/run-test.sh @@ -50,3 +50,6 @@ ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name- echo "running test-shutdown" ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-shutdown || die "test-shutdown failed" + +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 index 0000000..d3f42e3 --- /dev/null +++ b/test/name-test/test-autolaunch.c @@ -0,0 +1,31 @@ +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +#include +#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; +} -- 1.6.3.2