From 52e3df63bb1f985637a53e73b892f55387043cea Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 12 Sep 2013 14:11:17 +0200 Subject: [PATCH 2/4] move tests tools to tests/twisted/tools Other CMs store these files there. https://bugs.freedesktop.org/show_bug.cgi?id=69269 --- .gitignore | 4 +- configure.ac | 1 + tests/Makefile.am | 29 -------- tests/exec-with-log.sh | 46 ------------ tests/haze.service.in | 3 - tests/tmp-session-bus.conf.in | 30 -------- tests/twisted/Makefile.am | 6 +- tests/twisted/tools/Makefile.am | 24 +++++++ tests/twisted/tools/exec-with-log.sh | 46 ++++++++++++ tests/twisted/tools/haze.service.in | 3 + tests/twisted/tools/tmp-session-bus.conf.in | 30 ++++++++ tests/twisted/tools/with-session-bus.sh | 106 ++++++++++++++++++++++++++++ tools/Makefile.am | 1 - tools/with-session-bus.sh | 106 ---------------------------- 14 files changed, 216 insertions(+), 219 deletions(-) delete mode 100755 tests/exec-with-log.sh delete mode 100644 tests/haze.service.in delete mode 100644 tests/tmp-session-bus.conf.in create mode 100644 tests/twisted/tools/Makefile.am create mode 100755 tests/twisted/tools/exec-with-log.sh create mode 100644 tests/twisted/tools/haze.service.in create mode 100644 tests/twisted/tools/tmp-session-bus.conf.in create mode 100644 tests/twisted/tools/with-session-bus.sh delete mode 100644 tools/with-session-bus.sh diff --git a/.gitignore b/.gitignore index 1776590..6d8f085 100644 --- a/.gitignore +++ b/.gitignore @@ -32,8 +32,8 @@ src/telepathy-haze src/telepathy-haze.8 tags /tests/haze-testing.log -/tests/org.freedesktop.Telepathy.ConnectionManager.haze.service -/tests/tmp-session-bus.conf +/tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.haze.service +/tests/twisted/tools/tmp-session-bus.conf /tests/twisted/config.py /telepathy-haze*.tar.gz* /telepathy-haze*/ diff --git a/configure.ac b/configure.ac index c0e50a7..5b08b67 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_CONFIG_FILES([Makefile m4/Makefile tests/Makefile tests/twisted/Makefile + tests/twisted/tools/Makefile tools/Makefile extensions/Makefile ]) diff --git a/tests/Makefile.am b/tests/Makefile.am index edb1084..0677b8f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,32 +3,3 @@ SUBDIRS = . if WANT_TWISTED_TESTS SUBDIRS += twisted endif - -%.conf: %.conf.in - $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@ - -# We don't use the full filename for the .in because > 99 character filenames -# in tarballs are non-portable (and automake 1.8 doesn't let us build -# non-archaic tarballs) -org.freedesktop.Telepathy.ConnectionManager.%.service: %.service.in - $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" \ - -e "s|[@]abs_top_srcdir[@]|@abs_top_srcdir@|g" $< > $@ - -# D-Bus service file for testing -service_in_files = haze.service.in -service_files = org.freedesktop.Telepathy.ConnectionManager.haze.service - -# D-Bus config file for testing -conf_in_files = tmp-session-bus.conf.in -conf_files = $(conf_in_files:.conf.in=.conf) - -BUILT_SOURCES = $(service_files) $(conf_files) - -EXTRA_DIST = \ - $(service_in_files) \ - $(conf_in_files) \ - exec-with-log.sh - -CLEANFILES = \ - $(BUILT_SOURCES) \ - haze-testing.log diff --git a/tests/exec-with-log.sh b/tests/exec-with-log.sh deleted file mode 100755 index 54abf29..0000000 --- a/tests/exec-with-log.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -abs_top_srcdir="$1" -shift -abs_top_builddir="$1" -shift - -cd "${abs_top_builddir}/tests" - -export LC_ALL=C -export HAZE_DEBUG=all -G_MESSAGES_DEBUG=all -export G_MESSAGES_DEBUG -ulimit -c unlimited -exec >> haze-testing.log 2>&1 - -# Avoid using a non-trivial GSettings backend -GSETTINGS_BACKEND=memory -export GSETTINGS_BACKEND -# Avoid libpurple doing "clever" things -unset KDE_FULL_SESSION -unset KDEDIR -unset KDEDIRS -unset GNOME_DESKTOP_SESSION_ID - -if test -n "$HAZE_TEST_VALGRIND"; then - export G_DEBUG=${G_DEBUG:+"${G_DEBUG},"}gc-friendly - export G_SLICE=always-malloc - HAZE_WRAPPER="valgrind --leak-check=full --num-callers=20" - HAZE_WRAPPER="$HAZE_WRAPPER --show-reachable=yes" - HAZE_WRAPPER="$HAZE_WRAPPER --gen-suppressions=all" - HAZE_WRAPPER="$HAZE_WRAPPER --child-silent-after-fork=yes" - HAZE_WRAPPER="$HAZE_WRAPPER --suppressions=${abs_top_srcdir}/tools/tp-glib.supp" -elif test -n "$HAZE_TEST_REFDBG"; then - if test -z "$REFDBG_OPTIONS" ; then - export REFDBG_OPTIONS="btnum=10" - fi - if test -z "$HAZE_WRAPPER" ; then - HAZE_WRAPPER="refdbg" - fi -fi - -# not suitable for haze: -#export G_DEBUG=fatal-warnings" ${G_DEBUG}" -exec "${abs_top_builddir}/libtool" --mode=execute $HAZE_WRAPPER \ - "${abs_top_builddir}/src/telepathy-haze" diff --git a/tests/haze.service.in b/tests/haze.service.in deleted file mode 100644 index 976f8af..0000000 --- a/tests/haze.service.in +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.freedesktop.Telepathy.ConnectionManager.haze -Exec=@abs_top_srcdir@/tests/exec-with-log.sh @abs_top_srcdir@ @abs_top_builddir@ diff --git a/tests/tmp-session-bus.conf.in b/tests/tmp-session-bus.conf.in deleted file mode 100644 index c73caac..0000000 --- a/tests/tmp-session-bus.conf.in +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - session - - unix:tmpdir=/tmp - - @abs_top_builddir@/tests - - - - - - - - - - - - - - - - diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index ec838bb..89b9c14 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = tools + TWISTED_TESTS = \ avatar-requirements.py \ simple-caps.py \ @@ -32,8 +34,8 @@ check-local: check-twisted check-twisted: rm -f ../haze-testing.log - sh $(top_srcdir)/tools/with-session-bus.sh \ - --config-file=$(top_builddir)/tests/tmp-session-bus.conf \ + sh $(top_srcdir)/tests/twisted/tools/with-session-bus.sh \ + --config-file=$(top_builddir)/tests/twisted/tools/tmp-session-bus.conf \ -- $(MAKE) check-TESTS \ TESTS="$(TWISTED_TESTS)" \ TESTS_ENVIRONMENT="$(TESTS_ENVIRONMENT) $(TEST_PYTHON)" diff --git a/tests/twisted/tools/Makefile.am b/tests/twisted/tools/Makefile.am new file mode 100644 index 0000000..db691a5 --- /dev/null +++ b/tests/twisted/tools/Makefile.am @@ -0,0 +1,24 @@ +%.conf: %.conf.in + $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@ + +# We don't use the full filename for the .in because > 99 character filenames +# in tarballs are non-portable (and automake 1.8 doesn't let us build +# non-archaic tarballs) +org.freedesktop.Telepathy.ConnectionManager.%.service: %.service.in + $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" \ + -e "s|[@]abs_top_srcdir[@]|@abs_top_srcdir@|g" $< > $@ + +# D-Bus service file for testing +service_in_files = haze.service.in +service_files = org.freedesktop.Telepathy.ConnectionManager.haze.service + +# D-Bus config file for testing +conf_in_files = tmp-session-bus.conf.in +conf_files = $(conf_in_files:.conf.in=.conf) + +BUILT_SOURCES = $(service_files) $(conf_files) + +EXTRA_DIST = \ + $(service_in_files) \ + $(conf_in_files) \ + exec-with-log.sh diff --git a/tests/twisted/tools/exec-with-log.sh b/tests/twisted/tools/exec-with-log.sh new file mode 100755 index 0000000..54abf29 --- /dev/null +++ b/tests/twisted/tools/exec-with-log.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +abs_top_srcdir="$1" +shift +abs_top_builddir="$1" +shift + +cd "${abs_top_builddir}/tests" + +export LC_ALL=C +export HAZE_DEBUG=all +G_MESSAGES_DEBUG=all +export G_MESSAGES_DEBUG +ulimit -c unlimited +exec >> haze-testing.log 2>&1 + +# Avoid using a non-trivial GSettings backend +GSETTINGS_BACKEND=memory +export GSETTINGS_BACKEND +# Avoid libpurple doing "clever" things +unset KDE_FULL_SESSION +unset KDEDIR +unset KDEDIRS +unset GNOME_DESKTOP_SESSION_ID + +if test -n "$HAZE_TEST_VALGRIND"; then + export G_DEBUG=${G_DEBUG:+"${G_DEBUG},"}gc-friendly + export G_SLICE=always-malloc + HAZE_WRAPPER="valgrind --leak-check=full --num-callers=20" + HAZE_WRAPPER="$HAZE_WRAPPER --show-reachable=yes" + HAZE_WRAPPER="$HAZE_WRAPPER --gen-suppressions=all" + HAZE_WRAPPER="$HAZE_WRAPPER --child-silent-after-fork=yes" + HAZE_WRAPPER="$HAZE_WRAPPER --suppressions=${abs_top_srcdir}/tools/tp-glib.supp" +elif test -n "$HAZE_TEST_REFDBG"; then + if test -z "$REFDBG_OPTIONS" ; then + export REFDBG_OPTIONS="btnum=10" + fi + if test -z "$HAZE_WRAPPER" ; then + HAZE_WRAPPER="refdbg" + fi +fi + +# not suitable for haze: +#export G_DEBUG=fatal-warnings" ${G_DEBUG}" +exec "${abs_top_builddir}/libtool" --mode=execute $HAZE_WRAPPER \ + "${abs_top_builddir}/src/telepathy-haze" diff --git a/tests/twisted/tools/haze.service.in b/tests/twisted/tools/haze.service.in new file mode 100644 index 0000000..8ee3f3a --- /dev/null +++ b/tests/twisted/tools/haze.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.Telepathy.ConnectionManager.haze +Exec=@abs_top_srcdir@/tests/twisted/tools/exec-with-log.sh @abs_top_srcdir@ @abs_top_builddir@ diff --git a/tests/twisted/tools/tmp-session-bus.conf.in b/tests/twisted/tools/tmp-session-bus.conf.in new file mode 100644 index 0000000..84d8d65 --- /dev/null +++ b/tests/twisted/tools/tmp-session-bus.conf.in @@ -0,0 +1,30 @@ + + + + + + session + + unix:tmpdir=/tmp + + @abs_top_builddir@/tests/twisted/tools + + + + + + + + + + + + + + + + diff --git a/tests/twisted/tools/with-session-bus.sh b/tests/twisted/tools/with-session-bus.sh new file mode 100644 index 0000000..0afa593 --- /dev/null +++ b/tests/twisted/tools/with-session-bus.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# with-session-bus.sh - run a program with a temporary D-Bus session daemon +# +# The canonical location of this program is the telepathy-glib tools/ +# directory, please synchronize any changes with that copy. +# +# Copyright (C) 2007-2008 Collabora Ltd. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. + +set -e + +me=with-session-bus + +dbus_daemon_args="--print-address=5 --print-pid=6 --fork" +sleep=0 + +usage () +{ + echo "usage: $me [options] -- program [program_options]" >&2 + echo "Requires write access to the current directory." >&2 + echo "" >&2 + echo "If \$WITH_SESSION_BUS_FORK_DBUS_MONITOR is set, fork dbus-monitor" >&2 + echo "with the arguments in \$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT." >&2 + echo "The output of dbus-monitor is saved in $me-.dbus-monitor-logs" >&2 + exit 2 +} + +while test "z$1" != "z--"; do + case "$1" in + --sleep=*) + sleep="$1" + sleep="${sleep#--sleep=}" + shift + ;; + --session) + dbus_daemon_args="$dbus_daemon_args --session" + shift + ;; + --config-file=*) + # FIXME: assumes config file doesn't contain any special characters + dbus_daemon_args="$dbus_daemon_args $1" + shift + ;; + *) + usage + ;; + esac +done +shift +if test "z$1" = "z"; then usage; fi + +exec 5> $me-$$.address +exec 6> $me-$$.pid + +cleanup () +{ + pid=`head -n1 $me-$$.pid` + if test -n "$pid" ; then + if [ -n "$VERBOSE_TESTS" ]; then + echo "Killing temporary bus daemon: $pid" >&2 + fi + kill -INT "$pid" + fi + rm -f $me-$$.address + rm -f $me-$$.pid +} + +trap cleanup INT HUP TERM +dbus-daemon $dbus_daemon_args + +if [ -n "$VERBOSE_TESTS" ]; then + { echo -n "Temporary bus daemon is "; cat $me-$$.address; } >&2 + { echo -n "Temporary bus daemon PID is "; head -n1 $me-$$.pid; } >&2 +fi + +e=0 + +# These might be non-null when run from e.g. gnome-terminal 3.8, which uses +# an activatable service for its windows; we don't want to inherit them either +unset DBUS_STARTER_ADDRESS +unset DBUS_STARTER_BUS_TYPE + +DBUS_SESSION_BUS_ADDRESS="`cat $me-$$.address`" +export DBUS_SESSION_BUS_ADDRESS +DBUS_SESSION_BUS_PID="`cat $me-$$.pid`" +export DBUS_SESSION_BUS_PID + +if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then + echo -n "Forking dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2 + dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \ + > $me-$$.dbus-monitor-logs 2>&1 & +fi + +"$@" || e=$? + +if test $sleep != 0; then + sleep $sleep +fi + +trap - INT HUP TERM +cleanup + +exit $e diff --git a/tools/Makefile.am b/tools/Makefile.am index ac54560..715d792 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,5 +1,4 @@ EXTRA_DIST = \ - with-session-bus.sh \ c-constants-gen.py \ doc-generator.xsl \ glib-ginterface-gen.py \ diff --git a/tools/with-session-bus.sh b/tools/with-session-bus.sh deleted file mode 100644 index 0afa593..0000000 --- a/tools/with-session-bus.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh -# with-session-bus.sh - run a program with a temporary D-Bus session daemon -# -# The canonical location of this program is the telepathy-glib tools/ -# directory, please synchronize any changes with that copy. -# -# Copyright (C) 2007-2008 Collabora Ltd. -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. - -set -e - -me=with-session-bus - -dbus_daemon_args="--print-address=5 --print-pid=6 --fork" -sleep=0 - -usage () -{ - echo "usage: $me [options] -- program [program_options]" >&2 - echo "Requires write access to the current directory." >&2 - echo "" >&2 - echo "If \$WITH_SESSION_BUS_FORK_DBUS_MONITOR is set, fork dbus-monitor" >&2 - echo "with the arguments in \$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT." >&2 - echo "The output of dbus-monitor is saved in $me-.dbus-monitor-logs" >&2 - exit 2 -} - -while test "z$1" != "z--"; do - case "$1" in - --sleep=*) - sleep="$1" - sleep="${sleep#--sleep=}" - shift - ;; - --session) - dbus_daemon_args="$dbus_daemon_args --session" - shift - ;; - --config-file=*) - # FIXME: assumes config file doesn't contain any special characters - dbus_daemon_args="$dbus_daemon_args $1" - shift - ;; - *) - usage - ;; - esac -done -shift -if test "z$1" = "z"; then usage; fi - -exec 5> $me-$$.address -exec 6> $me-$$.pid - -cleanup () -{ - pid=`head -n1 $me-$$.pid` - if test -n "$pid" ; then - if [ -n "$VERBOSE_TESTS" ]; then - echo "Killing temporary bus daemon: $pid" >&2 - fi - kill -INT "$pid" - fi - rm -f $me-$$.address - rm -f $me-$$.pid -} - -trap cleanup INT HUP TERM -dbus-daemon $dbus_daemon_args - -if [ -n "$VERBOSE_TESTS" ]; then - { echo -n "Temporary bus daemon is "; cat $me-$$.address; } >&2 - { echo -n "Temporary bus daemon PID is "; head -n1 $me-$$.pid; } >&2 -fi - -e=0 - -# These might be non-null when run from e.g. gnome-terminal 3.8, which uses -# an activatable service for its windows; we don't want to inherit them either -unset DBUS_STARTER_ADDRESS -unset DBUS_STARTER_BUS_TYPE - -DBUS_SESSION_BUS_ADDRESS="`cat $me-$$.address`" -export DBUS_SESSION_BUS_ADDRESS -DBUS_SESSION_BUS_PID="`cat $me-$$.pid`" -export DBUS_SESSION_BUS_PID - -if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then - echo -n "Forking dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2 - dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \ - > $me-$$.dbus-monitor-logs 2>&1 & -fi - -"$@" || e=$? - -if test $sleep != 0; then - sleep $sleep -fi - -trap - INT HUP TERM -cleanup - -exit $e -- 1.8.3.1