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

changeset 670
ef490647f5d1
child 672
4bfe452a2665
equal deleted inserted replaced
669:152101df336d 670:ef490647f5d1
1 #!/bin/sh
2 #
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 #
5 # Copyright 2019 Olaf Wintermann. All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 #
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 #
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28 #
29
30 if [ -z "$DAV_BIN" ];
31 then
32 echo "DAV_BIN variable not set"
33 exit 1
34 fi
35 if [ -z "$DAV_SYNC_BIN" ];
36 then
37 echo "DAV_BIN variable not set"
38 exit 1
39 fi
40
41 XATTR=../../build/xattrtool
42
43 # checks if tmp-sync/out.txt contains a specific text
44 # arg1: pattern
45 # arg2: errormsg
46 check_tmpout()
47 {
48 TEST=`cat tmp-sync/out.txt | grep "$1"`
49 if [ $? -ne 0 ];
50 then
51 echo "$2"
52 exit 2
53 fi
54 }
55
56 # do dav-sync push and check return value
57 # arg1: dir
58 # arg2: errormsg
59 dav_sync_push()
60 {
61 $DAV_SYNC_BIN push $1 > tmp-sync/out.txt
62 if [ $? -ne 0 ];
63 then
64 echo "$2"
65 exit 2
66 fi
67 }
68 # do dav-sync pull and check return value
69 # arg1: dir
70 # arg2: errormsg
71 dav_sync_pull()
72 {
73 $DAV_SYNC_BIN pull $1 > tmp-sync/out.txt
74 if [ $? -ne 0 ];
75 then
76 echo "$2"
77 exit 2
78 fi
79 }
80
81 rm -f .dav/dav-sync-tests-test4a-db.xml
82 rm -f .dav/dav-sync-tests-test4b-db.xml
83
84 $DAV_BIN rm dav-test-repo/sync/test4 2> /dev/null
85
86 $DAV_BIN mkcol dav-test-repo/sync/test4 2> /dev/null
87
88 # tmp sync dir
89 rm -Rf tmp-sync
90 mkdir tmp-sync
91 mkdir tmp-sync/test4a
92 mkdir tmp-sync/test4b
93
94 # ----------------------------------------------------------------------------
95 # test 1: add some files and add tags, sync only files with tag test1
96 # expected result: only files
97
98 mkdir tmp-sync/test4a/dir1
99
100 cp synctest/file1 tmp-sync/test4a/
101 cp synctest/file2 tmp-sync/test4a/
102
103 cp synctest/file3 tmp-sync/test4a/dir1/
104 cp synctest/file4 tmp-sync/test4a/dir1/
105
106 $DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/file1 mytag
107 $DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/file1 test1
108
109 $DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/file2 mytag
110 $DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/file2 test1
111
112 $DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/dir1/file3 sub
113
114 $DAV_SYNC_BIN push test4a -t test1 > tmp-sync/out.txt
115 if [ $? -ne 0 ];
116 then
117 echo "test 1: push failed"
118 exit 2
119 fi
120 check_tmpout "2 files pushed" "test 1: wrong push counter"
121 check_tmpout "0 conflicts" "test 1: wrong conflict counter (push)"
122 check_tmpout "0 errors" "test 1: wrong error counter (push)"
123
124 dav_sync_pull test4b "test 1: pull failed"
125 check_tmpout "2 files pulled" "test 1: wrong pull counter"
126 check_tmpout "0 conflicts" "test 1: wrong conflict counter (pull)"
127 check_tmpout "0 errors" "test 1: wrong error counter (pull)"
128
129 cat tmp-sync/test4b/dir1/file3 > /dev/null 2>&1
130 if [ $? -eq 0 ]; then
131 echo "test 1: file 3 must not be synced"
132 exit 2
133 fi
134
135
136 # ----------------------------------------------------------------------------
137 # test 2: push again without tag filter
138 # expected result: remaining files pushed
139
140 dav_sync_push test4a "test 2: push failed"
141 check_tmpout "2 files pushed" "test 2: wrong push counter"
142 check_tmpout "0 conflicts" "test 2: wrong conflict counter (push)"
143 check_tmpout "0 errors" "test 2: wrong error counter (push)"
144
145
146 # ----------------------------------------------------------------------------
147 # test 3: add another tag to 2 files and pull with tag filter
148 # expected result: 2 files pulled
149
150 $DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/file1 test3
151 $DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/dir1/file3 test3
152
153 dav_sync_push test4a "test 3: push failed"
154 check_tmpout "0 conflicts" "test 3: wrong conflict counter (push)"
155 check_tmpout "0 errors" "test 2: wrong error counter (push)"
156 check_tmpout "update: /file1" "test 3: file1 not updated (push)"
157 check_tmpout "update: /dir1/file3" "test 3: file3 not updated (push)"
158
159 $DAV_SYNC_BIN pull test4b -t test3 > tmp-sync/out.txt
160 if [ $? -ne 0 ];
161 then
162 echo "test 3: pull failed"
163 exit 2
164 fi
165 check_tmpout "2 files pulled" "test 3: wrong pull counter"
166 check_tmpout "0 conflicts" "test 3: wrong conflict counter (pull)"
167 check_tmpout "0 errors" "test 3: wrong error counter (pull)"
168
169 TAGS=`$DAV_SYNC_BIN list-tags -s test4b tmp-sync/test4b/file1 > tmp-sync/out.txt 2> /dev/null`
170 if [ $? -ne 0 ]; then
171 echo "test 3: file1 not pulled"
172 exit 2
173 fi
174 check_tmpout "test3" "test 3: file1: missing tag test3"
175 check_tmpout "mytag" "test 3: file1: missing tag mytag"
176 check_tmpout "test1" "test 3: file1: missing tag test1"
177
178 TAGS=`$DAV_SYNC_BIN list-tags -s test4b tmp-sync/test4b/dir1/file3 > tmp-sync/out.txt 2> /dev/null`
179 if [ $? -ne 0 ]; then
180 echo "test 3: file3 not pulled"
181 exit 2
182 fi
183 check_tmpout "test3" "test 3: file1: missing tag test3"
184 check_tmpout "sub" "test 3: file1: missing tag sub"
185
186
187

mercurial