3 # Copyright (C) 2007-2010 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 test_description='run the zerolen unit tests in a directory supporting O_DIRECT'
20 # Need root privileges to create a device-mapper device.
21 privileges_required_=1
22 device_mapper_required_=1
25 . "$top_srcdir/tests/test-lib.sh"
29 # This test only makes sense on Linux.
30 test "$(uname -s)" = Linux \
31 || skip_test_ "not on Linux"
33 test "x$DYNAMIC_LOADING" = xyes \
34 || skip_test_ "no dynamic loading support"
36 test "x$ENABLE_DEVICE_MAPPER" = xyes \
37 || skip_test_ "no device-mapper support"
39 # Device map name - should be random to not conflict with existing ones on
45 # 'dmsetup remove' may fail because udev is still processing the device.
46 # Try it repeatedly for 2s.
50 dmsetup remove $linear_ > /dev/null 2>&1 && break
51 sleep .1 2>/dev/null || { sleep 1; incr=10; }
52 i=$(expr $i + $incr); test $i = 20 && break
55 dmsetup remove $linear_
58 test -n "$d1" && losetup -d "$d1"
63 d1=$(loop_setup_ "$f1") \
64 || skip_test_ "is this partition mounted with 'nodev'?"
66 echo "0 1024 linear $d1 0" | dmsetup create "$linear_" \
67 || skip_test_ "unable to create dm device"
69 wait_for_dev_to_appear_ "/dev/mapper/$linear_" \
70 || skip_test_ "dm device did not appear"
73 'run the actual tests' "zerolen /dev/mapper/$linear_"