From cd98705d215c139b41efbdf8409c57e2cf146bef Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 15 Oct 2016 15:34:05 +0200 Subject: [PATCH] tests: combine "run-test-valgrind.sh" and "run-test-dbus-session.sh" in "run-nm-test.sh" No need to have two test-runners. Combine them, and call tests always via "tools/run-nm-test.sh". Yes, this brings an overhead, that we now always invoke the test with a test wrapper script, also --without-vagrind. Previously, that was only necessary for libnm tests that require their own D-Bus session. Later we will do non-recursive Makefiles, thus all tests should have the same LOG_COMPILER. --- configure.ac | 5 +--- libnm-glib/tests/Makefile.am | 4 ---- libnm/tests/Makefile.am | 4 ---- tools/Makefile.am | 3 +-- .../{run-test-valgrind.sh => run-nm-test.sh} | 24 +++++++++++++++++-- tools/run-test-dbus-session.sh | 10 -------- 6 files changed, 24 insertions(+), 26 deletions(-) rename tools/{run-test-valgrind.sh => run-nm-test.sh} (89%) delete mode 100755 tools/run-test-dbus-session.sh diff --git a/configure.ac b/configure.ac index 7b038fd508..24f50ef70d 100644 --- a/configure.ac +++ b/configure.ac @@ -1069,10 +1069,7 @@ else with_valgrind_suppressions='$(top_srcdir)/valgrind.suppressions' fi fi -AS_IF([test "$with_valgrind" != "no"], - AC_SUBST(NM_LOG_COMPILER, 'LOG_COMPILER = "$(top_srcdir)/tools/run-test-valgrind.sh" --called-from-make "$(LIBTOOL)" "$(with_valgrind)" '"$with_valgrind_suppressions"), - AC_SUBST(NM_LOG_COMPILER, [])) -AM_CONDITIONAL(WITH_VALGRIND, test "${with_valgrind}" != "no") +AC_SUBST(NM_LOG_COMPILER, 'LOG_COMPILER = "$(top_srcdir)/tools/run-nm-test.sh" --called-from-make "$(LIBTOOL)" "$(with_valgrind)" "'"$with_valgrind_suppressions"'"'), GTK_DOC_CHECK(1.0) diff --git a/libnm-glib/tests/Makefile.am b/libnm-glib/tests/Makefile.am index 4a51eba750..9d15802697 100644 --- a/libnm-glib/tests/Makefile.am +++ b/libnm-glib/tests/Makefile.am @@ -13,11 +13,7 @@ AM_CPPFLAGS = \ noinst_PROGRAMS = $(TESTS) -if WITH_VALGRIND @NM_LOG_COMPILER@ --launch-dbus -else -LOG_COMPILER = $(top_srcdir)/tools/run-test-dbus-session.sh -endif TESTS = test-nm-client test-remote-settings-client ####### NMClient and non-settings tests ####### diff --git a/libnm/tests/Makefile.am b/libnm/tests/Makefile.am index 5507c5267f..a143abaf51 100644 --- a/libnm/tests/Makefile.am +++ b/libnm/tests/Makefile.am @@ -17,11 +17,7 @@ LDADD = \ noinst_PROGRAMS = $(TESTS) -if WITH_VALGRIND @NM_LOG_COMPILER@ --launch-dbus -else -LOG_COMPILER = $(top_srcdir)/tools/run-test-dbus-session.sh -endif TESTS = test-nm-client test-remote-settings-client test-secret-agent test_nm_client_SOURCES = \ diff --git a/tools/Makefile.am b/tools/Makefile.am index b59b2a97d0..c2b3912775 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,8 +2,7 @@ EXTRA_DIST = \ check-exports.sh \ create-exports-NetworkManager.sh \ debug-helper.py \ - run-test-valgrind.sh \ - run-test-dbus-session.sh \ + run-nm-test.sh \ test-networkmanager-service.py \ test-sudo-wrapper.sh \ enums-to-docbook.pl diff --git a/tools/run-test-valgrind.sh b/tools/run-nm-test.sh similarity index 89% rename from tools/run-test-valgrind.sh rename to tools/run-nm-test.sh index 65c98ce5f7..809e95b739 100755 --- a/tools/run-test-valgrind.sh +++ b/tools/run-nm-test.sh @@ -8,6 +8,7 @@ die() { SCRIPT_PATH="${SCRIPT_PATH:-$(readlink -f "$(dirname "$0")")}" VALGRIND_ERROR=37 + if [ "$1" == "--called-from-make" ]; then shift NMTST_LIBTOOL=($1 --mode=execute); shift @@ -20,6 +21,10 @@ if [ "$1" == "--called-from-make" ]; then NMTST_LAUNCH_DBUS=no fi TEST="$1"; shift + + if [[ "$NMTST_VALGRIND" == no ]]; then + NMTST_VALGRIND= + fi else if [ -n "${NMTST_LIBTOOL-:x}" ]; then NMTST_LIBTOOL=(sh "$SCRIPT_PATH/../libtool" --mode=execute) @@ -42,6 +47,16 @@ else NMTST_LIBTOOL=() shift ;; + "--valgrind") + NMTST_NO_VALGRIND= + NMTST_VALGRIND=valgrind + shift; + ;; + "--no-valgrind") + NMTST_NO_VALGRIND=no + NMTST_VALGRIND="" + shift; + ;; "--") shift break @@ -90,18 +105,23 @@ if [ "$NMTST_LAUNCH_DBUS" == "yes" ]; then fi fi -if [ "$NMTST_NO_VALGRIND" != "" ]; then +[ -x "$TEST" ] || die "Cannot execute test \"$TEST\"" + + +if [ "$NMTST_NO_VALGRIND" != "" -o "$NMTST_VALGRIND" == "" ]; then "${NMTST_DBUS_RUN_SESSION[@]}" \ "$TEST" "$@" exit $? fi + LOGFILE="${TEST}.valgrind-log" export G_SLICE=always-malloc export G_DEBUG=gc-friendly "${NMTST_DBUS_RUN_SESSION[@]}" \ -"${NMTST_LIBTOOL[@]}" "$NMTST_VALGRIND" \ +"${NMTST_LIBTOOL[@]}" \ +"$NMTST_VALGRIND" \ --quiet \ --error-exitcode=$VALGRIND_ERROR \ --leak-check=full \ diff --git a/tools/run-test-dbus-session.sh b/tools/run-test-dbus-session.sh deleted file mode 100755 index c6a94fa6cc..0000000000 --- a/tools/run-test-dbus-session.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -if ! which dbus-run-session >/dev/null 2>&1; then - eval `dbus-launch --sh-syntax` - trap "kill $DBUS_SESSION_BUS_PID" EXIT - "$@" - exit $? -fi - -dbus-run-session -- "$@"