Sun, 15 Dec 2019 18:43:01 +0100
Added tag v1.3.0 for changeset 33c9b0f17cb2
#!/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-test3a-db.xml rm -f .dav/dav-sync-tests-test3b-db.xml $DAV_BIN rm dav-test-repo/sync/test3 2> /dev/null $DAV_BIN mkcol dav-test-repo/sync/test3 2> /dev/null # tmp sync dir rm -Rf tmp-sync mkdir tmp-sync mkdir tmp-sync/test3a mkdir tmp-sync/test3b # ---------------------------------------------------------------------------- # 1. test: add 4 files, push, pull # expected result: 4 files pushed, 4 files pulled mkdir tmp-sync/test3a/dir1/ mkdir tmp-sync/test3a/dir1/subdir1/ cp synctest/file1 tmp-sync/test3a/ cp synctest/file2 tmp-sync/test3a/dir1/ cp synctest/file3 tmp-sync/test3a/dir1/subdir1 cp synctest/file4 tmp-sync/test3a/dir1/subdir1 dav_sync_push test3a "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 test3b "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)" # ---------------------------------------------------------------------------- # 2. test: add 4 more files to test3b, push, pull # expected result: 4 files pushed, 4 files pulled echo "newfile1" > tmp-sync/test3b/new1 echo "newfile2" > tmp-sync/test3b/new2 echo "newfile3" > tmp-sync/test3b/dir1/new3 echo "newfile4" > tmp-sync/test3b/dir1/new4 dav_sync_push test3b "test 2: push failed" check_tmpout "4 files pushed" "test 2: wrong push counter" check_tmpout "0 conflicts" "test 2: wrong conflict counter (push)" check_tmpout "0 errors" "test 2: wrong error counter (push)" dav_sync_pull test3a "test 2: pull failed" check_tmpout "4 files pulled" "test 2: wrong pull counter" check_tmpout "0 conflicts" "test 2: wrong conflict counter (pull)" check_tmpout "0 errors" "test 2: wrong error counter (pull)" # ---------------------------------------------------------------------------- # 3. test: enable hashing (by using syncdirs with h suffix), touch file1 # and modify file2, push, pull # expected result: 2 files pushed, 1 files pulled sleep 2 touch tmp-sync/test3a/file1 echo "test3-mod1" >> tmp-sync/test3a/dir1/file2 # should push 2 files, because the db doesn't contain any hashes yet dav_sync_push test3ah "test 3: push failed" check_tmpout "2 files pushed" "test 3: wrong push counter" check_tmpout "0 conflicts" "test 3: wrong conflict counter (push)" check_tmpout "0 errors" "test 3: wrong error counter (push)" dav_sync_pull test3bh "test 3: pull failed" check_tmpout "1 file pulled" "test 3: wrong pull counter" check_tmpout "0 conflicts" "test 3: wrong conflict counter (pull)" check_tmpout "0 errors" "test 3: wrong error counter (pull)" # ---------------------------------------------------------------------------- # 4. test: same as test 3, but the db should contain hashes # expected result: 1 file pushed, because the db should contain hashes now sleep 2 touch tmp-sync/test3a/file1 echo "test4-mod1" >> tmp-sync/test3a/dir1/file2 # should push 2 files, because the db doesn't contain any hashes yet dav_sync_push test3ah "test 4: push failed" check_tmpout "1 file pushed" "test 4: wrong push counter" check_tmpout "0 conflicts" "test 4: wrong conflict counter (push)" check_tmpout "0 errors" "test 4: wrong error counter (push)" dav_sync_pull test3bh "test 4: pull failed" check_tmpout "1 file pulled" "test 4: wrong pull counter" check_tmpout "0 conflicts" "test 4: wrong conflict counter (pull)" check_tmpout "0 errors" "test 4: wrong error counter (pull)" # ---------------------------------------------------------------------------- # 5. test: mod file3 on both sides, mod new1 differently on both sides, push # expected result: 1 conflict, 0 files pushed echo "test5-mod1" >> tmp-sync/test3a/dir1/subdir1/file3 echo "test5-mod1" >> tmp-sync/test3b/dir1/subdir1/file3 echo "test5-mod-a" >> tmp-sync/test3a/new1 echo "test5-mod-b" >> tmp-sync/test3b/new1 dav_sync_push test3ah "test 5: push test3ah failed" check_tmpout "2 files pushed" "test 5: wrong push counter (test3ah)" check_tmpout "0 conflicts" "test 5: wrong conflict counter (test3ah)" check_tmpout "0 errors" "test 5: wrong error counter (test3ah)" dav_sync_push test3bh "test 5: push test3bh failed" check_tmpout "0 files pushed" "test 5: wrong push counter (test3bh)" check_tmpout "1 conflict" "test 5: wrong conflict counter (testbh)" check_tmpout "0 errors" "test 5: wrong error counter (test3bh)" # ---------------------------------------------------------------------------- # 6. test: cp new1 from test3a to test3b and push test3bh # expected result: 0 files pushed, 0 conflicts cp tmp-sync/test3a/new1 tmp-sync/test3b/new1 dav_sync_push test3bh "test 6: push failed" check_tmpout "0 files pushed" "test 6: wrong push counter" check_tmpout "0 conflicts" "test 6: wrong conflict counter" check_tmpout "0 errors" "test 6: wrong error counter" # ---------------------------------------------------------------------------- # 7. test: pull test3bh # expected result: 0 files pulled, 0 conflicts dav_sync_pull test3bh "test 6: pull failed" check_tmpout "0 files pulled" "test 6: wrong pull counter" check_tmpout "0 conflicts" "test 6: wrong conflict counter" check_tmpout "0 errors" "test 6: wrong error counter"