Allow $RSYNC_TEST_TMP to indicate a good tmp dir for our tests.
[rsync/rsync.git] / testsuite / duplicates.test
CommitLineData
766526c7
MP
1#! /bin/sh
2
3# Copyright (C) 2002 by Martin Pool <mbp@samba.org>
4
c8d19f90 5# This program is distributable under the terms of the GNU GPL (see
766526c7
MP
6# COPYING).
7
8# Test rsync handling of duplicate filenames.
9
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.
16
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.
19
20# This test is not great, because it is a timing-dependent bug.
21
b0e9bafc 22. "$suitedir/rsync.fns"
766526c7 23
766526c7
MP
24# Build some hardlinks
25
766526c7
MP
26mkdir "$fromdir"
27name1="$fromdir/name1"
1623ba68 28name2="$fromdir/name2"
766526c7
MP
29echo "This is the file" > "$name1"
30ln -s "$name1" "$name2" || fail "can't create symlink"
31
1623ba68
MP
32outfile="$scratchdir/rsync.out"
33
7918f244 34checkit "$RSYNC -avv '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
1623ba68
MP
35 | tee "$outfile"
36
37# Make sure each file was only copied once...
38if [ `grep -c '^name1$' "$outfile"` != 1 ]
39then
0406a3a7 40 test_fail "name1 was not copied exactly once"
1623ba68 41fi
bc3b5b25 42if [ `grep -c '^name2 -> ' "$outfile"` != 1 ]
1623ba68 43then
0406a3a7 44 test_fail "name2 was not copied exactly once"
1623ba68 45fi
766526c7 46
05118158 47# The script would have aborted on error, so getting here means we've won.
766526c7 48exit 0