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

Mon, 16 Sep 2019 19:49:04 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 16 Sep 2019 19:49:04 +0200
changeset 642
4e23087d3d90
parent 641
b138d1241e68
child 643
5b8643cf0a2f
permissions
-rwxr-xr-x

add config element for push strategy

571
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 #!/bin/sh
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 # Copyright 2019 Olaf Wintermann. All rights reserved.
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 # Redistribution and use in source and binary forms, with or without
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 # modification, are permitted provided that the following conditions are met:
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 # 1. Redistributions of source code must retain the above copyright
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 # notice, this list of conditions and the following disclaimer.
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 # 2. Redistributions in binary form must reproduce the above copyright
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 # notice, this list of conditions and the following disclaimer in the
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 # documentation and/or other materials provided with the distribution.
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 # POSSIBILITY OF SUCH DAMAGE.
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 if [ $# -lt 2 ];
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 then
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 echo "usage:" $0 "<dav-binary> <dav-sync-binary>"
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 exit 1
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 fi
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 # check if binaries exist
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 which $1 > /dev/null
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 if [ $? -ne 0 ];
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 then
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 exit 1
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 fi
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 which $2 > /dev/null
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 if [ $? -ne 0 ];
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 then
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 exit 1
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 fi
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 DAV_BIN=$1
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 DAV_SYNC_BIN=$2
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 export DAV_BIN
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 export DAV_SYNC_BIN
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 # create config
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 rm -Rf .dav
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 cp -R $HOME/.dav/ .dav/
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 cp dav-home/sync.xml .dav/sync.xml
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 export HOME=`pwd`
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 # tmp sync dir
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 rm -Rf tmp-sync
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 mkdir tmp-sync
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 mkdir tmp-sync/test1a
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 mkdir tmp-sync/test1b
637
20241338740c add first dav-sync hashing test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 635
diff changeset
64 mkdir tmp-sync/test2a
20241338740c add first dav-sync hashing test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 635
diff changeset
65 mkdir tmp-sync/test2b
20241338740c add first dav-sync hashing test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 635
diff changeset
66
571
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 # check if config works
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 TEST1_DIR=`$DAV_SYNC_BIN list-dirs | grep test1a | tail -n 1`
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 if [ -z $TEST1_DIR ];
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 then
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 echo "Config not working"
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 rm -Rf .dav
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 rm -Rf tmp-sync
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 exit 1
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 fi
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 # clean test repo and files
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 $DAV_BIN rm -N dav-test-repo/tests/ 2> /dev/null
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 $DAV_BIN rm -N dav-test-repo/sync/ 2> /dev/null
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 do_test()
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 {
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 printf "TEST: $1 ... "
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 ./$2
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 if [ $? -ne 0 ]; then
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 rm -Rf .dav
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 exit 2
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 fi
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 echo ok
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 }
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 # ok, begin the tests
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 #
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 do_test "dav-sync push (1)" test-dav-sync-push1.sh
641
b138d1241e68 finish hashing tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 640
diff changeset
97 do_test "dav-sync pull (1)" test-dav-sync-pull1.sh
b138d1241e68 finish hashing tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 640
diff changeset
98 do_test "dav-sync pull conflict (1)" test-dav-sync-pull-conflict.sh
b138d1241e68 finish hashing tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 640
diff changeset
99 do_test "dav-sync push conflict (1)" test-dav-sync-push-conflict.sh
637
20241338740c add first dav-sync hashing test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 635
diff changeset
100 do_test "dav-sync hashing" test-dav-sync-hashing.sh
571
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 # cleanup
627
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
103 $DAV_BIN rm dav-test-repo/sync/test1 > /dev/null 2>&1
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
104 if [ $? -ne 0 ]; then
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
105 echo "cleanup failed"
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
106 exit 2
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
107 fi
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
108
571
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 rm -Rf .dav
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 rm -Rf tmp-sync
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111

mercurial