]> www.infradead.org Git - users/hch/blktests.git/commitdiff
common,tests: replace _have_modules() with _have_module()
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 23 Aug 2022 00:11:53 +0000 (09:11 +0900)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Mon, 29 Aug 2022 23:52:54 +0000 (08:52 +0900)
The helper functions _have_modules() and _have_driver() have similar
roles, but they take different number of arguments. The former takes
multiple module names and the latter takes single module name. To make
their usage consistent, modify _have_modules() to _have_module() to take
single argument. This improves readability by checking one module per
line.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
common/rc
common/scsi_debug
tests/nbd/004
tests/nvmeof-mp/rc
tests/srp/015
tests/srp/rc
tests/zbd/010

index 8681a46500d89f689a8bad9f37377d66da0613e2..be69a4d9e2ffdc79a7fd837d3191476ea9db988b 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -57,22 +57,11 @@ _have_driver()
        return 0
 }
 
-# Check that the specified modules are available as loadable modules and not
+# Check that the specified module is available as a loadable module and not
 # built-in the kernel.
-_have_modules() {
-       local missing=()
-       local module
-
-       for module in "$@"; do
-               if ! _module_file_exists "${module}"; then
-                       missing+=("$module")
-               fi
-       done
-       if [[ ${#missing} -gt 1 ]]; then
-               SKIP_REASONS+=("the following modules are not available: ${missing[*]}")
-               return 1
-       elif [[ ${#missing} -eq 1 ]]; then
-               SKIP_REASONS+=("${missing[0]} module is not available")
+_have_module() {
+       if ! _module_file_exists "${1}"; then
+               SKIP_REASONS+=("${1} module is not available")
                return 1
        fi
        return 0
index 95da14ec471a48072f5fbb0e196074cc7beb06ae..ae13bb624b3d349df5822e5d6fdda6e363f6a2b0 100644 (file)
@@ -5,7 +5,7 @@
 # scsi_debug helper functions.
 
 _have_scsi_debug() {
-       _have_modules scsi_debug
+       _have_module scsi_debug
 }
 
 _init_scsi_debug() {
index 98afd09ae80a316b4204f64e5100cc3311f66de0..deb9673b3afa95e6a2309023b1248cff19fcb268 100755 (executable)
@@ -11,7 +11,7 @@ DESCRIPTION="module load/unload concurrently with connect/disconnect"
 QUICK=1
 
 requires() {
-       _have_modules nbd
+       _have_module nbd
 }
 
 module_load_and_unload() {
index b7ca611f3ff3eaecdf0a580caa9b2a60200509b6..ed27b5c9e0cbe0e74d9213029dc39212135792c7 100755 (executable)
@@ -12,7 +12,7 @@ nvme_port=7777
 ini_timeout=1
 
 group_requires() {
-       local m name p required_modules
+       local m name p
 
        _have_kernel_config_file || return
        # Since the nvmeof-mp tests are based on the dm-mpath driver, these
@@ -25,22 +25,20 @@ group_requires() {
        fi
 
        _have_configfs || return
-       required_modules=(
-               dm_multipath
-               dm_queue_length
-               dm_service_time
-               null_blk
-               rdma_cm
-               ib_ipoib
-               ib_umad
-               nvme-rdma
-               nvmet-rdma
-               rdma_rxe
-               scsi_dh_alua
-               scsi_dh_emc
-               scsi_dh_rdac
-       )
-       _have_modules "${required_modules[@]}" || return
+
+       _have_module dm_multipath
+       _have_module dm_queue_length
+       _have_module dm_service_time
+       _have_module null_blk
+       _have_module rdma_cm
+       _have_module ib_ipoib
+       _have_module ib_umad
+       _have_module nvme-rdma
+       _have_module nvmet-rdma
+       _have_module rdma_rxe
+       _have_module scsi_dh_alua
+       _have_module scsi_dh_emc
+       _have_module scsi_dh_rdac
 
        for p in mkfs.ext4 mkfs.xfs multipath multipathd pidof rdma fio; do
                _have_program "$p" || return
index e03b204796a502d6266cf43833a6606020cae689..d303921bf80ec2fe0afe3043656cee7b94d54ccb 100755 (executable)
@@ -10,7 +10,7 @@ TIMED=1
 requires() {
        # See also iproute commit 4336c5821a7b ("rdma: add 'link add/delete'
        # commands").
-       _have_modules siw && _have_kver 5 5 && _have_iproute2 190404
+       _have_module siw && _have_kver 5 5 && _have_iproute2 190404
 }
 
 test_disconnect_repeatedly() {
index 13dddf250ee327e2fe1032493488cd7fc8955477..23f87e482a56c94295aed3d3cb8f976f462d0458 100755 (executable)
@@ -28,7 +28,7 @@ is_lio_configured() {
 }
 
 group_requires() {
-       local m name p required_modules
+       local m name p
 
        _have_configfs || return
        if is_lio_configured; then
@@ -37,26 +37,24 @@ group_requires() {
        fi
        _have_driver sd_mod
        _have_driver sg
-       required_modules=(
-               dm_multipath
-               dm_queue_length
-               dm_service_time
-               ib_ipoib
-               ib_srp
-               ib_srpt
-               ib_umad
-               ib_uverbs
-               null_blk
-               rdma_cm
-               rdma_rxe
-               scsi_debug
-               scsi_dh_alua
-               scsi_dh_emc
-               scsi_dh_rdac
-               target_core_iblock
-               target_core_mod
-       )
-       _have_modules "${required_modules[@]}" || return
+
+       _have_module dm_multipath
+       _have_module dm_queue_length
+       _have_module dm_service_time
+       _have_module ib_ipoib
+       _have_module ib_srp
+       _have_module ib_srpt
+       _have_module ib_umad
+       _have_module ib_uverbs
+       _have_module null_blk
+       _have_module rdma_cm
+       _have_module rdma_rxe
+       _have_module scsi_debug
+       _have_module scsi_dh_alua
+       _have_module scsi_dh_emc
+       _have_module scsi_dh_rdac
+       _have_module target_core_iblock
+       _have_module target_core_mod
 
        for p in mkfs.ext4 mkfs.xfs multipath multipathd pidof rdma \
                 sg_reset fio; do
index 6d634b0b6626d697d9957035578554b43f547f17..35143b8e496fc286db02abe6cf38cd377fb13cd8 100644 (file)
@@ -12,7 +12,7 @@ QUICK=1
 requires() {
        _have_fio
        _have_driver f2fs
-       _have_modules null_blk
+       _have_module null_blk
        _have_module_param scsi_debug zone_cap_mb
        _have_program mkfs.f2fs
        _have_scsi_debug