If we're not root and the "fakeroot" command is available, use it
[rsync/rsync.git] / testsuite / devices.test
CommitLineData
355b8bcd
MP
1#! /bin/sh
2
3# Copyright (C) 2002 by Martin Pool <mbp@samba.org>
4
5# This program is distributable under the terms of the GNU GPL (see
6# COPYING).
7
8# Test rsync handling of devices. This can only run if you're root.
9
b0e9bafc 10. "$suitedir/rsync.fns"
355b8bcd 11
355b8bcd
MP
12# Build some hardlinks
13
f5450e79
WD
14case `id -u` in
15'') ;; # If "id" failed, try to continue...
648859bd
WD
160) ;;
17*) if [ -f /usr/bin/fakeroot ]; then
18 exec /usr/bin/fakeroot /bin/sh "$0"
19 fi
20 test_skipped "Rsync won't copy devices unless we're root"
21 ;;
f5450e79
WD
22esac
23
355b8bcd
MP
24# TODO: Need to test whether hardlinks are possible on this OS/filesystem
25
26mkdir "$fromdir"
f09dc86a
WD
27mknod "$fromdir/char" c 41 67 || test_skipped "Can't create char device node unless root"
28mknod "$fromdir/char2" c 42 68 || test_skipped "Can't create char device node unless root"
29mknod "$fromdir/char3" c 42 69 || test_skipped "Can't create char device node unless root"
7a176e87 30mknod "$fromdir/block" b 42 69 || test_skipped "Can't create block device node unless root"
ab264c9e
S
31mknod "$fromdir/block2" b 42 73 || test_skipped "Can't create block device node unless root"
32mknod "$fromdir/block3" b 105 73 || test_skipped "Can't create block device node unless root"
fdb6716c 33mkfifo "$fromdir/fifo" || test_skipped "Can't run mkfifo"
355b8bcd 34
40b13938 35checkit "$RSYNC -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" skip_file_diff
355b8bcd 36
05118158 37# The script would have aborted on error, so getting here means we've won.
355b8bcd 38exit 0