2 # run the zerolen unit tests in a directory supporting O_DIRECT
4 # Copyright (C) 2007-2011 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${abs_top_srcdir=../..}/tests/init.sh"; path_prepend_ .
20 . $abs_top_srcdir/tests/t-lib-helpers.sh
21 # Need root privileges to create a device-mapper device.
23 device_mapper_required_
27 # This test only makes sense on Linux.
28 test "$(uname -s)" = Linux \
29 || skip_ "not on Linux"
31 test "x$DYNAMIC_LOADING" = xyes \
32 || skip_ "no dynamic loading support"
34 test "x$ENABLE_DEVICE_MAPPER" = xyes \
35 || skip_ "no device-mapper support"
37 # Device map name - should be random to not conflict with existing ones on
43 # 'dmsetup remove' may fail because udev is still processing the device.
44 # Try it repeatedly for 2s.
48 dmsetup remove $linear_ > /dev/null 2>&1 && break
49 sleep .1 2>/dev/null || { sleep 1; incr=10; }
50 i=$(expr $i + $incr); test $i = 20 && break
53 dmsetup remove $linear_
56 test -n "$d1" && losetup -d "$d1"
61 d1=$(loop_setup_ "$f1") \
62 || skip_ "is this partition mounted with 'nodev'?"
64 echo "0 1024 linear $d1 0" | dmsetup create "$linear_" \
65 || skip_ "unable to create dm device"
67 wait_for_dev_to_appear_ "/dev/mapper/$linear_" \
68 || skip_ "dm device did not appear"
70 zerolen /dev/mapper/$linear_ || fail=1