From e7356ef0a6fa94b20850d6f8ca73bfac17589510 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 8 Feb 2015 11:52:22 +0100 Subject: [PATCH] libnm/tests: enable valgrind for libnm tests --- configure.ac | 1 + libnm-glib/tests/Makefile.am | 8 +++++--- libnm/tests/Makefile.am | 9 +++++---- tools/run-test-valgrind.sh | 8 ++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 3e23728e33..3bace48e27 100644 --- a/configure.ac +++ b/configure.ac @@ -891,6 +891,7 @@ AM_CONDITIONAL(REQUIRE_ROOT_TESTS, test "$enable_tests" == "root") 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) diff --git a/libnm-glib/tests/Makefile.am b/libnm-glib/tests/Makefile.am index b053109b62..6ce91dd931 100644 --- a/libnm-glib/tests/Makefile.am +++ b/libnm-glib/tests/Makefile.am @@ -12,7 +12,11 @@ AM_CPPFLAGS = \ 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 ####### @@ -43,8 +47,6 @@ test_remote_settings_client_LDADD = \ ########################################### -TESTS_ENVIRONMENT = $(srcdir)/libnm-glib-test-launch.sh - endif EXTRA_DIST = libnm-glib-test-launch.sh diff --git a/libnm/tests/Makefile.am b/libnm/tests/Makefile.am index f16ee3de7e..56dd17d5f8 100644 --- a/libnm/tests/Makefile.am +++ b/libnm/tests/Makefile.am @@ -17,7 +17,11 @@ LDADD = \ 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 = \ @@ -34,9 +38,6 @@ test_secret_agent_SOURCES = \ common.c \ common.h \ test-secret-agent.c - -TESTS_ENVIRONMENT = $(srcdir)/libnm-test-launch.sh - endif EXTRA_DIST = libnm-test-launch.sh diff --git a/tools/run-test-valgrind.sh b/tools/run-test-valgrind.sh index 84659fc85b..7eac4a80b7 100755 --- a/tools/run-test-valgrind.sh +++ b/tools/run-test-valgrind.sh @@ -3,6 +3,14 @@ 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"