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