btrfs-progs: tests: do dm target detection by one

Switch the helper to take only one parameter, the target name. This can
be used to extend the helper with additional parameters for the target.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-09-07 16:48:42 +02:00
parent 76ab1fa364
commit 6694fe5de9
2 changed files with 11 additions and 9 deletions

View File

@ -399,10 +399,13 @@ check_global_prereq()
fi
}
# Check if dmsetup and targets passed as arguments are available, and skip the
# Check if dmsetup and the target passed as argument is available, and skip the
# test if they aren't
# $1: the target name, expectind module dm-$1
check_dm_target_support()
{
local target="$1"
setup_root_helper
type -p dmsetup &> /dev/null
@ -410,13 +413,11 @@ check_dm_target_support()
_not_run "This test requires dmsetup tool";
fi
for target in "$@"; do
$SUDO_HELPER modprobe "dm-$target" >/dev/null 2>&1
$SUDO_HELPER dmsetup targets 2>&1 | grep -q "^$target"
if [ $? -ne 0 ]; then
_not_run "This test requires dm-$target support"
fi
done
$SUDO_HELPER modprobe "dm-$target" >/dev/null 2>&1
$SUDO_HELPER dmsetup targets 2>&1 | grep -q "^$target"
if [ $? -ne 0 ]; then
_not_run "This test requires dm-$target support"
fi
}
check_image()

View File

@ -6,7 +6,8 @@ source "$TEST_TOP/common"
check_prereq mkfs.btrfs
check_global_prereq udevadm
check_dm_target_support linear thin
check_dm_target_support linear
check_dm_target_support thin
setup_root_helper
prepare_test_dev