From: Simon McVittie Date: Wed, 5 Jul 2017 14:32:40 +0000 (+0100) Subject: tests: Make tests fail if they try to connect to the real session bus X-Git-Tag: dbus-1.10.22~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f2f239fc83cd902ceeb73b5338fd8afa3563d649;p=thirdparty%2Fdbus.git tests: Make tests fail if they try to connect to the real session bus It is too easy for a developer working in an environment that has a session bus to write tests that pass locally, but fail in minimal environments. This is also risky because the tests might do destructive things on the developer's real session bus. We can avoid connecting to the session bus by consistently removing its address from the environment, and replacing it with something that will always fail. Signed-off-by: Simon McVittie Reviewed-by: Philip Withnall Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101698 --- diff --git a/test/Makefile.am b/test/Makefile.am index 914dd7f2f..1f4057ee0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -200,6 +200,7 @@ installable_test_meta_with_config = \ installcheck_tests = installcheck_environment = \ export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \ + export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \ export DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT); \ export DBUS_TEST_DBUS_LAUNCH=$(DESTDIR)$(bindir)/dbus-launch$(EXEEXT); \ export DBUS_TEST_DBUS_MONITOR=$(DESTDIR)$(bindir)/dbus-monitor$(EXEEXT); \ @@ -211,6 +212,7 @@ installcheck_environment = \ AM_TESTS_ENVIRONMENT = \ export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \ export DBUS_FATAL_WARNINGS=1; \ + export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \ export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \ export DBUS_TEST_DBUS_LAUNCH=@abs_top_builddir@/tools/dbus-launch$(EXEEXT); \ export DBUS_TEST_DBUS_MONITOR=@abs_top_builddir@/tools/dbus-monitor$(EXEEXT); \ diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 8ec9de899..92227ed83 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -28,6 +28,7 @@ TESTS = if DBUS_ENABLE_EMBEDDED_TESTS if DBUS_UNIX AM_TESTS_ENVIRONMENT = \ + export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \ export DBUS_TOP_BUILDDIR=@abs_top_builddir@; \ export DBUS_TOP_SRCDIR=@abs_top_srcdir@; \ export PATH="@abs_top_builddir@/bus:$$PATH"; \ @@ -35,7 +36,6 @@ AM_TESTS_ENVIRONMENT = \ export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \ export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \ export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \ - unset DBUS_SESSION_BUS_ADDRESS; \ unset DBUS_SESSION_BUS_PID; \ $(NULL)