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.
This commit is contained in:
Thomas Haller 2016-10-15 15:34:05 +02:00
parent 274de2555b
commit cd98705d21
6 changed files with 24 additions and 26 deletions

View file

@ -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)

View file

@ -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 #######

View file

@ -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 = \

View file

@ -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

View file

@ -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 \

View file

@ -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 -- "$@"