Update links to https.
[rsync.git] / testsuite / devices.test
blob0af0428bd0484aa8290628e9f043938227be3d64
1 #! /bin/sh
3 # Copyright (C) 2002 by Martin Pool <mbp@samba.org>
5 # This program is distributable under the terms of the GNU GPL (see
6 # COPYING).
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
17 case $0 in
18 *fake*)
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"
22 case "$HOST_OS" in
23 darwin*)
24 mknod() {
25 fn="$1"
26 case "$2" in
27 p) mode=10644 ;;
28 c) mode=20644 ;;
29 b) mode=60644 ;;
30 esac
31 maj="${3:-0}"
32 min="${4:-0}"
33 touch "$fn"
34 xattr -s 'rsync.%stat' "$mode $maj,$min 0:0" "$fn"
37 solaris*)
38 mknod() {
39 fn="$1"
40 case "$2" in
41 p) mode=10644 ;;
42 c) mode=20644 ;;
43 b) mode=60644 ;;
44 esac
45 maj="${3:-0}"
46 min="${4:-0}"
47 touch "$fn"
48 runat "$fn" "$SHELL_PATH" <<EOF
49 echo "$mode $maj,$min 0:0" > rsync.%stat
50 EOF
54 mknod() {
55 fn="$1"
56 case "$2" in
57 p) mode=10644 ;;
58 c) mode=20644 ;;
59 b) mode=60644 ;;
60 esac
61 maj="${3:-0}"
62 min="${4:-0}"
63 touch "$fn"
64 setfattr -n 'user.rsync.%stat' -v "$mode $maj,$min 0:0" "$fn"
67 esac
70 case `get_testuid` in
71 '') ;; # If "id" failed, try to continue...
72 0) ;;
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"
79 esac
81 esac
83 # TODO: Need to test whether hardlinks are possible on this OS/filesystem
85 mkdir "$fromdir"
86 mkdir "$todir"
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" \
99 | tee "$outfile"
100 cat <<EOT >"$chkfile"
101 cD$all_plus block
103 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
105 $RSYNC -ai "$fromdir/block2" "$todir/block" \
106 | tee "$outfile"
107 cat <<EOT >"$chkfile"
108 cD$all_plus block2
110 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
112 sleep 1
114 $RSYNC -Di "$fromdir/block3" "$todir/block" \
115 | tee "$outfile"
116 cat <<EOT >"$chkfile"
117 cDc.T.$dots block3
119 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
121 $RSYNC -aiHvv "$fromdir/" "$todir/" \
122 | tee "$outfile"
123 filter_outfile
124 cat <<EOT >"$chkfile"
125 .d..t.$dots ./
126 cDc.t.$dots block
127 cDc...$dots block2
128 cD$all_plus block3
129 hD$all_plus block3.5 => block3
130 cD$all_plus char
131 cD$all_plus char2
132 cD$all_plus char3
133 cS$all_plus fifo
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:"
142 echo ""
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
148 set -x
149 $RSYNC -aii --link-dest="$todir" "$fromdir/" "$chkdir/" \
150 | tee "$outfile"
151 cat <<EOT >"$chkfile"
152 cd$allspace ./
153 hD$allspace block
154 hD$allspace block2
155 hD$allspace block3
156 hD$allspace block3.5
157 hD$allspace char
158 hD$allspace char2
159 hD$allspace char3
160 hS$allspace fifo
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.
166 exit 0