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 devices. This can only run if you're root.
10 . "$suitedir/rsync.fns"
12 chkfile="$scratchdir/rsync.chk"
13 outfile="$scratchdir/rsync.out"
15 # Build some hardlinks
18 '') ;; # If "id" failed, try to continue...
20 *) if [ -f /usr/bin/fakeroot ]; then
21 echo "Let's try re-running the script under fakeroot..."
22 exec /usr/bin/fakeroot /bin/sh $RUNSHFLAGS "$0"
25 # If we can't test the real device code, try to test --fake-super instead
26 $RSYNC --version | grep ", xattrs" >/dev/null || test_skipped "Rsync needs root/fakeroot/--fake-super for device tests"
27 RSYNC="$RSYNC --fake-super"
28 export RSYNC_FAKE_SUPER=1
29 case "`xattr 2>&1`" in
41 xattr -s 'rsync.%stat' "$mode $maj,$min 0:0" "$fn"
55 setfattr -n 'user.rsync.%stat' -v "$mode $maj,$min 0:0" "$fn"
62 # TODO: Need to test whether hardlinks are possible on this OS/filesystem
66 mknod "$fromdir/char" c 41 67 || test_skipped "Can't create char device node"
67 mknod "$fromdir/char2" c 42 68 || test_skipped "Can't create char device node"
68 mknod "$fromdir/char3" c 42 69 || test_skipped "Can't create char device node"
69 mknod "$fromdir/block" b 42 69 || test_skipped "Can't create block device node"
70 mknod "$fromdir/block2" b 42 73 || test_skipped "Can't create block device node"
71 mknod "$fromdir/block3" b 105 73 || test_skipped "Can't create block device node"
72 ln "$fromdir/block3" "$fromdir/block2.5" || echo "Skipping hard-linked device test..."
73 mkfifo "$fromdir/fifo" || mknod "$fromdir/fifo" p || test_skipped "Can't run mkfifo"
74 touch -r "$fromdir/block" "$fromdir/block2"
76 $RSYNC -ai "$fromdir/block" "$todir/block2" \
81 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
83 $RSYNC -ai "$fromdir/block2" "$todir/block" \
88 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
92 $RSYNC -Di "$fromdir/block3" "$todir/block" \
97 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
99 $RSYNC -aiHvv "$fromdir/" "$todir/" \
102 cat <<EOT >"$chkfile"
107 hD+++++++++ block2.5 => block3
113 if test ! -r "$fromdir/block2.5"; then
114 sed -e '/block2\.5/d' <"$chkfile" >"$chkfile.new"
115 mv "$chkfile.new" "$chkfile"
117 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
119 echo "check how the directory listings compare with diff:"
121 ( cd "$fromdir" && rsync_ls_lR . ) > "$tmpdir/ls-from"
122 ( cd "$todir" && rsync_ls_lR . ) > "$tmpdir/ls-to"
123 diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to"
125 if test -b "$fromdir/block2.5"; then
127 $RSYNC -aii --link-dest="$todir" "$fromdir/" "$chkdir/" \
129 cat <<EOT >"$chkfile"
140 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
143 # The script would have aborted on error, so getting here means we've won.