Use umask kluge from rsync.fns to try to get rid of a potential
[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 umask 0
28 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
29 umask 022
30 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
31
32 $RSYNC -iplr "$fromdir/" "$todir/" \
33     | tee "$outfile"
34 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 1 failed"
35 cd+++++++ bar/
36 cd+++++++ bar/baz/
37 >f+++++++ bar/baz/rsync
38 cd+++++++ foo/
39 >f+++++++ foo/config1
40 >f+++++++ foo/config2
41 >f+++++++ foo/extra
42 cL+++++++ foo/sym -> ../bar/baz/rsync
43 EOT
44
45 # Ensure there are no accidental directory-time problems.
46 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
47
48 cp -p "$srcdir/config.h" "$fromdir/foo/config2"
49 chmod 601 "$fromdir/foo/config2"
50 $RSYNC -iplrH "$fromdir/" "$todir/" \
51     | tee "$outfile"
52 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 2 failed"
53 >f..T.... bar/baz/rsync
54 >f..T.... foo/config1
55 >f.sTp... foo/config2
56 hf..T.... foo/extra => foo/config1
57 EOT
58
59 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
60 sleep 1 # For directory mod below to ensure time difference
61 rm "$todir/foo/sym"
62 ln -s ../bar/baz "$todir/foo/sym"
63 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
64 chmod 600 "$fromdir/foo/config2"
65 chmod 777 "$todir/bar/baz/rsync"
66
67 $RSYNC -iplrtc "$fromdir/" "$todir/" \
68     | tee "$outfile"
69 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 3 failed"
70 .f..tp... bar/baz/rsync
71 .d..t.... foo/
72 .f..t.... foo/config1
73 >fcstp... foo/config2
74 cL..T.... foo/sym -> ../bar/baz/rsync
75 EOT
76
77 cp -p "$srcdir/config.h" "$fromdir/foo/config2"
78 chmod 600 "$fromdir/foo/config2"
79 # Lack of -t is for unchanged hard-link stress-test!
80 $RSYNC -vvplrH "$fromdir/" "$todir/" \
81     | sed -e '1,/done$/d' -e '/--whole-file/d' -e '/total:/d' -e '/^$/,$d' \
82     | tee "$outfile"
83 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 4 failed"
84 bar/baz/rsync is uptodate
85 foo/config1 is uptodate
86 foo/config2
87 "foo/extra" is a hard link
88 foo/sym is uptodate
89 EOT
90
91 chmod 747 "$todir/bar/baz/rsync"
92 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
93 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
94     | grep "$itemregex" \
95     | tee "$outfile"
96 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 5 failed"
97 .d        ./
98 .d        bar/
99 .d        bar/baz/
100 .f...p... bar/baz/rsync
101 .d        foo/
102 .f        foo/config1
103 >f..t.... foo/config2
104 hf        foo/extra
105 .L        foo/sym -> ../bar/baz/rsync
106 EOT
107
108 chmod 757 "$todir/foo/config1"
109 touch "$todir/foo/config2"
110 $RSYNC -vplrtH "$fromdir/" "$todir/" \
111     | sed -e '/done$/d' -e '/^$/,$d' \
112     | tee "$outfile"
113 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 6 failed"
114 foo/config2
115 EOT
116
117 chmod 757 "$todir/foo/config1"
118 touch "$todir/foo/config2"
119 $RSYNC -iplrtH "$fromdir/" "$todir/" \
120     | tee "$outfile"
121 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 7 failed"
122 .f...p... foo/config1
123 >f..t.... foo/config2
124 EOT
125
126 mv "$todir" "$lddir"
127 $RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
128     | grep "$itemregex" \
129     | tee "$outfile"
130 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 8 failed"
131 .d..t.... ./
132 cd+++++++ bar/
133 cd+++++++ bar/baz/
134 cf....... bar/baz/rsync
135 cd+++++++ foo/
136 cf....... foo/config1
137 cf....... foo/config2
138 hf+++++++ foo/extra => foo/config1
139 cL+++++++ foo/sym -> ../bar/baz/rsync
140 EOT
141
142 rm -rf "$todir"
143 $RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
144     | tee "$outfile"
145 cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 9 failed"
146 .d..t.... ./
147 cd+++++++ bar/
148 cd+++++++ bar/baz/
149 cd+++++++ foo/
150 hf+++++++ foo/extra => foo/config1
151 cL+++++++ foo/sym -> ../bar/baz/rsync
152 EOT
153
154 # The script would have aborted on error, so getting here means we've won.
155 exit 0