test/bin-test/test-dav-sync.sh

Mon, 16 Sep 2019 19:49:04 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 16 Sep 2019 19:49:04 +0200
changeset 642
4e23087d3d90
parent 641
b138d1241e68
child 643
5b8643cf0a2f
permissions
-rwxr-xr-x

add config element for push strategy

#!/bin/sh
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright 2019 Olaf Wintermann. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#   1. Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#
#   2. Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in the
#      documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

if [ $# -lt 2 ];
then
	echo "usage:" $0 "<dav-binary> <dav-sync-binary>"
	exit 1
fi

# check if binaries exist
which $1 > /dev/null
if [ $? -ne 0 ];
then
	exit 1
fi
which $2 > /dev/null
if [ $? -ne 0 ];
then
	exit 1
fi

DAV_BIN=$1
DAV_SYNC_BIN=$2
export DAV_BIN
export DAV_SYNC_BIN

# create config
rm -Rf .dav
cp -R $HOME/.dav/ .dav/
cp dav-home/sync.xml .dav/sync.xml
export HOME=`pwd`

# tmp sync dir
rm -Rf tmp-sync
mkdir tmp-sync
mkdir tmp-sync/test1a
mkdir tmp-sync/test1b
mkdir tmp-sync/test2a
mkdir tmp-sync/test2b


# check if config works
TEST1_DIR=`$DAV_SYNC_BIN list-dirs | grep test1a | tail -n 1`
if [ -z $TEST1_DIR ];
then
	echo "Config not working"
	rm -Rf .dav
	rm -Rf tmp-sync
	exit 1
fi

# clean test repo and files
$DAV_BIN rm -N dav-test-repo/tests/ 2> /dev/null
$DAV_BIN rm -N dav-test-repo/sync/ 2> /dev/null

do_test()
{
	printf "TEST: $1 ... "
	./$2
	if [ $? -ne 0 ]; then
		rm -Rf .dav
		exit 2
	fi
	echo ok
}

#
# ok, begin the tests
#
do_test "dav-sync push (1)" test-dav-sync-push1.sh
do_test "dav-sync pull (1)" test-dav-sync-pull1.sh
do_test "dav-sync pull conflict (1)" test-dav-sync-pull-conflict.sh
do_test "dav-sync push conflict (1)" test-dav-sync-push-conflict.sh
do_test "dav-sync hashing" test-dav-sync-hashing.sh

# cleanup
$DAV_BIN rm dav-test-repo/sync/test1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
	echo "cleanup failed"
	exit 2
fi

rm -Rf .dav
rm -Rf tmp-sync

mercurial