testing: added activesyncd compilation + coverage
activesyncd gets compiled completely (which should always succeed) and then only the required pieces are installed (without the things which are hard-coded for /usr, because installing those will fail). Testing is done by running a similar set of client-test tests as for remove CalDAV/CardDAV servers. activesyncd is started anew each time client-test is run, done in the new wrappercheck.sh script. Can be combined with valgrindcheck.sh: wrappercheck.sh valgrindcheck.sh activesyncd -- valgrindcheck.sh client-test ... The return code of wrappercheck.sh is the return code of the real command or the daemon, if the real command succeeded. This way the special 100 return code from valgrindcheck.sh is returned if the only problems were memory issues.
This commit is contained in:
parent
3ff6ab7dff
commit
cd7cc5e7bc
|
@ -96,7 +96,7 @@ void ActiveSyncCalendarSource::beginSync(const std::string &lastToken, const std
|
|||
|
||||
// same logic as in ActiveSyncSource::beginSync()
|
||||
|
||||
bool slowSync = false;
|
||||
// TODO: use slow sync? bool slowSync = false;
|
||||
for (bool firstIteration = true;
|
||||
moreAvailable;
|
||||
firstIteration = false) {
|
||||
|
@ -115,13 +115,13 @@ void ActiveSyncCalendarSource::beginSync(const std::string &lastToken, const std
|
|||
gerror)) {
|
||||
if (gerror.m_gerror &&
|
||||
/*
|
||||
gerror.m_gerror->domain == EAS_TYPE_CONNECTION_ERROR &&
|
||||
gerror.m_gerror->domain == EAS_TYPE_CONECTION_ERROR &&
|
||||
gerror.m_gerror->code == EAS_CONNECTION_SYNC_ERROR_INVALIDSYNCKEY && */
|
||||
gerror.m_gerror->message &&
|
||||
!strcmp(gerror.m_gerror->message, "Sync error: Invalid synchronization key") &&
|
||||
firstIteration) {
|
||||
// fall back to slow sync
|
||||
slowSync = true;
|
||||
// slowSync = true;
|
||||
setCurrentSyncKey("");
|
||||
m_trackingNode->clear();
|
||||
continue;
|
||||
|
@ -448,7 +448,7 @@ SyncSourceRaw::InsertItemResult ActiveSyncCalendarSource::insertItem(const std::
|
|||
}
|
||||
}
|
||||
|
||||
InsertItemResultState state;
|
||||
InsertItemResultState state = ITEM_OKAY;
|
||||
if (easid.empty()) {
|
||||
// New VEVENT; should not be part of an existing merged item
|
||||
// ("meeting series").
|
||||
|
|
|
@ -22,4 +22,12 @@ src_backends_activesync_syncactivesync_la_LIBADD = $(EASCLIENT_LIBS) $(SYNCEVOLU
|
|||
src_backends_activesync_syncactivesync_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
src_backends_activesync_syncactivesync_la_CPPFLAGS = $(SYNCEVOLUTION_CFLAGS) -I$(top_srcdir)/test $(BACKEND_CPPFLAGS)
|
||||
src_backends_activesync_syncactivesync_la_CXXFLAGS = $(EASCLIENT_CFLAGS) $(SYNCEVOLUTION_CXXFLAGS) $(SYNCEVO_WFLAGS) $(LIBICAL_CFLAGS)
|
||||
src_backends_activesync_syncactivesync_la_DEPENDENCIES = $(SYNCEVOLUTION_LIBS)
|
||||
src_backends_activesync_syncactivesync_la_DEPENDENCIES = $(SYNCEVOLUTION_LIBS) $(EASCLIENT_DEPENDENCIES)
|
||||
|
||||
# activated by EASCLIENT_DEPENDENCIES: usually empty, unless --with-activesyncd-src is used
|
||||
$(src_backends_activesync_src) src/backends/activesync/ActiveSyncSourceRegister.cpp: $(EASCLIENT_DEPENDENCIES)
|
||||
$(EASCLIENT_DEPENDENCIES): $(LIBEASCLIENT_LA_DEPENDENCIES)
|
||||
cd src/backends/activesync/activesyncd/build && $(MAKE)
|
||||
for i in libeasaccount/src libeasclient eas-daemon/libeas libeastest/src eas-daemon/src; do \
|
||||
(cd src/backends/activesync/activesyncd/build/$$i && $(MAKE) DESTDIR= install) || exit 1; \
|
||||
done
|
||||
|
|
|
@ -5,8 +5,39 @@ SE_ARG_ENABLE_BACKEND(activesync, activesync,
|
|||
[AS_HELP_STRING([--enable-activesync], [enable access to servers via ActiveSync (default off)])],
|
||||
[enable_activesync="$enableval"], [enable_activesync="no"])
|
||||
|
||||
AC_ARG_WITH(activesyncd-src,
|
||||
AS_HELP_STRING([--with-activesyncd-src=<base directory>],
|
||||
[Specifies location of the activesyncd source root directory.
|
||||
Use this when activesyncd is to
|
||||
be compiled as part of the SyncEvolution compilation.]),
|
||||
[ACTIVESYNCDSRC="$withval"
|
||||
test "$ACTIVESYNCDSRC" != "yes" || AC_MSG_ERROR([--with-synthesis-src requires a parameter (base directory, svn URL or git URL)])],
|
||||
[ACTIVESYNCDSRC=""])
|
||||
|
||||
AM_CONDITIONAL([BUILD_ACTIVESYNCD], [test "$enable_activesync" = "yes" && test "$ACTIVESYNCDSRC" != ""])
|
||||
|
||||
if test "$enable_activesync" = "yes"; then
|
||||
PKG_CHECK_MODULES(EASCLIENT, libeasclient)
|
||||
if test "$ACTIVESYNCDSRC" != ""; then
|
||||
# brute-force dependency on any file in the source repo
|
||||
LIBEASCLIENT_LA_DEPENDENCIES=`find "$ACTIVESYNCDSRC"/* -type f -printf '%p ' `
|
||||
AC_SUBST(LIBEASCLIENT_LA_DEPENDENCIES)
|
||||
mkdir -p src/backends/activesync/activesyncd/build
|
||||
AC_MSG_NOTICE([configuring activesyncd using the $ACTIVESYNCDSRC source code])
|
||||
( set -x; cd src/backends/activesync/activesyncd/build &&
|
||||
$ACTIVESYNCDSRC/configure --prefix=`pwd`/../install) ||
|
||||
AC_MSG_ERROR([configuring activesyncd failed])
|
||||
|
||||
# hard-coded replacement for pkg-config: necessary because
|
||||
# .pc file not installed yet
|
||||
EASCLIENT_LIBS=src/backends/activesync/activesyncd/install/lib/libeasclient.la
|
||||
EASCLIENT_DEPENDENCIES=src/backends/activesync/activesyncd/install/lib/libeasclient.la
|
||||
EASCLIENT_CFLAGS=-Isrc/backends/activesync/activesyncd/install/include/eas-daemon/eas-client
|
||||
AC_SUBST(EASCLIENT_LIBS)
|
||||
AC_SUBST(EASCLIENT_DEPENDENCIES)
|
||||
AC_SUBST(EASCLIENT_CFLAGS)
|
||||
else
|
||||
PKG_CHECK_MODULES(EASCLIENT, libeasclient)
|
||||
fi
|
||||
AC_DEFINE(ENABLE_ACTIVESYNC, 1, [ActiveSync available])
|
||||
need_ical="yes"
|
||||
need_glib="yes"
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <syncevo/util.h>
|
||||
#include "test.h"
|
||||
|
||||
#include <synthesis/SDK_util.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -1608,6 +1610,8 @@ void Cmdline::readLUIDs(SyncSource *source, list<string> &luids)
|
|||
CHECK_ERROR("next item");
|
||||
while (status != sysync::ReadNextItem_EOF) {
|
||||
luids.push_back(id.item);
|
||||
StrDispose(id.item);
|
||||
StrDispose(id.parent);
|
||||
err = ops.m_readNextItem(&id, &status, false);
|
||||
CHECK_ERROR("next item");
|
||||
}
|
||||
|
|
|
@ -518,6 +518,9 @@ sysync::TSyError SyncSourceChanges::iterate(sysync::ItemID aID,
|
|||
sysync::sInt32 *aStatus,
|
||||
bool aFirst)
|
||||
{
|
||||
aID->item = NULL;
|
||||
aID->parent = NULL;
|
||||
|
||||
if (m_first || aFirst) {
|
||||
m_it = m_items[ANY].begin();
|
||||
m_first = false;
|
||||
|
|
|
@ -489,6 +489,12 @@ bool SyncEvolution_ReadNextMapItem( CContext aContext, MapID mID, bool aFirst )
|
|||
}
|
||||
bool res = false;
|
||||
try {
|
||||
// always reset mID, just in case that caller expects it or
|
||||
// operation doesn't do it correctly
|
||||
mID->localID = NULL;
|
||||
mID->remoteID = NULL;
|
||||
mID->ident = 0;
|
||||
mID->flags = 0;
|
||||
if (source->getOperations().m_readNextMapItem) {
|
||||
res = source->getOperations().m_readNextMapItem(mID, aFirst);
|
||||
}
|
||||
|
|
|
@ -213,6 +213,7 @@ def step2(resultdir, result, servers, indents, srcdir, shellprefix, backenddir):
|
|||
'apple',
|
||||
'egroupware-dav',
|
||||
'oracle',
|
||||
'exchange',
|
||||
'dbus']
|
||||
sourceServersRun = 0
|
||||
haveSource = False
|
||||
|
|
104
test/runtests.py
104
test/runtests.py
|
@ -18,6 +18,7 @@ import os, sys, popen2, traceback, re, time, smtplib, optparse, stat, shutil, St
|
|||
import shlex
|
||||
import subprocess
|
||||
import fnmatch
|
||||
import copy
|
||||
|
||||
try:
|
||||
import gzip
|
||||
|
@ -93,6 +94,28 @@ def copyLog(filename, dirname, htaccess, lineFilter=None):
|
|||
(error.strip().replace("\"", "'").replace("<", "<").replace(">",">"),
|
||||
os.path.basename(filename)))
|
||||
|
||||
def TryKill(pid, signal):
|
||||
try:
|
||||
os.kill(pid, signal)
|
||||
except OSError, ex:
|
||||
# might have quit in the meantime, deal with the race
|
||||
# condition
|
||||
if ex.errno != 3:
|
||||
raise ex
|
||||
|
||||
def ShutdownSubprocess(popen, timeout):
|
||||
start = time.time()
|
||||
if popen.poll() == None:
|
||||
TryKill(popen.pid, signal.SIGTERM)
|
||||
while popen.poll() == None and start + timeout >= time.time():
|
||||
time.sleep(0.01)
|
||||
if popen.poll() == None:
|
||||
TryKill(popen.pid, signal.SIGKILL)
|
||||
while popen.poll() == None and start + timeout + 1 >= time.time():
|
||||
time.sleep(0.01)
|
||||
return False
|
||||
return True
|
||||
|
||||
class Action:
|
||||
"""Base class for all actions to be performed."""
|
||||
|
||||
|
@ -714,6 +737,9 @@ parser.add_option("", "--syncevo-tag",
|
|||
parser.add_option("", "--synthesis-tag",
|
||||
type="string", dest="synthesistag", default="master",
|
||||
help="the tag of the synthesis library (default = master in the moblin.org repo)")
|
||||
parser.add_option("", "--activesyncd-tag",
|
||||
type="string", dest="activesyncdtag", default="master",
|
||||
help="the tag of the activesyncd (default = master)")
|
||||
parser.add_option("", "--configure",
|
||||
type="string", dest="configure", default="",
|
||||
help="additional parameters for configure")
|
||||
|
@ -839,6 +865,14 @@ class SynthesisCheckout(GitCheckout):
|
|||
"git@gitorious.org:meego-middleware/libsynthesis.git",
|
||||
revision)
|
||||
|
||||
class ActiveSyncDCheckout(GitCheckout):
|
||||
def __init__(self, name, revision):
|
||||
"""checkout activesyncd"""
|
||||
GitCheckout.__init__(self,
|
||||
name, context.workdir, options.shell,
|
||||
"git://git.infradead.org/activesyncd.git",
|
||||
revision)
|
||||
|
||||
class SyncEvolutionBuild(AutotoolsBuild):
|
||||
def execute(self):
|
||||
AutotoolsBuild.execute(self)
|
||||
|
@ -868,6 +902,19 @@ else:
|
|||
libsynthesis = SynthesisCheckout("libsynthesis", options.synthesistag)
|
||||
context.add(libsynthesis)
|
||||
|
||||
if options.sourcedir:
|
||||
if options.nosourcedircopy:
|
||||
activesyncd = NopSource("activesyncd", options.sourcedir)
|
||||
else:
|
||||
activesyncd = GitCopy("activesyncd",
|
||||
options.workdir,
|
||||
options.shell,
|
||||
options.sourcedir,
|
||||
options.activesyncdtag)
|
||||
else:
|
||||
activesyncd = ActiveSyncDCheckout("activesyncd", options.activesyncdtag)
|
||||
context.add(activesyncd)
|
||||
|
||||
if options.sourcedir:
|
||||
if options.nosourcedircopy:
|
||||
sync = NopSource("syncevolution", options.sourcedir)
|
||||
|
@ -880,10 +927,11 @@ if options.sourcedir:
|
|||
else:
|
||||
sync = SyncEvolutionCheckout("syncevolution", options.syncevotag)
|
||||
context.add(sync)
|
||||
source = []
|
||||
if options.synthesistag:
|
||||
synthesis_source = "--with-synthesis-src=%s" % libsynthesis.basedir
|
||||
else:
|
||||
synthesis_source = ""
|
||||
source.append("--with-synthesis-src=%s" % libsynthesis.basedir)
|
||||
if options.activesyncdtag:
|
||||
source.append("--with-activesyncd-src=%s" % activesyncd.basedir)
|
||||
|
||||
# determine where binaries come from:
|
||||
# either compile anew or prebuilt
|
||||
|
@ -894,7 +942,7 @@ if options.prebuilt:
|
|||
else:
|
||||
compile = SyncEvolutionBuild("compile",
|
||||
sync.basedir,
|
||||
"%s %s" % (options.configure, synthesis_source),
|
||||
"%s %s" % (options.configure, " ".join(source)),
|
||||
options.shell,
|
||||
[ libsynthesis.name, sync.name ])
|
||||
context.add(compile)
|
||||
|
@ -1062,6 +1110,54 @@ test = SyncEvolutionTest("apple", compile,
|
|||
testPrefix=options.testprefix)
|
||||
context.add(test)
|
||||
|
||||
class ActiveSyncTest(SyncEvolutionTest):
|
||||
def __init__(self, name):
|
||||
SyncEvolutionTest.__init__(self, name,
|
||||
compile,
|
||||
"", options.shell,
|
||||
"Client::Sync::eds_event Client::Sync::eds_contact Client::Source::eas_event Client::Source::eas_contact",
|
||||
[ "eas_event", "eas_contact", "eds_event", "eds_contact" ],
|
||||
"CLIENT_TEST_NUM_ITEMS=10 "
|
||||
"CLIENT_TEST_MODE=server " # for Client::Sync
|
||||
"EAS_SOUP_LOGGER=1 "
|
||||
"EAS_DEBUG=5 "
|
||||
"EAS_DEBUG_DETACHED_RECURRENCES=1 "
|
||||
"CLIENT_TEST_LOG=activesyncd.log "
|
||||
,
|
||||
testPrefix=" ".join(("env EAS_DEBUG_FILE=activesyncd.log",
|
||||
os.path.join(sync.basedir, "test", "wrappercheck.sh"),
|
||||
options.testprefix,
|
||||
os.path.join(compile.builddir, "src", "backends", "activesync", "activesyncd", "install", "libexec", "activesyncd"),
|
||||
"--",
|
||||
options.testprefix)))
|
||||
|
||||
def executeWithActiveSync(self):
|
||||
'''start and stop activesyncd before/after running the test'''
|
||||
args = []
|
||||
if options.testprefix:
|
||||
args.append(options.testprefix)
|
||||
args.append(os.path.join(compile.builddir, "src", "backends", "activesync", "activesyncd", "install", "libexec", "activesyncd"))
|
||||
env = copy.deepcopy(os.environ)
|
||||
env['EAS_SOUP_LOGGER'] = '1'
|
||||
env['EAS_DEBUG'] = '5'
|
||||
env['EAS_DEBUG_DETACHED_RECURRENCES'] = '1'
|
||||
activesyncd = subprocess.Popen(args,
|
||||
env=env)
|
||||
try:
|
||||
SyncEvolutionTest.execute(self)
|
||||
finally:
|
||||
if not ShutdownSubprocess(activesyncd, 5):
|
||||
raise Exception("activesyncd had to be killed with SIGKILL")
|
||||
returncode = activesyncd.poll()
|
||||
if returncode != None:
|
||||
if returncode != 0:
|
||||
raise Exception("activesyncd returned %d" % returncode)
|
||||
else:
|
||||
raise Exception("activesyncd did not return")
|
||||
|
||||
test = ActiveSyncTest("exchange")
|
||||
context.add(test)
|
||||
|
||||
scheduleworldtest = SyncEvolutionTest("scheduleworld", compile,
|
||||
"", options.shell,
|
||||
"Client::Sync",
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#! /bin/bash
|
||||
#
|
||||
# wrappercheck.sh background command args ... -- command args ...
|
||||
#
|
||||
# Wrapper script which runs one command in the background and the
|
||||
# other in the foreground. Once that second command completes, the
|
||||
# first one is send a SIGINT, then a SIGTERM until it terminates.
|
||||
#
|
||||
# Overall return code of this script is the return code of the
|
||||
# foreground command or, if that is 0, the background command.
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
PIDS=
|
||||
|
||||
trap "kill -TERM $PIDS" TERM
|
||||
trap "kill -INT $PIDS" INT
|
||||
|
||||
declare -a BACKGROUND
|
||||
while [ $# -gt 1 ] && [ "$1" != "--" ] ; do
|
||||
BACKGROUND[${#BACKGROUND[*]}]="$1"
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
( set +x; echo "*** starting background daemon" )
|
||||
( set -x; exec "${BACKGROUND[@]}" ) &
|
||||
BACKGROUND_PID=$!
|
||||
PIDS+="$BACKGROUND_PID"
|
||||
|
||||
set +e
|
||||
(set -x; "$@")
|
||||
RET=$?
|
||||
set -e
|
||||
|
||||
( set +x; echo "*** killing and waiting for ${BACKGROUND[0]}" )
|
||||
kill -INT $BACKGROUND_PID || true
|
||||
set +e
|
||||
wait $BACKGROUND_PID
|
||||
SUBRET=$?
|
||||
set -e
|
||||
if [ $RET = 0 ]; then
|
||||
RET=$SUBRET
|
||||
fi
|
||||
|
||||
exit $RET
|
Loading…
Reference in New Issue