Wed, 04 Sep 2019 19:28:10 +0200
add first dav-sync hashing test
--- a/test/bin-test/dav-home/sync.xml Tue Sep 03 21:24:17 2019 +0200 +++ b/test/bin-test/dav-home/sync.xml Wed Sep 04 19:28:10 2019 +0200 @@ -20,4 +20,27 @@ <trash>.trash</trash> <database>dav-sync-tests-test1b-db.xml</database> </directory> + + <!-- + Test 2: default settings after add-directory + --> + <directory> + <name>test2a</name> + <path>$HOME/tmp-sync/test2a</path> + <repository>dav-test-repo</repository> + <collection>/sync/test2</collection> + <trash>.trash</trash> + <database>dav-sync-tests-test2a-db.xml</database> + <hashing>true</hashing> + </directory> + + <directory> + <name>test2b</name> + <path>$HOME/tmp-sync/test2b</path> + <repository>dav-test-repo</repository> + <collection>/sync/test2</collection> + <trash>.trash</trash> + <database>dav-sync-tests-test2b-db.xml</database> + <hashing>true</hashing> + </directory> </configuration>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bin-test/test-dav-sync-hashing.sh Wed Sep 04 19:28:10 2019 +0200 @@ -0,0 +1,115 @@ +#!/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 [ -z "$DAV_BIN" ]; +then + echo "DAV_BIN variable not set" + exit 1 +fi +if [ -z "$DAV_SYNC_BIN" ]; +then + echo "DAV_BIN variable not set" + exit 1 +fi + +# checks if tmp-sync/out.txt contains a specific text +# arg1: pattern +# arg2: errormsg +check_tmpout() +{ + TEST=`cat tmp-sync/out.txt | grep "$1"` + if [ $? -ne 0 ]; + then + echo "$2" + exit 2 + fi +} + +# do dav-sync push and check return value +# arg1: dir +# arg2: errormsg +dav_sync_push() +{ + $DAV_SYNC_BIN push $1 > tmp-sync/out.txt + if [ $? -ne 0 ]; + then + echo "$2" + exit 2 + fi +} +# do dav-sync pull and check return value +# arg1: dir +# arg2: errormsg +dav_sync_pull() +{ + $DAV_SYNC_BIN pull $1 > tmp-sync/out.txt + if [ $? -ne 0 ]; + then + echo "$2" + exit 2 + fi +} + +rm -f .dav/dav-sync-tests-test2a-db.xml +rm -f .dav/dav-sync-tests-test2b-db.xml + +$DAV_BIN rm dav-test-repo/sync/test2 2> /dev/null + +$DAV_BIN mkcol dav-test-repo/sync/test2 2> /dev/null + +# tmp sync dir +rm -Rf tmp-sync +mkdir tmp-sync +mkdir tmp-sync/test2a +mkdir tmp-sync/test2b + +# ---------------------------------------------------------------------------- +# 1. test: add 4 files, push, pull +# expected result: 4 files pushed, 4 files pulled + +mkdir tmp-sync/test2a/dir1/ +mkdir tmp-sync/test2a/dir1/subdir1/ + +cp synctest/file1 tmp-sync/test2a/ +cp synctest/file2 tmp-sync/test2a/dir1/ +cp synctest/file3 tmp-sync/test2a/dir1/subdir1 +cp synctest/file4 tmp-sync/test2a/dir1/subdir1 + +dav_sync_push test2a "test 1: push failed" +check_tmpout "4 files pushed" "test 1: wrong push counter" +check_tmpout "0 conflicts" "test 1: wrong conflict counter (push)" +check_tmpout "0 errors" "test 1: wrong error counter (push)" + +dav_sync_pull test2b "test 1: pull failed" +check_tmpout "4 files pulled" "test 1: wrong pull counter" +check_tmpout "0 conflicts" "test 1: wrong conflict counter (pull)" +check_tmpout "0 errors" "test 1: wrong error counter (pull)" + + +
--- a/test/bin-test/test-dav-sync-pull-conflict.sh Tue Sep 03 21:24:17 2019 +0200 +++ b/test/bin-test/test-dav-sync-pull-conflict.sh Wed Sep 04 19:28:10 2019 +0200 @@ -83,6 +83,8 @@ rm -f .dav/dav-sync-tests-test1a-db.xml rm -f .dav/dav-sync-tests-test1b-db.xml +rm -f .dav/dav-sync-tests-test2a-db.xml +rm -f .dav/dav-sync-tests-test2b-db.xml $DAV_BIN rm dav-test-repo/sync/test1 2> /dev/null $DAV_BIN rm dav-test-repo/sync/test2 2> /dev/null
--- a/test/bin-test/test-dav-sync-push-conflict.sh Tue Sep 03 21:24:17 2019 +0200 +++ b/test/bin-test/test-dav-sync-push-conflict.sh Wed Sep 04 19:28:10 2019 +0200 @@ -337,6 +337,8 @@ # 11. test: create 3 conflicts, push, push again with -c # expected result: first push: 3 conflicts, second push: 3 files pushed +sleep 3 + # prepare test1a (like test 8) dav_sync_pull test1a "test 11: pull failed" check_tmpout "0 conflicts" "test 11: wrong conflict counter (pull test1a)" @@ -347,6 +349,8 @@ exit 2 fi +sleep 3 + # change some files in test1a and push the changes echo "test11_change_a" >> tmp-sync/test1a/file1 echo "test11_change_a" >> tmp-sync/test1a/file2 @@ -433,6 +437,9 @@ # 2 new, 2 mod files without conflict # expected result: 4 conflicts, 4 files pushed +dav_sync_pull test1a "test 13: prepare test1a failed" +check_tmpout "0 conflicts" "test 13: wrong conflict counter (prepare test1a)" + sleep 3 echo "test13_change_a" >> tmp-sync/test1a/file1
--- a/test/bin-test/test-dav-sync.sh Tue Sep 03 21:24:17 2019 +0200 +++ b/test/bin-test/test-dav-sync.sh Wed Sep 04 19:28:10 2019 +0200 @@ -61,6 +61,9 @@ 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` @@ -94,6 +97,7 @@ 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