duplicates.test 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #! /bin/sh
  2. # Copyright (C) 2002 by Martin Pool <mbp@samba.org>
  3. # This program is distributable under the terms of the GNU GPL (see
  4. # COPYING).
  5. # Test rsync handling of duplicate filenames.
  6. # It's quite possible that the user might specify the same source file
  7. # more than once on the command line, perhaps through shell variables
  8. # or wildcard expansions. It might cause problems for rsync if the
  9. # same name occurred more than once in the file list, because we might
  10. # be trying to update the first copy and generate checksums for the
  11. # second copy at the same time. See clean_flist() for the implementation.
  12. # We don't need to worry about hardlinks or symlinks. Because we
  13. # always rename-and-replace the new copy, they can't affect us.
  14. # This test is not great, because it is a timing-dependent bug.
  15. . "$suitedir/rsync.fns"
  16. # Build some hardlinks
  17. mkdir "$fromdir"
  18. name1="$fromdir/name1"
  19. name2="$fromdir/name2"
  20. echo "This is the file" > "$name1"
  21. ln -s "$name1" "$name2" || fail "can't create symlink"
  22. outfile="$scratchdir/rsync.out"
  23. checkit "$RSYNC -avv '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
  24. | tee "$outfile"
  25. # Make sure each file was only copied once...
  26. if [ `grep -c '^name1$' "$outfile"` != 1 ]
  27. then
  28. test_fail "name1 was not copied exactly once"
  29. fi
  30. if [ `grep -c '^name2 -> ' "$outfile"` != 1 ]
  31. then
  32. test_fail "name2 was not copied exactly once"
  33. fi
  34. # The script would have aborted on error, so getting here means we've won.
  35. exit 0