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 # This is only called if rsync was run with -v or -vv (not -i alone).
16 # Higher levels of -v would require more filtering.
18 sed -e '/^building file list /d' \
19 -e '/^created directory /d' \
21 -e '/ --whole-file$/d' \
24 <"$outfile" >"$outfile.new"
25 mv "$outfile.new" "$outfile"
28 # Build some hardlinks
31 '') ;; # If "id" failed, try to continue...
33 *) if [ -f /usr/bin/fakeroot ]; then
34 echo "Let's try re-running the script under fakeroot..."
35 exec /usr/bin/fakeroot /bin/sh $RUNSHFLAGS "$0"
37 test_skipped "Rsync won't copy devices unless we're root"
41 # TODO: Need to test whether hardlinks are possible on this OS/filesystem
45 mknod "$fromdir/char" c 41 67 || test_skipped "Can't create char device node unless root"
46 mknod "$fromdir/char2" c 42 68 || test_skipped "Can't create char device node unless root"
47 mknod "$fromdir/char3" c 42 69 || test_skipped "Can't create char device node unless root"
48 mknod "$fromdir/block" b 42 69 || test_skipped "Can't create block device node unless root"
49 mknod "$fromdir/block2" b 42 73 || test_skipped "Can't create block device node unless root"
50 mknod "$fromdir/block3" b 105 73 || test_skipped "Can't create block device node unless root"
51 ln "$fromdir/block3" "$fromdir/block2.5" || echo "Skipping hard-linked device test..."
52 mkfifo "$fromdir/fifo" || test_skipped "Can't run mkfifo"
53 touch -r "$fromdir/block" "$fromdir/block2"
55 $RSYNC -ai "$fromdir/block" "$todir/block2" \
60 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
62 $RSYNC -ai "$fromdir/block2" "$todir/block" \
67 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
71 $RSYNC -Di "$fromdir/block3" "$todir/block" \
76 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
78 $RSYNC -aiHvv "$fromdir/" "$todir/" \
86 hD++++++ block2.5 => block3
92 if test ! -b "$fromdir/block2.5"; then
93 sed -e '/block2\.5/d' \
94 <"$chkfile" >"$chkfile.new"
95 mv "$chkfile.new" "$chkfile"
97 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
99 echo "check how the directory listings compare with diff:"
101 ( cd "$fromdir" && rsync_ls_lR . ) > "$tmpdir/ls-from"
102 ( cd "$todir" && rsync_ls_lR . ) > "$tmpdir/ls-to"
103 diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to"
105 # The script would have aborted on error, so getting here means we've won.