diff mbox series

[V2,blktests,2/3] common/rc: add one function to check required dev size for TEST_DEV

Message ID 20221102025702.1664101-3-yi.zhang@redhat.com (mailing list archive)
State New, archived
Headers show
Series fix and improvement for xfs log size change from new xfsprogs version | expand

Commit Message

Yi Zhang Nov. 2, 2022, 2:57 a.m. UTC
nvme/035 has minimum TEST_DEV size requirement, add a helper function
to check it

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
---
 common/rc      | 10 ++++++++++
 tests/nvme/035 |  4 ++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index e490041..7987ac3 100644
--- a/common/rc
+++ b/common/rc
@@ -324,6 +324,16 @@  _get_pci_parent_from_blkdev() {
 		tail -2 | head -1
 }
 
+_require_test_dev_size_mb() {
+	local require_sz_mb=$1
+	local test_dev_sz_mb=$(($(blockdev --getsize64 "$TEST_DEV")/1024/1024))
+
+	if (( "$test_dev_sz_mb" < "$require_sz_mb" )); then
+		SKIP_REASONS+=("${TEST_DEV} required at least ${require_sz_mb}m")
+		return 1
+	fi
+}
+
 _require_test_dev_in_hotplug_slot() {
 	local parent
 	parent="$(_get_pci_parent_from_blkdev)"
diff --git a/tests/nvme/035 b/tests/nvme/035
index ee78a75..e8581ef 100755
--- a/tests/nvme/035
+++ b/tests/nvme/035
@@ -16,6 +16,10 @@  requires() {
 	_have_fio
 }
 
+device_requires() {
+	_require_test_dev_size_mb 1024
+}
+
 test_device() {
 	local subsys="blktests-subsystem-1"
 	local ctrldev