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
19 $RSYNC --version |
grep "[, ] xattrs" >/dev
/null || test_skipped
"Rsync needs xattrs for fake device tests"
20 RSYNC
="$RSYNC --fake-super"
21 TLS_ARGS
="$TLS_ARGS --fake-super"
34 xattr
-s 'rsync.%stat' "$mode $maj,$min 0:0" "$fn"
48 runat
"$fn" "$SHELL_PATH" <<EOF
49 echo "$mode $maj,$min 0:0" > rsync.%stat
64 setfattr
-n 'user.rsync.%stat' -v "$mode $maj,$min 0:0" "$fn"
71 '') ;; # If "id" failed, try to continue...
73 *) if [ -e "$FAKEROOT_PATH" ]; then
74 echo "Let's try re-running the script under fakeroot..."
75 exec "$FAKEROOT_PATH" "$SHELL_PATH" $RUNSHFLAGS "$0"
77 test_skipped
"Rsync needs root/fakeroot for device tests"
83 # TODO: Need to test whether hardlinks are possible on this OS/filesystem
87 mknod
"$fromdir/char" c
41 67 || test_skipped
"Can't create char device node"
88 mknod
"$fromdir/char2" c
42 68 || test_skipped
"Can't create char device node"
89 mknod
"$fromdir/char3" c
42 69 || test_skipped
"Can't create char device node"
90 mknod
"$fromdir/block" b
42 69 || test_skipped
"Can't create block device node"
91 mknod
"$fromdir/block2" b
42 73 || test_skipped
"Can't create block device node"
92 mknod
"$fromdir/block3" b
105 73 || test_skipped
"Can't create block device node"
93 ln "$fromdir/block3" "$fromdir/block3.5" ||
echo "Skipping hard-linked device test..."
94 mkfifo "$fromdir/fifo" || mknod
"$fromdir/fifo" p || test_skipped
"Can't run mkfifo"
95 # Work around time rounding/truncating issue by touching both files.
96 touch -r "$fromdir/block" "$fromdir/block" "$fromdir/block2"
98 $RSYNC -ai "$fromdir/block" "$todir/block2" \
100 cat <<EOT >"$chkfile"
103 diff $diffopt "$chkfile" "$outfile" || test_fail
"test 1 failed"
105 $RSYNC -ai "$fromdir/block2" "$todir/block" \
107 cat <<EOT >"$chkfile"
110 diff $diffopt "$chkfile" "$outfile" || test_fail
"test 2 failed"
114 $RSYNC -Di "$fromdir/block3" "$todir/block" \
116 cat <<EOT >"$chkfile"
119 diff $diffopt "$chkfile" "$outfile" || test_fail
"test 3 failed"
121 $RSYNC -aiHvv "$fromdir/" "$todir/" \
124 cat <<EOT >"$chkfile"
129 hD$all_plus block3.5 => block3
135 if test ! -r "$fromdir/block3.5"; then
136 grep -v block3.5
<"$chkfile" >"$chkfile.new"
137 mv "$chkfile.new" "$chkfile"
139 diff $diffopt "$chkfile" "$outfile" || test_fail
"test 4 failed"
141 echo "check how the directory listings compare with diff:"
143 ( cd "$fromdir" && rsync_ls_lR .
) > "$tmpdir/ls-from"
144 ( cd "$todir" && rsync_ls_lR .
) > "$tmpdir/ls-to"
145 diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to"
147 if test -r "$fromdir/block3.5"; then
149 $RSYNC -aii --link-dest="$todir" "$fromdir/" "$chkdir/" \
151 cat <<EOT >"$chkfile"
162 diff $diffopt "$chkfile" "$outfile" || test_fail
"test 5 failed"
165 # The script would have aborted on error, so getting here means we've won.