generic: _require_dm_target() helper

generic/085 was failing on a machine w/o devicemapper kernel
support because it requires the linear target, but didn't
explicitly test for it.

I could have cut & pasted _require_dm_linear(), but chose
to go the route of a generic helper, _require_dm_target $FOO,
because some day someone will need the zero target, the error
target, or who knows.

Add the helper, use it in test generic/085, and convert
_require_dm_flakey, _require_dm_snapshot, and
_dmerror_required with this new helper.

Reported-by: Angelo Dureghello <angelo.dureghello@nomovok.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Eric Sandeen
2015-10-14 14:08:42 +11:00
committed by Dave Chinner
parent 7f0a867ce6
commit 50266c22dc
32 changed files with 47 additions and 71 deletions
-14
View File
@@ -18,20 +18,6 @@
#
# common functions for setting up and tearing down a dmerror device
# this test requires the device mapper error target
#
_dmerror_required()
{
_require_command "$DMSETUP_PROG" dmsetup
_require_block_device $SCRATCH_DEV
_require_sane_bdev_flush $SCRATCH_DEV
modprobe dm-mod >/dev/null 2>&1
$DMSETUP_PROG targets | grep error >/dev/null 2>&1
[ $? -ne 0 ] && _notrun "This test requires dm error support"
}
_dmerror_init()
{
local dm_backing_dev=$SCRATCH_DEV
+7 -17
View File
@@ -1346,32 +1346,22 @@ _require_sane_bdev_flush()
fi
}
# this test requires the device mapper flakey target
#
_require_dm_flakey()
# this test requires a specific device mapper target
_require_dm_target()
{
_target=$1
# require SCRATCH_DEV to be a valid block device with sane BLKFLSBUF
# behaviour
_require_block_device $SCRATCH_DEV
_require_sane_bdev_flush $SCRATCH_DEV
_require_command "$DMSETUP_PROG" dmsetup
modprobe dm-flakey >/dev/null 2>&1
$DMSETUP_PROG targets | grep flakey >/dev/null 2>&1
if [ $? -ne 0 ]; then
_notrun "This test requires dm flakey support"
fi
}
modprobe dm-$_target >/dev/null 2>&1
_require_dm_snapshot()
{
_require_block_device $SCRATCH_DEV
_require_sane_bdev_flush $SCRATCH_DEV
_require_command "$DMSETUP_PROG" dmsetup
modprobe dm-snapshot >/dev/null 2>&1
$DMSETUP_PROG targets | grep -q snapshot
$DMSETUP_PROG targets 2>&1 | grep -q ^$_target
if [ $? -ne 0 ]; then
_notrun "This test requires dm snapshot support"
_notrun "This test requires dm $_target support"
fi
}