ea17d5b6fbddfb6330c66e3e92ad1b3bda9c8d74
[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 cd "$TMP"
18
19 mkdir from
20
21 mkdir "from/safe"
22 mkdir "from/unsafe"
23
24 mkdir "from/safe/files"
25 mkdir "from/safe/links"
26
27 touch "from/safe/files/file1"
28 touch "from/safe/files/file2"
29 touch "from/unsafe/unsafefile"
30
31 ln -s ../files/file1 "from/safe/links/"
32 ln -s ../files/file2 "from/safe/links/"
33 ln -s ../../unsafe/unsafefile "from/safe/links/"
34
35 set -x
36
37 echo "rsync with relative path and just -a";
38 rsync -avv from/safe/ to
39 test_symlink to/links/file1
40 test_symlink to/links/file2
41 test_symlink to/links/unsafefile
42
43 echo "rsync with relative path and -a --copy-links"
44 rsync -avv --copy-links from/safe/ to
45 test_regular to/links/file1
46 test_regular to/links/file2
47 test_regular to/links/unsafefile
48
49 #next rsync copy correctly
50 echo "rsync with relative path and --copy-unsafe-links";
51 rsync -avv --copy-unsafe-links from/safe/ to
52 test_symlink to/links/file1
53 test_symlink to/links/file2
54 test_regular to/links/unsafefile
55
56 # I think these are correct, but I don't really understand the code.
57 # Waiting for an answer from dwd
58 test_skipped "correct behaviour is unclear"
59
60
61 rm -rf to
62 #next rsync copy incorrectly - links are copied as files not as links
63 echo "rsync with relative2 path";
64 (cd from; rsync -avv --copy-unsafe-links safe/ ../to)
65 test_symlink to/links/file1
66 test_symlink to/links/file2
67 test_regular to/links/unsafefile
68
69 rm -rf to
70 #next rsync copy uncorectly - all links are copied
71 echo "rsync with absolute path";
72 rsync -avv --copy-unsafe-links `pwd`/from/safe/ to
73 test_symlink to/links/file1
74 test_symlink to/links/file2
75 test_regular to/links/unsafefile
76