Fixed get_xattr_acl() -- it needed to zero *len_p.
[rsync.git] / testsuite / backup.test
blobdc53368ca990b68a3bef19ce2c5d8dc2c1fb802f
1 #! /bin/sh
3 # Copyright (C) 2004 by Wayne Davison <wayned@samba.org>
5 # This program is distributable under the terms of the GNU GPL (see
6 # COPYING).
8 # Test that the --backup option works right.
10 . "$suitedir/rsync.fns"
12 bakdir="$tmpdir/bak"
14 makepath "$fromdir/deep" "$bakdir"
15 name1="$fromdir/deep/name1"
16 name2="$fromdir/deep/name2"
18 outfile="$scratchdir/rsync.out"
20 cat "$srcdir"/[gr]*.[ch] > "$name1"
21 cat "$srcdir"/[et]*.[ch] > "$name2"
23 checkit "$RSYNC -avv '$fromdir/' '$todir/'" "$fromdir" "$todir"
25 checkit "$RSYNC -avv '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
26 cat "$srcdir"/[fgpr]*.[ch] > "$name1"
27 cat "$srcdir"/[etw]*.[ch] > "$name2"
29 $RSYNC -avv --no-whole-file --backup "$fromdir/" "$todir/" \
30 | tee "$outfile"
31 for fn in deep/name1 deep/name2; do
32 grep "backed up $fn to $fn~" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
33 diff $diffopt "$fromdir/$fn" "$todir/$fn" || test_fail "copy of $fn failed"
34 diff $diffopt "$chkdir/$fn" "$todir/$fn~" || test_fail "backup of $fn to $fn~ failed"
35 mv "$todir/$fn~" "$todir/$fn"
36 done
38 echo deleted-file >"$todir/dname"
39 cp -p "$todir/dname" "$chkdir"
41 checkit "$RSYNC -avv --no-whole-file --delete-delay \
42 --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
43 | tee "$outfile"
45 for fn in deep/name1 deep/name2; do
46 grep "backed up $fn to .*/$fn$" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
47 done
48 diff -r $diffopt "$chkdir" "$bakdir" || test_fail "backup dir contents are bogus"
49 rm "$bakdir/dname"
51 checkit "$RSYNC -avv --del '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
52 cat "$srcdir"/[efgr]*.[ch] > "$name1"
53 cat "$srcdir"/[ew]*.[ch] > "$name2"
55 checkit "$RSYNC -avv --inplace --no-whole-file --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
56 | tee "$outfile"
58 for fn in deep/name1 deep/name2; do
59 grep "backed up $fn to .*/$fn$" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
60 done
61 diff -r $diffopt "$chkdir" "$bakdir" || test_fail "backup dir contents are bogus"
63 checkit "$RSYNC -avv --inplace --no-whole-file '$fromdir/' '$bakdir/'" "$fromdir" "$bakdir"
65 # The script would have aborted on error, so getting here means we've won.
66 exit 0