add more dav-sync pull tests

Wed, 14 Aug 2019 21:13:28 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 14 Aug 2019 21:13:28 +0200
changeset 625
e1a85fbf68f9
parent 624
27985062cd2c
child 626
2f735b0e87fa

add more dav-sync pull tests

libidav/crypto.c file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync-pull1.sh file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync-push1.sh file | annotate | diff | comparison | revisions
--- a/libidav/crypto.c	Tue Aug 13 20:23:23 2019 +0200
+++ b/libidav/crypto.c	Wed Aug 14 21:13:28 2019 +0200
@@ -38,7 +38,7 @@
 /* -------------------- OpenSSL Crypto Functions -------------------- */
 #ifdef DAV_USE_OPENSSL
 
-#if OPENSSL_VERSION_NUMBER < 10000000
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
 
 static EVP_CIPHER_CTX* create_evp_cipher_ctx() {
     EVP_CIPHER_CTX *ctx = malloc(sizeof(EVP_CIPHER_CTX));
--- 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
+
+
--- a/test/bin-test/test-dav-sync-push1.sh	Tue Aug 13 20:23:23 2019 +0200
+++ b/test/bin-test/test-dav-sync-push1.sh	Wed Aug 14 21:13:28 2019 +0200
@@ -239,22 +239,41 @@
 check_tmpout "delete: /dir_b/1/2/3/4/5/6/7/8/t6f1-8" "missing: delete: /dir_b/1/2/3/4/5/6/7/8/t6f1-8"
 
 # 10. test
+# delete empty dir
+# expected result: empty dir deleted on server
+
+rm -Rf tmp-sync/test1a/dir1
+
+dav_sync_push test1a
+
+check_tmpout "0 conflicts" "push10: wrong conflict counter"
+check_tmpout "0 errors" "push10: wrong error counter"
+
+dav info dav-test-repo/sync/test1a/dir1 > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+	echo "push 10: collection not deleted"
+	exit 2
+fi
+
+# 11. test
 # delete everything
 # collection is empty
+
 rm -Rf tmp-sync/test1a/*
-dav_sync_push test1a "push 10 failed"
+
+dav_sync_push test1a "push 11 failed"
 
 check_tmpout "0 conflicts" "push10: wrong conflict counter"
 check_tmpout "0 errors" "push10: wrong error counter"
 
 OUT=`dav list dav-test-repo/sync/test1/ | wc -l`
 if [ $? -ne 0 ]; then
-	echo "push 10: dav list failed"
+	echo "push 11: dav list failed"
 	exit 2
 fi
 if [ "$OUT" != "0" ];
 then	
-	echo "push 10: dav-test-repo/sync/test1/ not empty"
+	echo "push 11: dav-test-repo/sync/test1/ not empty"
 	exit 2
 fi
 

mercurial