diff -r 27985062cd2c -r e1a85fbf68f9 test/bin-test/test-dav-sync-pull1.sh --- a/test/bin-test/test-dav-sync-pull1.sh Tue Aug 13 20:23:23 2019 +0200 +++ b/test/bin-test/test-dav-sync-pull1.sh Wed Aug 14 21:13:28 2019 +0200 @@ -105,6 +105,15 @@ check_tmpout "0 errors" "test2: wrong error counter" check_tmpout "0 conflicts" "test2: wrong conflicts counter" +cat tmp-sync/test1b/file1 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test2: missing file1" +fi +cat tmp-sync/test1b/file2 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test2: missing file2" +fi + # ---------------------------------------------------------------------------- # 3. test: pull empty directory # expected result: empty directory created @@ -154,7 +163,7 @@ # 5. test: pull changed files # expected result: 1 file pulled -echo testx2 > tmp-sync/test1a/file1 +echo testx5 > tmp-sync/test1a/file1 dav_sync_push test1a "test5: push failed" check_tmpout "1 file pushed" "test5: wrong push counter" @@ -162,6 +171,12 @@ check_tmpout "0 errors" "test5: wrong error counter" check_tmpout "0 conflicts" "test5: wrong conflicts counter" +TEST=`cat tmp-sync/test1b/file1` +if [ $TEST != "testx5" ]; then + echo "test5: wrong content" + exit 2 +fi + # ---------------------------------------------------------------------------- # 6. test: pull new dir and files # expected result: mkdir and some files pulled @@ -174,3 +189,204 @@ dav_sync_pull test1b "test6: pull failed" check_tmpout "get: /subdir/sub1" "test6: sub1 not pulled" check_tmpout "get: /subdir/sub2" "test6: sub2 not pulled" + + +# ---------------------------------------------------------------------------- +# 7. test: pull deep dir hierarchy with some files +# expected result: mkdir in correct order (see push1 test 6) + +mkdir -p tmp-sync/test1a/dir_a/1/2/3/4/5/6/7/8 +mkdir -p tmp-sync/test1a/dir_a/1/2/3/a/b/c/d +mkdir -p tmp-sync/test1a/dir_a/i/j/k +mkdir -p tmp-sync/test1a/dir_b/1/2/3/4/5/6/7/8 +mkdir -p tmp-sync/test1a/dir_b/1/2/3/a/b/c/d +mkdir -p tmp-sync/test1a/dir_b/i/j/k +mkdir -p tmp-sync/test1a/dir_c/sub1/sub2/sub3/sub4 +mkdir -p tmp-sync/test1a/dir_c/sub1/sub2/1 +mkdir -p tmp-sync/test1a/dir_c/sub1/sub2/2 +mkdir -p tmp-sync/test1a/dir_c/sub1/sub2/3 +mkdir -p tmp-sync/test1a/dir_c/sub1/sub2/4 +mkdir -p tmp-sync/test1a/dir_c/sub1/sub2/5 +mkdir -p tmp-sync/test1a/dir_c/sub_a/x +mkdir -p tmp-sync/test1a/dir_c/sub_a/y/d1/d2/d3 +touch tmp-sync/test1a/dir_a/1/2/3/4/5/6/7/8/file1 +touch tmp-sync/test1a/dir_a/1/2/3/4/5/6/7/file1 +touch tmp-sync/test1a/dir_a/1/2/3/4/5/6/file1 +touch tmp-sync/test1a/dir_a/1/2/3/a/b/c/d/d_file1 +touch tmp-sync/test1a/dir_a/1/2/3/a/b/b_file1 +touch tmp-sync/test1a/dir_a/a_file + +echo "test6-file-1" > tmp-sync/test1a/dir_b/1/2/3/4/5/6/7/8/t6f1-8 +echo "test6-file-2" > tmp-sync/test1a/dir_b/i/t6f2-i +echo "test6-file-3" > tmp-sync/test1a/dir_c/sub1/sub2/sub3/sub4/t6f3-s4 +echo "test6-file-4" > tmp-sync/test1a/dir_c/sub1/sub2/3/t6f4-3 + +dav_sync_push test1a "test7: push failed" +check_tmpout "10 files pushed" "test7: wrong push counter" + +dav_sync_pull test1b "test7: pull failed" +check_tmpout "0 errors" "test7: wrong error counter" +check_tmpout "0 conflicts" "test7: wrong conflicts counter" + +# check if all files are pulled +cat tmp-sync/test1b/dir_a/1/2/3/4/5/6/7/8/file1 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 1" + exit 2 +fi +cat tmp-sync/test1b/dir_a/1/2/3/4/5/6/7/file1 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 2" + exit 2 +fi +cat tmp-sync/test1b/dir_a/1/2/3/4/5/6/file1 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 3" + exit 2 +fi +cat tmp-sync/test1b/dir_a/1/2/3/a/b/c/d/d_file1 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 4" + exit 1 +fi +cat tmp-sync/test1b/dir_a/1/2/3/a/b/b_file1 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 5" + exit 2 +fi +cat tmp-sync/test1b/dir_a/a_file > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 6" + exit 2 +fi + +cat tmp-sync/test1b/dir_b/1/2/3/4/5/6/7/8/t6f1-8 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 7" + exit 2 +fi +cat tmp-sync/test1b/dir_b/i/t6f2-i > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 8" + exit 2 +fi +cat tmp-sync/test1b/dir_c/sub1/sub2/sub3/sub4/t6f3-s4 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 9" + exit 2 +fi +cat tmp-sync/test1b/dir_c/sub1/sub2/3/t6f4-3 > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "test 7: missing file: 10" + exit 2 +fi + +# ---------------------------------------------------------------------------- +# 8. test: delete file +# expected result: 1 file deleted + +rm tmp-sync/test1a/file1 + +dav_sync_push test1a +check_tmpout "1 file deleted" "test8: wrong delete counter" + +dav_sync_pull test1b +check_tmpout "1 file deleted" "test8: wrong delete counter" + +TEST=`cat tmp-sync/out.txt | grep "delete: /file1"` +if [ $? -ne 0 ]; then + echo "test8: file1 not deleted (log)" + exit 2 +fi + +cat tmp-sync/test1b/file1 > /dev/null 2>&1 # should fail +if [ $? -eq 0 ]; then + echo "test8: file1 not deleted" + exit 2 +fi + +# ---------------------------------------------------------------------------- +# 9. test: delete multiple files +# expected result: multiple files deleted + +rm tmp-sync/test1a/file2 +rm tmp-sync/test1a/subdir/sub1 +rm tmp-sync/test1a/subdir/sub2 + +dav_sync_push test1a +check_tmpout "3 files deleted" "test9: wrong delete counter" + +dav_sync_pull test1b +check_tmpout "3 files deleted" "test9: wrong delete counter" +check_tmpout "0 errors" "test9: wrong error counter" +check_tmpout "0 conflicts" "test9: wrong conflicts counter" + +TEST=`cat tmp-sync/out.txt | grep "delete: /subdir/sub1"` +if [ $? -ne 0 ]; then + echo "test9: sub1 not deleted (log)" + exit 2 +fi +TEST=`cat tmp-sync/out.txt | grep "delete: /subdir/sub2"` +if [ $? -ne 0 ]; then + echo "test9: sub2 not deleted (log)" + exit 2 +fi + +cat tmp-sync/test1b/file2 > /dev/null 2>&1 # should fail +if [ $? -eq 0 ]; then + echo "test9: file2 not deleted" + exit 2 +fi +cat tmp-sync/test1b/subdir/sub1 > /dev/null 2>&1 # should fail +if [ $? -eq 0 ]; then + echo "test9: sub1 not deleted" + exit 2 +fi +cat tmp-sync/test1b/subdir/sub2 > /dev/null 2>&1 # should fail +if [ $? -eq 0 ]; then + echo "test9: sub2 not deleted" + exit 2 +fi + +OUT=`ls tmp-sync/test1b/subdir/ | wc -l` +if [ "$OUT" != "0" ]; +then + echo "test9: test1b/subdir not empty" + exit 2 +fi + +# ---------------------------------------------------------------------------- +# 10. test: delete empty dir +# expected result: pull deletes local empty dir + +rm -Rf tmp-sync/test1a/subdir/ + +dav_sync_push test1a + +dav_sync_pull test1b +check_tmpout "0 errors" "test10: wrong error counter" +check_tmpout "0 conflicts" "test10: wrong conflicts counter" + +TEST=`ls tmp-sync/test1b/ | grep subdir` +if [ $? -eq 0 ]; then + echo "test10: subdir not deleted" +fi + +# ---------------------------------------------------------------------------- +# 11. test: delete deep dir hierarchy +# expected result: 0 errors, everything deleted + +rm -Rf tmp-sync/test1a/dir_a + +dav_sync_push test1a +bash +dav_sync_pull test1b +check_tmpout "0 errors" "test10: wrong error counter" +check_tmpout "0 conflicts" "test10: wrong conflicts counter" + +TEST=`ls tmp-sync/test1b/ | grep dir_a` +if [ $? -eq 0 ]; then + echo "test10: dir_a not deleted" +fi + +