Skip to contentSkip to conversation

tests: do not fail if dm-thin is missing

PATCH Superseded Marcos Paulo de Souza 2 participants 6 messages Dec 18, 2019 Btrfs file system

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover tests: do not fail if dm-thin is missing

From: Marcos Paulo de Souza <[email protected]>

Hi there,

This is a v2 of the patches which basically changes the first patch and adds Reviewed-by to other reviewed patches. The change in the first patch was to remove the SUDO_HELPER variable from check_dm_target_support, since nowadays everyone executes these tests using root.

Original message:

these patchset is trying to fix the issue 192[1] by checking if dm-thin exists, and if it's not available, skip the test. In the last patch, the same is done for dmsetup. Feel free to ignore the last patch if you think we should stop the tests if dmsetup isn't available.

Thanks!

[1]: https://github.com/kdave/btrfs-progs/issues/192

Marcos Paulo de Souza (4):
tests: common: Add check_dm_target_support helper
tests: mkfs: 017: Use check_dm_target_support helper
tests: mkfs: 005: Use check_dm_target_support helper
tests: Do not fail is dmsetup is missing

 tests/common                                   | 18 ++++++++++++++++++
 .../005-long-device-name-for-ssd/test.sh       |  2 +-
 .../test.sh                                    |  2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH v2 1/4 tests: common: Add check_dm_target_support helper

From: Marcos Paulo de Souza <[email protected]>

This function will be used later to test if dm-thin is supported. Inspired by fstests.

---
Changes from v1:
Removed the $SUDO_HELPER variable when executing modprobe and dmsetup (Qu Wenruo)

 tests/common | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/common +13 -0
index ca098444..20ad7fd9 100644
@@ -322,6 +322,19 @@ check_global_prereq()
 	fi
 }
 
+# check if the targets passed as arguments are available, and if not just skip
+# the test
+check_dm_target_support()
+{
+	for target in "$@"; do
+		modprobe dm-$target >/dev/null 2>&1
+		dmsetup targets 2>&1 | grep -q ^$target
+		if [ $? -ne 0 ]; then
+			_not_run "This test requires dm $target support."
+		fi
+	done
+}
+
 check_image()
 {
 	local image
Signature · 1 line
2.23.0
#2 lore raw

Re: [btrfs-progs PATCHv2 1/4] tests: common: Add check_dm_target_support helper

Forget this patch, I understood it wrong. I will add setup_root_helper before the $SUDO_HELPER from v1 in a different patch.

Quoted 42 lines · Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

This function will be used later to test if dm-thin is supported. Inspired by fstests.

---
Changes from v1:
Removed the $SUDO_HELPER variable when executing modprobe and
dmsetup (Qu
Wenruo)

 tests/common | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/common +1 -0
index ca098444..20ad7fd9 100644
@@ -322,6 +322,19 @@ check_global_prereq()
 	fi
 }
 
+# check if the targets passed as arguments are available, and if not

just skip

tests/common +8 -0
+# the test
+check_dm_target_support()
+{
+	for target in "$@"; do
+		modprobe dm-$target >/dev/null 2>&1
+		dmsetup targets 2>&1 | grep -q ^$target
+		if [ $? -ne 0 ]; then
+			_not_run "This test requires dm $target

support."

tests/common +4 -0
+		fi
+	done
+}
+
 check_image()
 {
 	local image
#3 lore raw

PATCH v2 2/4 tests: mkfs: 017: Use check_dm_target_support helper

In reply to Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

If dm-thin or dm-linear are not supported, let's skip the test altogether instead of throwing an error.

Issue: #192

---
 .../017-small-backing-size-thin-provision-device/test.sh         | 1 +
 1 file changed, 1 insertion(+)
tests/mkfs-tests/017-small-backing-size-thin-provision-device/test.sh +1 -0
index 32640ce5..91851945 100755
@@ -7,6 +7,7 @@ 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
 prepare_test_dev
Signature · 1 line
2.23.0
#4 lore raw

PATCH v2 3/4 tests: mkfs: 005: Use check_dm_target_support helper

In reply to Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

This way we ensure the linear target is available and skip the test.

---
 tests/mkfs-tests/005-long-device-name-for-ssd/test.sh | 1 +
 1 file changed, 1 insertion(+)
tests/mkfs-tests/005-long-device-name-for-ssd/test.sh +1 -0
index e7a1ac45..329deaf2 100755
@@ -5,6 +5,7 @@ source "$TEST_TOP/common"
 
 check_prereq mkfs.btrfs
 check_global_prereq dmsetup
+check_dm_target_support linear
 
 setup_root_helper
 prepare_test_dev
Signature · 1 line
2.23.0
#5 lore raw

PATCH v2 4/4 tests: Do not fail is dmsetup is missing

In reply to Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

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.

---
 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(-)
tests/common +7 -2
index 20ad7fd9..5814ae6f 100644
@@ -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
tests/mkfs-tests/005-long-device-name-for-ssd/test.sh +0 -1
index 329deaf2..2df88db4 100755
@@ -4,7 +4,6 @@
 source "$TEST_TOP/common"
 
 check_prereq mkfs.btrfs
-check_global_prereq dmsetup
 check_dm_target_support linear
 
 setup_root_helper
tests/mkfs-tests/017-small-backing-size-thin-provision-device/test.sh +0 -1
index 91851945..83f34ecc 100755
@@ -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
Signature · 1 line
2.23.0