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@xxxxxxx> --- common/rc | 19 ++++--------------- common/scsi_debug | 2 +- tests/nbd/004 | 2 +- tests/nvmeof-mp/rc | 32 +++++++++++++++----------------- tests/srp/015 | 2 +- tests/srp/rc | 40 +++++++++++++++++++--------------------- tests/zbd/010 | 2 +- 7 files changed, 42 insertions(+), 57 deletions(-) diff --git a/common/rc b/common/rc index 8681a46..be69a4d 100644 --- 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 diff --git a/common/scsi_debug b/common/scsi_debug index 95da14e..ae13bb6 100644 --- a/common/scsi_debug +++ b/common/scsi_debug @@ -5,7 +5,7 @@ # scsi_debug helper functions. _have_scsi_debug() { - _have_modules scsi_debug + _have_module scsi_debug } _init_scsi_debug() { diff --git a/tests/nbd/004 b/tests/nbd/004 index 98afd09..deb9673 100755 --- a/tests/nbd/004 +++ b/tests/nbd/004 @@ -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() { diff --git a/tests/nvmeof-mp/rc b/tests/nvmeof-mp/rc index b7ca611..ed27b5c 100755 --- a/tests/nvmeof-mp/rc +++ b/tests/nvmeof-mp/rc @@ -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 diff --git a/tests/srp/015 b/tests/srp/015 index e03b204..d303921 100755 --- a/tests/srp/015 +++ b/tests/srp/015 @@ -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() { diff --git a/tests/srp/rc b/tests/srp/rc index 13dddf2..23f87e4 100755 --- a/tests/srp/rc +++ b/tests/srp/rc @@ -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 diff --git a/tests/zbd/010 b/tests/zbd/010 index 6d634b0..35143b8 100644 --- a/tests/zbd/010 +++ b/tests/zbd/010 @@ -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 -- 2.37.1