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