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

Sun, 17 Dec 2023 15:33:50 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 17 Dec 2023 15:33:50 +0100
changeset 800
30d484806c2b
parent 774
8c8aed7e1756
permissions
-rwxr-xr-x

fix faulty string to int conversion utilities

Probably it was expected that errno is set to EINVAL when illegal characters are encountered. But this is not standard and does not happen on every system, allowing illegal strings to be parsed as valid integers.

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 # check if config works
671
5256d7eb69e7 fix test system on solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 670
diff changeset
68 TEST1_DIR=`$DAV_SYNC_BIN list-dirs | grep test1a | tail -1`
679
0d352b79363a fix some versioning related bugs and add tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 678
diff changeset
69 if [ -z "$TEST1_DIR" ];
571
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 then
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 echo "Config not working"
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 rm -Rf .dav
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 rm -Rf tmp-sync
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 exit 1
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 fi
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 # clean test repo and files
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 $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
79 $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
80
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 do_test()
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 {
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 printf "TEST: $1 ... "
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 ./$2
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 if [ $? -ne 0 ]; then
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 rm -Rf .dav
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 exit 2
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 fi
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 echo ok
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 }
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 # ok, begin the tests
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 #
774
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
95 do_test "dav-sync push (1)" test-dav-sync-push1.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
96 do_test "dav-sync pull (1)" test-dav-sync-pull1.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
97 do_test "dav-sync pull conflict (1)" test-dav-sync-pull-conflict.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
98 do_test "dav-sync push conflict (1)" test-dav-sync-push-conflict.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
99 do_test "dav-sync hashing (1)" test-dav-sync-hashing1.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
100 do_test "dav-sync hashing (2)" test-dav-sync-hashing1.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
101 do_test "dav-sync hash strategy" test-dav-sync-hash-strategy.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
102 do_test "dav-sync hash conflict resolution" test-dav-sync-hash-conflictres.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
103 do_test "dav-sync hashing change cfg" test-dav-sync-hashing-cfgchange.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
104 do_test "dav-sync metadata (1)" test-dav-sync-metadata1.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
105 do_test "dav-sync metadata (2)" test-dav-sync-metadata2.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
106 do_test "dav-sync metadata (3)" test-dav-sync-metadata3.sh
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
107 do_test "dav-sync metadata (4)" test-dav-sync-metadata4.sh
684
a4b4257c1a5f improve shell completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 682
diff changeset
108 do_test "dav-sync versioning (1)" test-dav-sync-versioning1.sh
681
3320429502cf fix some split bugs and add tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 679
diff changeset
109 do_test "dav-sync split (1)" test-dav-sync-split1.sh
685
487645580b5e add symlink tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 684
diff changeset
110 do_test "dav-sync symlink (1)" test-dav-sync-symlink1.sh
571
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 # cleanup
774
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
113
8c8aed7e1756 fix split test script
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 773
diff changeset
114 $DAV_BIN rm dav-test-repo/sync/ > /dev/null 2>&1
627
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
115 if [ $? -ne 0 ]; then
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
116 echo "cleanup failed"
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
117 exit 2
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
118 fi
81e066c9ff87 finish basic pull tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 622
diff changeset
119
571
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 rm -Rf .dav
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 rm -Rf tmp-sync
f6de48471c9c add first dav-sync binary tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122

mercurial