3 # Copyright (C) 2002 by Martin Pool <mbp@samba.org>
5 # This program is distributable under the terms of the GNU GPL see
8 # Test rsync handling of duplicate filenames.
10 # It's quite possible that the user might specify the same source file
11 # more than once on the command line, perhaps through shell variables
12 # or wildcard expansions. It might cause problems for rsync if the
13 # same name occurred more than once in the file list, because we might
14 # be trying to update the first copy and generate checksums for the
15 # second copy at the same time. See clean_flist() for the implementation.
17 # We don't need to worry about hardlinks or symlinks. Because we
18 # always rename-and-replace the new copy, they can't affect us.
20 # This test is not great, because it is a timing-dependent bug.
22 . $srcdir/testsuite/rsync.fns
26 # Build some hardlinks
28 fromdir="$scratchdir/from"
29 todir="$scratchdir/to"
32 name1="$fromdir/name1"
33 name2="$fromdir/name2"
34 echo "This is the file" > "$name1"
35 ln -s "$name1" "$name2" || fail "can't create symlink"
37 outfile="$scratchdir/rsync.out"
39 checkit "$RSYNC -avv \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" \
42 # Make sure each file was only copied once...
43 if [ `grep -c '^name1$' "$outfile"` != 1 ]
45 test_fail "name1 was not copied exactly once"
47 if [ `grep -c '^name2 -> ' "$outfile"` != 1 ]
49 test_fail "name2 was not copied exactly once"
53 # last [] may have failed but if we get here then we've won