Test case for --copy-unsafe-links, contributed by Vladimír Michl,
[rsync/rsync.git] / testsuite / unsafe-links.test
1 #! /bin/sh
2
3 # Originally by Vladimír Michl <Vladimir.Michl@hlubocky.del.cz>
4
5 . $srcdir/testsuite/rsync.fns
6
7 test_symlink() {
8         is_a_link "$1" || test_fail "File $1 is not a symlink"
9 };
10
11 test_regular() {
12         if [ ! -f "$1" ]; then
13                 test_fail "File $1 is not regular file or not exists";
14         fi;
15 };
16
17 test_copy() {
18         test_symlink dest/links/file1
19         test_symlink dest/links/file2
20         test_regular dest/links/unsafefile
21 }
22
23 cd "$TMP"
24
25 mkdir from
26
27 mkdir "from/safe"
28 mkdir "from/unsafe"
29
30 mkdir "from/safe/files"
31 mkdir "from/safe/links"
32
33 touch "from/safe/files/file1"
34 touch "from/safe/files/file2"
35 touch "from/unsafe/unsafefile"
36
37 ln -s ../files/file1 "from/safe/links/"
38 ln -s ../files/file2 "from/safe/links/"
39 ln -s ../../unsafe/unsafefile "from/safe/links/"
40
41 #next rsync copy correctly
42 set -x
43 echo "rsync with relative path";
44 rsync -avv --copy-unsafe-links from/safe/ to
45 test_copy;
46
47 rm -rf to
48 #next rsync copy uncorectly - links are copied as files not as links
49 echo "rsync with relative2 path";
50 (cd from; rsync -avv --copy-unsafe-links safe/ ../to)
51 test_copy;
52
53 rm -rf to
54 #next rsync copy uncorectly - all links are copied
55 echo "rsync with absolute path";
56 rsync -avv --copy-unsafe-links `pwd`/from/safe/ to
57 test_copy;
58