test/bin-test/test-dav-sync-metadata1.sh

changeset 663
888aa263c0f1
parent 662
ab34fc9ecf1d
child 665
ec8c9201a974
--- a/test/bin-test/test-dav-sync-metadata1.sh	Sat Oct 19 11:15:04 2019 +0200
+++ b/test/bin-test/test-dav-sync-metadata1.sh	Sat Oct 19 15:46:33 2019 +0200
@@ -38,6 +38,8 @@
 	exit 1
 fi
 
+XATTR=../../build/xattrtool
+
 # checks if tmp-sync/out.txt contains a specific text
 # arg1: pattern
 # arg2: errormsg
@@ -164,6 +166,7 @@
 	exit 2
 fi
 
+
 # ----------------------------------------------------------------------------
 # test 3: modify file1 and push/pull
 # expected result: file content synced, mtime also synced
@@ -187,3 +190,226 @@
 	echo "file1: mtime not synced"
 	exit 2
 fi
+
+
+# ----------------------------------------------------------------------------
+# test 4: add xattr to files, push/pull
+# expected result: xattr synced
+
+# test if xattr are supported
+../../build/xattrtool set tmp-sync/test4a/file1 attr1 testv  2> /dev/null
+ATTR_TEST=`../../build/xattrtool get tmp-sync/test4a/file1 attr1 2> /dev/null`
+if [ $ATTR_TEST != "testv" ]; then
+	echo "xattr unsupported, skip"
+	exit 2
+fi
+
+sleep 2
+
+# add xattr to file without content modification
+$XATTR set tmp-sync/test4a/file1 attr2 value2
+$XATTR set tmp-sync/test4a/file1 attr3 hello
+$XATTR set tmp-sync/test4a/file1 attr4 hello
+touch tmp-sync/test4a/file1
+
+# modify file and add xattr
+echo "test4-mod1" >> tmp-sync/test4a/dir1/file2
+$XATTR set tmp-sync/test4a/dir1/file2 msg helloworld
+
+# create new file with extended attributes
+echo "newfile" > tmp-sync/test4a/file3
+$XATTR set tmp-sync/test4a/file3 msg helloworld
+
+dav_sync_push test4a "test 4: push failed"
+check_tmpout "0 conflicts" "test 4: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 4: wrong error counter (push)"
+check_tmpout "put: /file3" "test 4: file 3 not pushed"
+check_tmpout "put: /dir1/file2" "test 4: file 2 not pushed"
+check_tmpout "update: /file1" "test 4: file 1 not pushed"
+
+dav_sync_pull test4b "test 4: pull failed"
+check_tmpout "0 conflicts" "test 4: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 4: wrong error counter (pull)"
+check_tmpout "get: /file3" "test 4: file 3 not pulled"
+check_tmpout "get: /dir1/file2" "test 4: file 2 not pulled"
+check_tmpout "update: /file1" "test 4: file 1 not pulled"
+
+FILE1_ATTR2=`$XATTR get tmp-sync/test4b/file1 attr2 2> /dev/null`
+FILE1_ATTR3=`$XATTR get tmp-sync/test4b/file1 attr3 2> /dev/null`
+FILE1_ATTR4=`$XATTR get tmp-sync/test4b/file1 attr4 2> /dev/null`
+
+FILE2_ATTR0=`$XATTR get tmp-sync/test4b/dir1/file2 msg 2> /dev/null`
+
+FILE3_ATTR0=`$XATTR get tmp-sync/test4b/file3 msg 2> /dev/null`
+
+
+if [ "$FILE1_ATTR2" != "value2" ]; then
+	echo "file1 attr2 has wrong value: $FILE1_ATTR2"
+	exit 2
+fi
+if [ "$FILE1_ATTR3" != "hello" ]; then
+	echo "file1 attr3 has wrong value: $FILE1_ATTR3"
+	exit 2
+fi
+if [ "$FILE1_ATTR4" != "hello" ]; then
+	echo "file1 attr4 has wrong value: $FILE1_ATTR4"
+	exit 2
+fi
+
+if [ "$FILE2_ATTR0" != "helloworld" ]; then
+	echo "file2 attr has wrong value: $FILE2_ATTR0"
+	exit 2
+fi
+
+if [ "$FILE3_ATTR0" != "helloworld" ]; then
+	echo "file3 attr has wrong value: $FILE3_ATTR0"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 5: do nothing, push/pull
+# expected result: no update, no files pushed/pulled
+
+sleep 2
+
+dav_sync_push test4a "test 5: push failed"
+check_tmpout "0 files pushed" "test 5: wrong push counter"
+check_tmpout "0 conflicts" "test 5: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 5: wrong error counter (push)"
+LN=`cat tmp-sync/out.txt | wc -l`
+if [ "$LN" != "1" ]; then
+	echo "test 5: wrong output (push)"
+	exit 2
+fi
+
+dav_sync_pull test4b "test 5: pull failed"
+check_tmpout "0 files pulled" "test 5: wrong pull counter"
+check_tmpout "0 conflicts" "test 5: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 5: wrong error counter (pull)"
+LN=`cat tmp-sync/out.txt | wc -l`
+if [ "$LN" != "1" ]; then
+	echo "test 5: wrong output (pull)"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 6: add additional xattr to files, push/pull
+# expected result: xattr synced
+
+sleep 2
+
+$XATTR set tmp-sync/test4a/file1 test5 f1value5
+
+echo "test6-mod1" >> tmp-sync/test4a/file3
+$XATTR set tmp-sync/test4a/file3 test5 f3value5
+
+dav_sync_push test4a "test 6: push failed"
+check_tmpout "0 conflicts" "test 6: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 6: wrong error counter (push)"
+check_tmpout "put: /file3" "test 6: file 3 not pushed"
+check_tmpout "update: /file1" "test 6: file 1 not pushed"
+
+dav_sync_pull test4b "test 6: pull failed"
+check_tmpout "0 conflicts" "test 6: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 6: wrong error counter (pull)"
+check_tmpout "get: /file3" "test 6: file 3 not pulled"
+check_tmpout "update: /file1" "test 6: file 1 not pulled"
+
+TEST5=`$XATTR get tmp-sync/test4b/file1 test5 2> /dev/null`
+if [ "$TEST5" != "f1value5" ]; then
+	echo "test 6: file1 attr has wrong value"
+	exit 2
+fi
+TEST5=`$XATTR get tmp-sync/test4b/file3 test5 2> /dev/null`
+if [ "$TEST5" != "f3value5" ]; then
+	echo "test 6: file3 attr has wrong value"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 7: do nothing, push/pull
+# expected result: no update, no files pushed/pulled
+
+sleep 2
+
+dav_sync_push test4a "test 7: push failed"
+check_tmpout "0 files pushed" "test 7: wrong push counter"
+check_tmpout "0 conflicts" "test 7: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 7: wrong error counter (push)"
+LN=`cat tmp-sync/out.txt | wc -l`
+if [ "$LN" != "1" ]; then
+	echo "test 7: wrong output (push)"
+	exit 2
+fi
+
+dav_sync_pull test4b "test 7: pull failed"
+check_tmpout "0 files pulled" "test 7: wrong pull counter"
+check_tmpout "0 conflicts" "test 7: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 7: wrong error counter (pull)"
+LN=`cat tmp-sync/out.txt | wc -l`
+if [ "$LN" != "1" ]; then
+	echo "test 7: wrong output (pull)"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 8: remove xattr
+# expected result: xattr removed in test4b
+
+$XATTR remove tmp-sync/test4a/dir1/file2 msg
+if [ $? -ne 0 ]; then
+	echo "test 8: xattrtool remove failed"
+	exit 2
+fi
+
+touch tmp-sync/test4a/dir1/file2
+
+dav_sync_push test4a "test 8: push failed"
+check_tmpout "0 conflicts" "test 8: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 8: wrong error counter (push)"
+check_tmpout "update: /dir1/file2" "test 8: file 1 not pushed"
+
+dav_sync_pull test4b "test 8: pull failed"
+check_tmpout "0 conflicts" "test 8: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 8: wrong error counter (pull)"
+check_tmpout "update: /dir1/file2" "test 8: file 1 not pulled"
+
+TEST6=`$XATTR get tmp-sync/test4b/dir1/file2 msg 2> /dev/null`
+if [ "$TEST6" != "" ]; then
+	echo "test 8: xattr msg not removed"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 9: do nothing, push/pull
+# expected result: no update, no files pushed/pulled
+
+sleep 2
+
+dav_sync_push test4a "test 9: push failed"
+check_tmpout "0 files pushed" "test 9: wrong push counter"
+check_tmpout "0 conflicts" "test 9: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 9: wrong error counter (push)"
+LN=`cat tmp-sync/out.txt | wc -l`
+if [ "$LN" != "1" ]; then
+	echo "test 7: wrong output (push)"
+	exit 2
+fi
+
+dav_sync_pull test4b "test 9: pull failed"
+check_tmpout "0 files pulled" "test 9: wrong pull counter"
+check_tmpout "0 conflicts" "test 9: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 9: wrong error counter (pull)"
+LN=`cat tmp-sync/out.txt | wc -l`
+if [ "$LN" != "1" ]; then
+	echo "test 9: wrong output (pull)"
+	exit 2
+fi
+
+
+

mercurial