Got rid of some potentially unhandled permissions differences.
[rsync/rsync.git] / testsuite / itemize.test
1 #! /bin/sh
2
3 # Copyright (C) 2005 by Wayne Davison <wayned@samba.org>
4
5 # This program is distributable under the terms of the GNU GPL see
6 # COPYING).
7
8 # Test the output of various copy commands to ensure itemized output
9 # and double-verbose output is correct.
10
11 . "$suitedir/rsync.fns"
12
13 set -x
14
15 itemregex='^[.<>ch][dfDL][c .+][s .+][tT .+][p .+][o .+][g .+][a .+] '
16
17 lddir="$tmpdir/ld"
18
19 outfile="$scratchdir/rsync.out"
20
21 makepath "$fromdir/foo"
22 makepath "$fromdir/bar/baz"
23 cp -p "$srcdir/config.h" "$fromdir/foo/config1"
24 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
25 cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
26 chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
27 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
28 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
29
30 $RSYNC -iplr "$fromdir/" "$todir/" \
31     | tee "$outfile"
32 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 1 failed"
33 cd+++++++ bar/
34 cd+++++++ bar/baz/
35 >f+++++++ bar/baz/rsync
36 cd+++++++ foo/
37 >f+++++++ foo/config1
38 >f+++++++ foo/config2
39 >f+++++++ foo/extra
40 cL+++++++ foo/sym -> ../bar/baz/rsync
41 EOT
42
43 # Ensure there are no accidental directory-time problems.
44 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
45
46 cp -p "$srcdir/config.h" "$fromdir/foo/config2"
47 chmod 601 "$fromdir/foo/config2"
48 $RSYNC -iplrH "$fromdir/" "$todir/" \
49     | tee "$outfile"
50 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 2 failed"
51 >f..T.... bar/baz/rsync
52 >f..T.... foo/config1
53 >f.sTp... foo/config2
54 hf..T.... foo/extra => foo/config1
55 EOT
56
57 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
58 sleep 1 # For directory mod below to ensure time difference
59 rm "$todir/foo/sym"
60 ln -s ../bar/baz "$todir/foo/sym"
61 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
62 chmod 600 "$fromdir/foo/config2"
63 chmod 777 "$todir/bar/baz/rsync"
64
65 $RSYNC -iplrtc "$fromdir/" "$todir/" \
66     | tee "$outfile"
67 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 3 failed"
68 .f..tp... bar/baz/rsync
69 .d..t.... foo/
70 .f..t.... foo/config1
71 >fcstp... foo/config2
72 cL..T.... foo/sym -> ../bar/baz/rsync
73 EOT
74
75 cp -p "$srcdir/config.h" "$fromdir/foo/config2"
76 chmod 600 "$fromdir/foo/config2"
77 # Lack of -t is for unchanged hard-link stress-test!
78 $RSYNC -vvplrH "$fromdir/" "$todir/" \
79     | sed -e '0,/done$/d' -e '/--whole-file/d' -e '/total:/d' -e '/^$/,$d' \
80     | tee "$outfile"
81 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 4 failed"
82 bar/baz/rsync is uptodate
83 foo/config1 is uptodate
84 foo/config2
85 "foo/extra" is a hard link
86 foo/sym is uptodate
87 EOT
88
89 chmod 747 "$todir/bar/baz/rsync"
90 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
91 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
92     | grep "$itemregex" \
93     | tee "$outfile"
94 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 5 failed"
95 .d        ./
96 .d        bar/
97 .d        bar/baz/
98 .f...p... bar/baz/rsync
99 .d        foo/
100 .f        foo/config1
101 >f..t.... foo/config2
102 hf        foo/extra
103 .L        foo/sym -> ../bar/baz/rsync
104 EOT
105
106 chmod 757 "$todir/foo/config1"
107 touch "$todir/foo/config2"
108 $RSYNC -vplrtH "$fromdir/" "$todir/" \
109     | sed -e '0,/done$/d' -e '/^$/,$d' \
110     | tee "$outfile"
111 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 6 failed"
112 foo/config2
113 EOT
114
115 chmod 757 "$todir/foo/config1"
116 touch "$todir/foo/config2"
117 $RSYNC -iplrtH "$fromdir/" "$todir/" \
118     | tee "$outfile"
119 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 7 failed"
120 .f...p... foo/config1
121 >f..t.... foo/config2
122 EOT
123
124 mv "$todir" "$lddir"
125 $RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
126     | grep "$itemregex" \
127     | tee "$outfile"
128 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 8 failed"
129 .d..t.... ./
130 cd+++++++ bar/
131 cd+++++++ bar/baz/
132 cf....... bar/baz/rsync
133 cd+++++++ foo/
134 cf....... foo/config1
135 cf....... foo/config2
136 hf+++++++ foo/extra => foo/config1
137 cL+++++++ foo/sym -> ../bar/baz/rsync
138 EOT
139
140 rm -rf "$todir"
141 $RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
142     | tee "$outfile"
143 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 9 failed"
144 .d..t.... ./
145 cd+++++++ bar/
146 cd+++++++ bar/baz/
147 cd+++++++ foo/
148 hf+++++++ foo/extra => foo/config1
149 cL+++++++ foo/sym -> ../bar/baz/rsync
150 EOT
151
152 # The script would have aborted on error, so getting here means we've won.
153 exit 0