AS_IF([test "$with_valgrind" != "no"],
AC_SUBST(VALGRIND_RULES, 'TESTS_ENVIRONMENT = "$(top_srcdir)/tools/run-test-valgrind.sh" "$(LIBTOOL)" "$(with_valgrind)" "$(top_srcdir)/valgrind.suppressions"'),
AC_SUBST(VALGRIND_RULES, []))
+AM_CONDITIONAL(WITH_VALGRIND, test "${with_valgrind}" != "no")
GTK_DOC_CHECK(1.0)
noinst_PROGRAMS = $(TESTS)
-#@VALGRIND_RULES@
+if WITH_VALGRIND
+@VALGRIND_RULES@ --launch-dbus
+else
+TESTS_ENVIRONMENT = $(srcdir)/libnm-test-launch.sh
+endif
TESTS = test-nm-client test-remote-settings-client
####### NMClient and non-settings tests #######
###########################################
-TESTS_ENVIRONMENT = $(srcdir)/libnm-glib-test-launch.sh
-
endif
EXTRA_DIST = libnm-glib-test-launch.sh
noinst_PROGRAMS = $(TESTS)
-#@VALGRIND_RULES@
+if WITH_VALGRIND
+@VALGRIND_RULES@ --launch-dbus
+else
+TESTS_ENVIRONMENT = $(srcdir)/libnm-test-launch.sh
+endif
TESTS = test-nm-client test-remote-settings-client test-secret-agent
test_nm_client_SOURCES = \
common.c \
common.h \
test-secret-agent.c
-
-TESTS_ENVIRONMENT = $(srcdir)/libnm-test-launch.sh
-
endif
EXTRA_DIST = libnm-test-launch.sh
LIBTOOL="$1"; shift
VALGRIND="$1"; shift
SUPPRESSIONS="$1"; shift
+if [ "$1" = "--launch-dbus" ]; then
+ # Spawn DBus if there's none
+ if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
+ eval `dbus-launch --sh-syntax`
+ trap "kill $DBUS_SESSION_BUS_PID" EXIT
+ fi
+ shift
+fi
TEST="$1"; shift
LOGFILE="valgrind-`echo "$TEST" | tr -cd '[:alpha:]-'`.log"