finish hashing tests

Sun, 15 Sep 2019 16:11:58 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 15 Sep 2019 16:11:58 +0200
changeset 641
b138d1241e68
parent 640
65e40934b26c
child 642
4e23087d3d90

finish hashing tests

libidav/utils.c file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync-hashing.sh file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync.sh file | annotate | diff | comparison | revisions
--- a/libidav/utils.c	Sun Sep 08 15:43:13 2019 +0200
+++ b/libidav/utils.c	Sun Sep 15 16:11:58 2019 +0200
@@ -1027,7 +1027,7 @@
     size_t buflen = 2*len + 4;
     UcxBuffer *buf = ucx_buffer_new(malloc(buflen), buflen + 1, 0);
     for(int i=0;i<len;i++) {
-        ucx_bprintf(buf, "%x", data[i]);
+        ucx_bprintf(buf, "%02x", data[i]);
     }
     ucx_buffer_putc(buf, 0);
     char *str = buf->space;
--- a/test/bin-test/test-dav-sync-hashing.sh	Sun Sep 08 15:43:13 2019 +0200
+++ b/test/bin-test/test-dav-sync-hashing.sh	Sun Sep 15 16:11:58 2019 +0200
@@ -388,3 +388,52 @@
 check_tmpout "0 conflicts" "test 12: wrong conflict counter (pull)"
 check_tmpout "0 errors" "test 12: wrong error counter (pull)"
 
+
+# ----------------------------------------------------------------------------
+# 13. test: delete file, change name of other file to deleted file's name
+# expected result: first file has content of second file, second file deleted
+
+# prepare
+echo "test13-file1" > tmp-sync/test2a/t13file1
+sleep 3 # make sure t13file2 doesn't has the same mtime as t13file1
+echo "test13-file2" > tmp-sync/test2a/t13file2
+
+dav_sync_push test2a "test 13: push failed (prepare)"
+check_tmpout "2 files pushed" "test 13: wrong push counter (prepare, push)"
+check_tmpout "0 conflicts" "test 13: wrong conflict counter (prepare, push)"
+check_tmpout "0 errors" "test 13: wrong error counter (prepare, push)"
+
+dav_sync_pull test2b "test 13: pull failed (prepare)"
+check_tmpout "2 files pulled" "test 13: wrong pull counter (prepare, pull)"
+check_tmpout "0 conflicts" "test 13: wrong conflict counter (prepare, pull)"
+check_tmpout "0 errors" "test 13: wrong error counter (prepare, pull)"
+
+# do test
+rm -f tmp-sync/test2a/t13file1
+mv tmp-sync/test2a/t13file2 tmp-sync/test2a/t13file1
+
+
+dav_sync_push test2a "test 13: push failed"
+# we can't check the exact output, because there are multiple valid ways
+# to sync the changes
+check_tmpout "0 conflicts" "test 13: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 13: wrong error counter (push)"
+
+dav_sync_pull test2b "test 13: pull failed"
+check_tmpout "0 conflicts" "test 13: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 13: wrong error counter (pull)"
+
+TEST=`cat tmp-sync/test2b/t13file1`
+if  [ $TEST != "test13-file2" ]; then
+	echo "test 13: t13file1 has wrong content"
+	exit 2
+fi
+
+cat tmp-sync/test2b/t13file2 > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+	echo "test 13: t13file2 not deleted"
+	exit 2
+fi
+
+
+
--- a/test/bin-test/test-dav-sync.sh	Sun Sep 08 15:43:13 2019 +0200
+++ b/test/bin-test/test-dav-sync.sh	Sun Sep 15 16:11:58 2019 +0200
@@ -94,9 +94,9 @@
 # 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 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

mercurial