[btrfs-progs,PATCHv2,4/4] tests: Do not fail is dmsetup is missing
diff mbox series

Message ID 20191218011925.19428-5-marcos.souza.org@gmail.com
State New
Headers show
Series
  • tests: do not fail if dm-thin is missing
Related show

Commit Message

Marcos Paulo de Souza Dec. 18, 2019, 1:19 a.m. UTC
From: Marcos Paulo de Souza <mpdesouza@suse.com>

Move the check of dmsetup to check_dm_target_support, and adapt the only
two places checking if dmsetup is present in the system. Now we skip the
test if dmsetup isn't available, instead of marking the test as failed.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 tests/common                                             | 9 +++++++--
 tests/mkfs-tests/005-long-device-name-for-ssd/test.sh    | 1 -
 .../017-small-backing-size-thin-provision-device/test.sh | 1 -
 3 files changed, 7 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/tests/common b/tests/common
index 20ad7fd9..5814ae6f 100644
--- a/tests/common
+++ b/tests/common
@@ -322,10 +322,15 @@  check_global_prereq()
 	fi
 }
 
-# check if the targets passed as arguments are available, and if not just skip
-# the test
+# check if dmsetup and targets passed as arguments are available, and skip the
+# test if they aren't.
 check_dm_target_support()
 {
+	which dmsetup &> /dev/null
+	if [ $? -ne 0 ]; then
+		_not_run "This test requires dmsetup tool.";
+	fi
+
 	for target in "$@"; do
 		modprobe dm-$target >/dev/null 2>&1
 		dmsetup targets 2>&1 | grep -q ^$target
diff --git a/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh b/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh
index 329deaf2..2df88db4 100755
--- a/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh
+++ b/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh
@@ -4,7 +4,6 @@ 
 source "$TEST_TOP/common"
 
 check_prereq mkfs.btrfs
-check_global_prereq dmsetup
 check_dm_target_support linear
 
 setup_root_helper
diff --git a/tests/mkfs-tests/017-small-backing-size-thin-provision-device/test.sh b/tests/mkfs-tests/017-small-backing-size-thin-provision-device/test.sh
index 91851945..83f34ecc 100755
--- a/tests/mkfs-tests/017-small-backing-size-thin-provision-device/test.sh
+++ b/tests/mkfs-tests/017-small-backing-size-thin-provision-device/test.sh
@@ -6,7 +6,6 @@  source "$TEST_TOP/common"
 
 check_prereq mkfs.btrfs
 check_global_prereq udevadm
-check_global_prereq dmsetup
 check_dm_target_support linear thin
 
 setup_root_helper