summaryrefslogtreecommitdiff
path: root/testsuite/alt-dest.test
blob: d2fb5a1bbe11ea4fbfb5a604555c146e1a5b94c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

# Copyright (C) 2004-2022 Wayne Davison

# This program is distributable under the terms of the GNU GPL (see
# COPYING).

# Test rsync handling of --compare-dest and similar options.

. "$suitedir/rsync.fns"

alt1dir="$tmpdir/alt1"
alt2dir="$tmpdir/alt2"
alt3dir="$tmpdir/alt3"

SSH="$scratchdir/src/support/lsh.sh"

# Build some files/dirs/links to copy

hands_setup

# Setup the alt and chk dirs
$RSYNC -av --include=text --include='*/' --exclude='*' "$fromdir/" "$alt1dir/"
$RSYNC -av --include=etc-ltr-list --include='*/' --exclude='*' "$fromdir/" "$alt2dir/"

# Create a side dir where there is a candidate destfile of the same name as a sourcefile
echo "This is a test file" >"$fromdir/likely"

mkdir "$alt3dir"
echo "This is a test file" >"$alt3dir/likely"

sleep 1
touch "$fromdir/dir/text" "$fromdir/likely"

$RSYNC -av --exclude=/text --exclude=etc-ltr-list "$fromdir/" "$chkdir/"

# Let's do it!
checkit "$RSYNC -avv --no-whole-file \
    --compare-dest='$alt1dir' --compare-dest='$alt2dir' \
    '$fromdir/' '$todir/'" "$chkdir" "$todir"

rm -rf "$todir"
checkit "$RSYNC -avv --no-whole-file \
    --copy-dest='$alt1dir' --copy-dest='$alt2dir' \
    '$fromdir/' '$todir/'" "$fromdir" "$todir"

# Test that copy_file() works correctly with tmpfiles
for maybe_inplace in '' --inplace; do
    rm -rf "$todir"
    checkit "$RSYNC -av $maybe_inplace --copy-dest='$alt3dir' \
	'$fromdir/' '$todir/'" "$fromdir" "$todir"

    for srchost in '' 'localhost:'; do
	if [ -z "$srchost" ]; then
	    desthost='localhost:'
	else
	    desthost=''
	fi

	rm -rf "$todir"
	checkit "$RSYNC -ave '$SSH' --rsync-path='$RSYNC' $maybe_inplace \
	    --copy-dest='$alt3dir' '$srchost$fromdir/' '$desthost$todir/'" \
	    "$fromdir" "$todir"
    done
done

# The script would have aborted on error, so getting here means we've won.
exit 0