]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
common/rc, nvme/035: add function to check TEST_DEV size requirement
authorYi Zhang <yi.zhang@redhat.com>
Wed, 2 Nov 2022 02:57:01 +0000 (10:57 +0800)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 4 Nov 2022 09:27:17 +0000 (18:27 +0900)
nvme/035 has minimum TEST_DEV size requirement, add a helper function
to check it

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
[Shin'ichiro: fixed commit title and added "return 0"]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
common/rc
tests/nvme/035

index e49004192217aac8709291833b12e6d0512b7379..ef23ebee770460c8b0408f6ce974d4c67c489a9c 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -324,6 +324,17 @@ _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
+       return 0
+}
+
 _require_test_dev_in_hotplug_slot() {
        local parent
        parent="$(_get_pci_parent_from_blkdev)"
index ee78a7586f354d303ddb800547f139d016467e59..e8581ef30f2565c7fd723b81b9e8ed38418ff208 100755 (executable)
@@ -16,6 +16,10 @@ requires() {
        _have_fio
 }
 
+device_requires() {
+       _require_test_dev_size_mb 1024
+}
+
 test_device() {
        local subsys="blktests-subsystem-1"
        local ctrldev