@@ -7,7 +7,7 @@
. common/shellcheck
_have_null_blk() {
- _have_driver null_blk
+ _have_drivers null_blk
}
_remove_null_blk_devices() {
@@ -42,15 +42,25 @@ _module_file_exists()
return 1
}
-# Check that the specified module or driver is available, regardless of whether
-# it is built-in or built separately as a module.
-_have_driver()
-{
- local modname="${1//-/_}"
+# Check that the specified modules or drivers are available, regardless of
+# whether they are built-in or built separately as module files.
+_have_drivers() {
+ local missing=()
+ local driver modname
+
+ for driver in "$@"; do
+ modname=${driver//-/_}
+ if [[ ! -d "/sys/module/${modname}" ]] &&
+ ! modprobe -qn "${modname}"; then
+ missing+=("$driver")
+ fi
+ done
- if [ ! -d "/sys/module/${modname}" ] &&
- ! modprobe -qn "${modname}"; then
- SKIP_REASONS+=("driver ${modname} is not available")
+ if [[ ${#missing} -gt 1 ]]; then
+ SKIP_REASONS+=("the following drivers are not available: ${missing[*]}")
+ return 1
+ elif [[ ${#missing} -eq 1 ]]; then
+ SKIP_REASONS+=("${missing[0]} driver is not available")
return 1
fi
@@ -98,7 +108,7 @@ _have_module_param_value() {
local expected_value="$3"
local value
- if ! _have_driver "$modname"; then
+ if ! _have_drivers "$modname"; then
return 1;
fi
@@ -147,7 +157,7 @@ _have_src_program() {
}
_have_loop() {
- _have_driver loop && _have_program losetup
+ _have_drivers loop && _have_program losetup
}
_have_blktrace() {
@@ -11,7 +11,7 @@ group_requires() {
}
_have_nbd() {
- if ! _have_driver nbd; then
+ if ! _have_drivers nbd; then
return 1
fi
if ! _have_program nbd-server; then
@@ -18,23 +18,21 @@ _nvme_requires() {
_have_program nvme
case ${nvme_trtype} in
loop)
- _have_driver nvme-loop
+ _have_drivers nvme-loop
_have_configfs
;;
pci)
- _have_driver nvme
+ _have_drivers nvme
;;
tcp)
- _have_driver nvme-tcp
- _have_driver nvmet-tcp
+ _have_drivers nvme-tcp nvmet-tcp
_have_configfs
;;
rdma)
- _have_driver nvme-rdma
- _have_driver nvmet-rdma
+ _have_drivers nvme-rdma nvmet-rdma
_have_configfs
_have_program rdma
- _have_driver rdma_rxe || _have_driver siw
+ _have_drivers rdma_rxe || _have_drivers siw
;;
*)
SKIP_REASONS+=("unsupported nvme_trtype=${nvme_trtype}")
@@ -15,7 +15,7 @@ group_device_requires() {
}
_have_scsi_generic() {
- _have_driver sg
+ _have_drivers sg
}
_require_test_dev_is_scsi() {
@@ -33,7 +33,7 @@ have_good_mkfs_btrfs() {
requires() {
_have_fio
- _have_driver btrfs
+ _have_drivers btrfs
_have_module_param scsi_debug zone_cap_mb
_have_program mkfs.btrfs
_have_scsi_debug
@@ -11,7 +11,7 @@ QUICK=1
requires() {
_have_fio
- _have_driver f2fs
+ _have_drivers f2fs
_have_modules null_blk
_have_module_param scsi_debug zone_cap_mb
_have_program mkfs.f2fs
The helper function _have_driver() checks single driver but it is often required to check multiple drivers. Rename _have_driver() to _have_drivers() and improve it to check multiple drivers. This makes its usage consistent with _have_modules(). While at it, replace single brackets in _have_drivers() with double brackets to have consistent bracket style as _have_modules(). Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- common/null_blk | 2 +- common/rc | 30 ++++++++++++++++++++---------- tests/nbd/rc | 2 +- tests/nvme/rc | 12 +++++------- tests/scsi/rc | 2 +- tests/zbd/009 | 2 +- tests/zbd/010 | 2 +- 7 files changed, 30 insertions(+), 22 deletions(-)