fstests: check if the scratch device is an lv device for certain tests
authorJosef Bacik <josef@toxicpanda.com>
Fri, 12 Nov 2021 21:10:27 +0000 (16:10 -0500)
committerEryu Guan <guaneryu@gmail.com>
Sun, 14 Nov 2021 12:50:15 +0000 (20:50 +0800)
I use lvm to carve up a large disk so I can run the btrfs raid related xfstests.
However this messes with tests that try to greate lvm devices ontop of
SCRATCH_DEV.  Handle this by adding a _require_scratch_nolvm helper to skip
tests that are going to try and create lvm devices.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc
tests/generic/081
tests/generic/108
tests/generic/459

index de5be4aa4bd278fe0b7d5d27b8b5b4a2d7896f36..0a30a8421328043da671e00384e46c86ccece5c1 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -1676,6 +1676,17 @@ _require_scratch_nocheck()
     rm -f ${RESULT_DIR}/require_scratch
 }
 
+# we need the scratch device and it needs to not be an lvm device
+_require_scratch_nolvm()
+{
+       _require_scratch_nocheck
+
+       # This works if we don't have LVM, all we want is to skip if the scratch
+       # device is an lvm device.
+       $LVM_PROG lvdisplay $SCRATCH_DEV > /dev/null 2>&1
+       [ $? -eq 0 ] && _notrun "test requires a non-lvm scratch device"
+}
+
 # we need the scratch device and it should be checked post test.
 _require_scratch()
 {
index 9f294c118cfa997864598d853f52a8328f125510..22ac94de538304b44aebd235115e48289754181f 100755 (executable)
@@ -50,7 +50,7 @@ _cleanup()
 # real QA test starts here
 _supported_fs generic
 _require_test
-_require_scratch_nocheck
+_require_scratch_nolvm
 _require_dm_target snapshot
 _require_command $LVM_PROG lvm
 
index 6e1ea5b9d20ab9cb64847b2019be5b8ec16ede7b..ad43269f50e82c9886521a109c8fcc590a581747 100755 (executable)
@@ -32,7 +32,7 @@ _cleanup()
 
 # real QA test starts here
 _supported_fs generic
-_require_scratch_nocheck
+_require_scratch_nolvm
 _require_block_device $SCRATCH_DEV
 _require_scsi_debug
 _require_command "$LVM_PROG" lvm
index 5b44e2451de4a1dd7e8917625a13533da8d71287..cda19e6eb235dd8dde29193d8163060810e50acc 100755 (executable)
@@ -39,7 +39,7 @@ _cleanup()
 # This tests for filesystem lockup not consistency, so don't check for fs
 # consistency after test
 _supported_fs generic
-_require_scratch_nocheck
+_require_scratch_nolvm
 _require_dm_target thin-pool
 _require_dm_target snapshot
 _require_command $LVM_PROG lvm