From a9bd5dce1cb0471c408b83814479051789beeff2 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 21 Jan 2016 23:11:29 +0100 Subject: [PATCH 1/4] tests: use dbus-run-session instead of dbus-launch The dbus-run-session utility was designed to run a process within a D-Bus session, specifically for running regressions tests and is much better suited then dbus-launch. As an additional benefit, this avoids any X dependencies. https://mail.gnome.org/archives/networkmanager-list/2016-January/msg00023.html --- libnm-glib/tests/libnm-glib-test-launch.sh | 6 +----- libnm/tests/libnm-test-launch.sh | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/libnm-glib/tests/libnm-glib-test-launch.sh b/libnm-glib/tests/libnm-glib-test-launch.sh index 980f8345e9..1064e41223 100755 --- a/libnm-glib/tests/libnm-glib-test-launch.sh +++ b/libnm-glib/tests/libnm-glib-test-launch.sh @@ -1,7 +1,3 @@ #!/bin/sh -# Spawn DBus -eval `dbus-launch --sh-syntax` -trap "kill $DBUS_SESSION_BUS_PID" EXIT - -"$@" +dbus-run-session -- "$@" diff --git a/libnm/tests/libnm-test-launch.sh b/libnm/tests/libnm-test-launch.sh index 980f8345e9..1064e41223 100755 --- a/libnm/tests/libnm-test-launch.sh +++ b/libnm/tests/libnm-test-launch.sh @@ -1,7 +1,3 @@ #!/bin/sh -# Spawn DBus -eval `dbus-launch --sh-syntax` -trap "kill $DBUS_SESSION_BUS_PID" EXIT - -"$@" +dbus-run-session -- "$@" From 5170d3a760bf423468e1c9639eaa04ce8f4f940e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 22 Jan 2016 15:49:05 +0100 Subject: [PATCH 2/4] tests: move common dbus test-runners to tools/ directory --- libnm-glib/tests/Makefile.am | 4 +--- libnm/tests/Makefile.am | 4 +--- libnm/tests/libnm-test-launch.sh | 3 --- tools/Makefile.am | 1 + .../run-test-dbus-session.sh | 0 5 files changed, 3 insertions(+), 9 deletions(-) delete mode 100755 libnm/tests/libnm-test-launch.sh rename libnm-glib/tests/libnm-glib-test-launch.sh => tools/run-test-dbus-session.sh (100%) diff --git a/libnm-glib/tests/Makefile.am b/libnm-glib/tests/Makefile.am index a1b25f62f4..138b2b320e 100644 --- a/libnm-glib/tests/Makefile.am +++ b/libnm-glib/tests/Makefile.am @@ -17,7 +17,7 @@ noinst_PROGRAMS = $(TESTS) if WITH_VALGRIND @VALGRIND_RULES@ --launch-dbus else -LOG_COMPILER = $(srcdir)/libnm-glib-test-launch.sh +LOG_COMPILER = $(top_srcdir)/tools/run-test-dbus-session.sh endif TESTS = test-nm-client test-remote-settings-client @@ -50,5 +50,3 @@ test_remote_settings_client_LDADD = \ ########################################### endif - -EXTRA_DIST = libnm-glib-test-launch.sh diff --git a/libnm/tests/Makefile.am b/libnm/tests/Makefile.am index ddcf50be80..fd9edb6fb1 100644 --- a/libnm/tests/Makefile.am +++ b/libnm/tests/Makefile.am @@ -21,7 +21,7 @@ noinst_PROGRAMS = $(TESTS) if WITH_VALGRIND @VALGRIND_RULES@ --launch-dbus else -LOG_COMPILER = $(srcdir)/libnm-test-launch.sh +LOG_COMPILER = $(top_srcdir)/tools/run-test-dbus-session.sh endif TESTS = test-nm-client test-remote-settings-client test-secret-agent @@ -40,5 +40,3 @@ test_secret_agent_SOURCES = \ $(top_builddir)/shared/nm-test-libnm-utils.h \ test-secret-agent.c endif - -EXTRA_DIST = libnm-test-launch.sh diff --git a/libnm/tests/libnm-test-launch.sh b/libnm/tests/libnm-test-launch.sh deleted file mode 100755 index 1064e41223..0000000000 --- a/libnm/tests/libnm-test-launch.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -dbus-run-session -- "$@" diff --git a/tools/Makefile.am b/tools/Makefile.am index f008956d9b..27d6bcc417 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -3,5 +3,6 @@ EXTRA_DIST = \ debug-helper.py \ doc-generator.xsl \ run-test-valgrind.sh \ + run-test-dbus-session.sh \ test-networkmanager-service.py \ test-sudo-wrapper.sh diff --git a/libnm-glib/tests/libnm-glib-test-launch.sh b/tools/run-test-dbus-session.sh similarity index 100% rename from libnm-glib/tests/libnm-glib-test-launch.sh rename to tools/run-test-dbus-session.sh From fb1da0eab211fc50eb9a39fa24c63f7fdd2d7fc4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 22 Jan 2016 16:29:36 +0100 Subject: [PATCH 3/4] tests: allow fallback to dbus-launch in case dbus-run-session is not available Like on Ubuntu 12.04 which is currently used by our Travic CI setup. --- tools/run-test-dbus-session.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/run-test-dbus-session.sh b/tools/run-test-dbus-session.sh index 1064e41223..0235d65b77 100755 --- a/tools/run-test-dbus-session.sh +++ b/tools/run-test-dbus-session.sh @@ -1,3 +1,10 @@ #!/bin/sh +if ! which dbus-run-session &>/dev/null; then + eval `dbus-launch --sh-syntax` + trap "kill $DBUS_SESSION_BUS_PID" EXIT + "$@" + exit $? +fi + dbus-run-session -- "$@" From f74a9000b1ebd2cc1bf373e10ad87039b9fd73f4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 22 Jan 2016 15:57:46 +0100 Subject: [PATCH 4/4] tests: use dbus-run-session for tools/run-test-valgrind.sh --- tools/run-test-valgrind.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/run-test-valgrind.sh b/tools/run-test-valgrind.sh index 4dc092a093..f2eeefcd02 100755 --- a/tools/run-test-valgrind.sh +++ b/tools/run-test-valgrind.sh @@ -80,10 +80,14 @@ else fi fi +NMTST_DBUS_RUN_SESSION=() if [ "$NMTST_LAUNCH_DBUS" == "yes" ]; then - # Spawn DBus - eval `dbus-launch --sh-syntax` - trap "kill $DBUS_SESSION_BUS_PID" EXIT + if ! which dbus-run-session &>/dev/null ; then + eval `dbus-launch --sh-syntax` + trap "kill $DBUS_SESSION_BUS_PID" EXIT + else + NMTST_DBUS_RUN_SESSION=(dbus-run-session --) + fi fi if [ "$NMTST_NO_VALGRIND" != "" ]; then @@ -95,6 +99,7 @@ LOGFILE="${TEST}.valgrind-log" export G_SLICE=always-malloc export G_DEBUG=gc-friendly +"${NMTST_DBUS_RUN_SESSION[@]}" \ "${NMTST_LIBTOOL[@]}" "$NMTST_VALGRIND" \ --quiet \ --error-exitcode=$VALGRIND_ERROR \