libnm/tests: enable valgrind for libnm tests
authorThomas Haller <thaller@redhat.com>
Sun, 8 Feb 2015 10:52:22 +0000 (11:52 +0100)
committerThomas Haller <thaller@redhat.com>
Mon, 9 Feb 2015 11:10:13 +0000 (12:10 +0100)
configure.ac
libnm-glib/tests/Makefile.am
libnm/tests/Makefile.am
tools/run-test-valgrind.sh

index 3e23728..3bace48 100644 (file)
@@ -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)
 
index b053109..6ce91dd 100644 (file)
@@ -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
index f16ee3d..56dd17d 100644 (file)
@@ -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
index 84659fc..7eac4a8 100755 (executable)
@@ -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"