Re: [Evolution-hackers] "make check" failing in the e-d-s gnome-2-32
- From: Murray Cumming <murrayc murrayc com>
- To: Raul Gutierrez Segales <raul gutierrez segales collabora co uk>
- Cc: Tristan Van Berkom <tristanvb openismus com>, evolution-hackers gnome org
- Subject: Re: [Evolution-hackers] "make check" failing in the e-d-s gnome-2-32
- Date: Wed, 15 Jun 2011 13:39:52 +0200
On Thu, 2011-06-09 at 14:03 +0100, Raul Gutierrez Segales wrote:
[snip]
> Matthew Barnes wrote:
> > You could probably get away with just using a date stamp instead of
> > random characters for XXXXXX. The key is really for each address book
> > to have its own unique ESource ID.
The attached patch uses mktemp to create a randomly-named tmp
directory.
[snip]
> > To really automate the whole thing, the test environment is gonna have
> > to set up some kind of private D-Bus session and launch the address book
> > service prior to running the client-side tests, and then clean up after
> > itself. I think that's possible but it's a bit beyond my expertise at
> > the moment.
> >
> > You can kinda see why I've been dragging my feet about fixing the tests.
> > Haven't had enough spare cycles to really do it properly.
>
> For the e-d-s backend in libfolks (not merged into master yet) we do the
> following for our tests:
>
> - set XDG_DATA_HOME, XDG_CACHE_HOME and XDG_CONFIG_HOME to a temp dir
> - start new session bus
> - run tests
> - clean up temp dir
>
> Relevant files:
>
> http://cgit.collabora.com/git/user/rgs/folks/tree/tests/eds/Makefile.am?h=eds-0.5
> http://cgit.collabora.com/git/user/rgs/folks/tree/tests/tools/with-session-bus-eds.sh?h=eds-0.5
> http://cgit.collabora.com/git/user/rgs/folks/tree/tests/tools/eds.sh?h=eds-0.5
Many thanks for that. I've taken the relevant bits for e-d-s - see the
attached patch against the gnome-2-32 branch. If this is OK, I can try
to do this for the master branch.
It seems to work, though make doesn't tell me more about what's
happening with each test than "PASSED" so I am not really sure that
anything much is happening.
This sets the XDG_* variables, but doesn't seem to start the address
book service, right? Or maybe that happens automatically via activation,
though I worry that that would require "make install" before "make
check".
One test still fails for me, either with this:
** (process:5762): WARNING **: failed to remove book; Cannot remove
book: Failed to remove file '(null)': Bad address
FAIL: test-ebook-stress-factory--single-book
or this:
(process:6466): libebook-WARNING **: e-book.c:3095: cannot get book from
factory: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message did not
receive a reply (timeout by message bus)
** ERROR **: failed to create addressbook:
`local:/tmp/ebook-test-LBFVWV/':
GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message did not receive
a reply (timeout by message bus)
Trace/breakpoint trap
FAIL: test-ebook-stress-factory--single-book
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
>From 3fb4984fa7f353ac7fe2726b557dd3536419026a Mon Sep 17 00:00:00 2001
From: Murray Cumming <murrayc murrayc com>
Date: Wed, 15 Jun 2011 13:15:07 +0200
Subject: [PATCH] * addressbook/tests/: Add a tools/ directory with .sh files from
libfolks/tests/tools/, to let us start and stop a private D-Bus
session, and set XDG_* environment variables for local use of EDS,
when running tests.
* addressbook/tests/ebook/Makefile.am: Set TESTS_ENVIRONMENT to
run the tests with the private D-Bus session.
---
addressbook/tests/Makefile.am | 2 +-
addressbook/tests/ebook/Makefile.am | 7 ++
addressbook/tests/tools/Makefile.am | 5 +
addressbook/tests/tools/dbus-session.sh | 114 +++++++++++++++++++++++
addressbook/tests/tools/eds.sh | 25 +++++
addressbook/tests/tools/with-session-bus-eds.sh | 44 +++++++++
configure.ac | 1 +
7 files changed, 197 insertions(+), 1 deletions(-)
create mode 100644 addressbook/tests/tools/Makefile.am
create mode 100644 addressbook/tests/tools/dbus-session.sh
create mode 100644 addressbook/tests/tools/eds.sh
create mode 100755 addressbook/tests/tools/with-session-bus-eds.sh
diff --git a/addressbook/tests/Makefile.am b/addressbook/tests/Makefile.am
index 591bdff..36ae876 100644
--- a/addressbook/tests/Makefile.am
+++ b/addressbook/tests/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = vcard ebook
+SUBDIRS = tools vcard ebook
-include $(top_srcdir)/git.mk
diff --git a/addressbook/tests/ebook/Makefile.am b/addressbook/tests/ebook/Makefile.am
index 32c8e40..3671344 100644
--- a/addressbook/tests/ebook/Makefile.am
+++ b/addressbook/tests/ebook/Makefile.am
@@ -22,6 +22,13 @@ TEST_LIBS = \
libebook-test-utils.la \
$(NULL)
+RUN_WITH_PRIVATE_BUS = $(top_srcdir)/addressbook/tests/tools/with-session-bus-eds.sh
+
+TESTS_ENVIRONMENT = \
+ $(RUN_WITH_PRIVATE_BUS) \
+ --session \
+ --
+
# Should be kept ordered approximately from least to most difficult/complex
TESTS = \
test-ebook-remove \
diff --git a/addressbook/tests/tools/Makefile.am b/addressbook/tests/tools/Makefile.am
new file mode 100644
index 0000000..6abf3bc
--- /dev/null
+++ b/addressbook/tests/tools/Makefile.am
@@ -0,0 +1,5 @@
+EXTRA_DIST = \
+ with-session-bus.sh \
+ dbus-session.sh
+
+-include $(top_srcdir)/git.mk
diff --git a/addressbook/tests/tools/dbus-session.sh b/addressbook/tests/tools/dbus-session.sh
new file mode 100644
index 0000000..1f805bf
--- /dev/null
+++ b/addressbook/tests/tools/dbus-session.sh
@@ -0,0 +1,114 @@
+#
+# Helper functions to start your own D-Bus session.
+#
+# Refactored from with-session-bush.sh (from telepathy-glib).
+#
+# The canonical location of this program is the telepathy-glib tools/
+# directory, please synchronize any changes with that copy.
+#
+# Copyright (C) 2007-2008,2011 Collabora Ltd. <http://www.collabora.co.uk/>
+#
+# 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.
+
+
+dbus_daemon_args="--print-address=5 --print-pid=6 --fork"
+dbus_verbose=0
+dbus_me=with-session-bus
+dbus_sleep=0
+dbus_with_session=""
+dbus_config_file=""
+
+# Params:
+# verbose: 0 for off and 1 for on
+#
+dbus_init () {
+ exec 5> $dbus_me-$$.address
+ exec 6> $dbus_me-$$.pid
+ dbus_verbose=$1
+}
+
+dbus_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-<pid>.dbus-monitor-logs" >&2
+ exit 2
+}
+
+dbus_parse_args () {
+ while test "z$1" != "z--"; do
+ case "$1" in
+ --sleep=*)
+ sleep="$1"
+ dbus_sleep="${sleep#--sleep=}"
+ shift
+ ;;
+ --session)
+ dbus_with_session="--session"
+ shift
+ ;;
+ --config-file=*)
+ # FIXME: assumes config file doesn't contain any special characters
+ dbus_config_file="$1"
+ shift
+ ;;
+ *)
+ dbus_usage
+ ;;
+ esac
+ done
+}
+
+dbus_start () {
+ local args="$dbus_daemon_args $dbus_with_session $dbus_config_file "
+
+ if [ $dbus_verbose -gt 0 ] ; then
+ echo -n "dbus args $args "
+ fi
+
+ dbus-daemon $args
+
+ {
+ if [ $dbus_verbose -gt 0 ] ; then
+ echo -n "Temporary bus daemon is "; cat $dbus_me-$$.address;
+ fi
+ } >&2
+
+ {
+ if [ $dbus_verbose -gt 0 ] ; then
+ echo -n "Temporary bus daemon PID is "; head -n1 $dbus_me-$$.pid;
+ fi
+ } >&2
+
+ DBUS_SESSION_BUS_ADDRESS="`cat $dbus_me-$$.address`"
+ export DBUS_SESSION_BUS_ADDRESS
+
+ if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then
+ if [ $dbus_verbose -gt 0 ] ; then
+ echo -n "Forking dbus-monitor " \
+ "$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2
+ fi
+ dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \
+ > $dbus_me-$$.dbus-monitor-logs 2>&1 &
+ fi
+}
+
+#
+# This should be called for INT, HUP and TERM signals
+#
+dbus_stop () {
+ pid=`head -n1 $dbus_me-$$.pid`
+ if test -n "$pid" ; then
+ if [ $dbus_verbose -gt 0 ] ; then
+ echo "Killing temporary bus daemon: $pid" >&2
+ fi
+ kill -INT "$pid"
+ fi
+ rm -f $dbus_me-$$.address
+ rm -f $dbus_me-$$.pid
+}
diff --git a/addressbook/tests/tools/eds.sh b/addressbook/tests/tools/eds.sh
new file mode 100644
index 0000000..852ba2b
--- /dev/null
+++ b/addressbook/tests/tools/eds.sh
@@ -0,0 +1,25 @@
+#
+# Helper functions to start your own e-d-s instance. This depends
+# on you having your own D-Bus session bus started (first).
+#
+#
+# Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+#
+# 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.
+
+eds_tmpdir=$(mktemp -d)
+
+eds_init_settings () {
+ export XDG_DATA_HOME=$eds_tmpdir/.local
+ export XDG_CACHE_HOME=$eds_tmpdir/.cache
+ export XDG_CONFIG_HOME=$eds_tmpdir/.config
+}
+
+# This should be called on INT TERM and EXIT
+eds_stop () {
+ rm -rf $eds_tmpdir
+ rm -rf $eds_tmpdir
+}
+
diff --git a/addressbook/tests/tools/with-session-bus-eds.sh b/addressbook/tests/tools/with-session-bus-eds.sh
new file mode 100755
index 0000000..b5cab54
--- /dev/null
+++ b/addressbook/tests/tools/with-session-bus-eds.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# with-session-bus-eds.sh - run a program with a temporary D-Bus session daemon
+#
+# interesting bits have been move into dbus to permit reusability
+#
+# Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/>
+#
+# 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.
+
+
+cur_dir=`dirname $0`
+
+. $cur_dir"/dbus-session.sh"
+. $cur_dir"/eds.sh"
+
+dbus_parse_args $@
+while test "z$1" != "z--"; do
+ shift
+done
+shift
+if test "z$1" = "z"; then dbus_usage; fi
+
+cleanup ()
+{
+ eds_stop
+ dbus_stop
+}
+
+trap cleanup INT HUP TERM
+
+eds_init_settings
+dbus_init 0
+
+dbus_start
+
+e=0
+"$@" || e=$?
+
+trap - INT HUP TERM
+cleanup
+
+exit $e
diff --git a/configure.ac b/configure.ac
index 4e0c9c8..0879fcf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1456,6 +1456,7 @@ addressbook/backends/webdav/Makefile
addressbook/tests/Makefile
addressbook/tests/ebook/Makefile
addressbook/tests/vcard/Makefile
+addressbook/tests/tools/Makefile
art/Makefile
calendar/Makefile
calendar/libecal/Makefile
--
1.7.4.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]