Skip to content

Commit

Permalink
srp: skip test if scsi_transport_srp module is loaded and in use
Browse files Browse the repository at this point in the history
The srp/* tests requires exclusive access to scsi_transport_srp
module. Running srp/* tests would definitely fail if the test can't
get exclusive access of scsi_transport_srp module as shown below:

$ lsmod | grep scsi_transport_srp
scsi_transport_srp    327680  1 ibmvscsi

$ ./check srp/001
srp/001 (Create and remove LUNs)                             [failed]
    runtime    ...  0.249s
tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied
tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied
modprobe: FATAL: Module scsi_transport_srp is in use.
error: Invalid argument
error: Invalid argument

So if the scsi_transport_srp module is loaded and in use then skip
running srp/* tests.

Signed-off-by: Nilay Shroff <[email protected]>
Tested-by: Disha Goel <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
[Shin'ichiro: removed extra spaces and fixed a shellcheck warning]
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
shroffni authored and kawasaki committed Feb 9, 2025
1 parent 67aff55 commit 18914ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/rc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ _have_module() {
return 0
}

_module_not_in_use() {
local refcnt

_have_module "$1" || return

if [ -d "/sys/module/$1" ]; then
refcnt="$(cat /sys/module/"$1"/refcnt)"
if [ "$refcnt" -ne "0" ]; then
SKIP_REASONS+=("module $1 is in use")
fi
fi
}

_have_module_param() {
_have_driver "$1" || return

Expand Down
1 change: 1 addition & 0 deletions tests/srp/rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ group_requires() {
_have_module scsi_debug
_have_module target_core_iblock
_have_module target_core_mod
_module_not_in_use scsi_transport_srp

for p in mkfs.ext4 mkfs.xfs multipath multipathd pidof rdma \
sg_reset fio; do
Expand Down

0 comments on commit 18914ab

Please sign in to comment.