From f80c0d38b9e61b33e358d5d539a0f22676ecb077 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Thu, 22 May 2014 01:37:17 +0200 Subject: tests: ts_scsi_debug_init skip instead of die If any of these modprobe commands fails then it's not a broken test. ALso ts_die often does not work correctly from subtests which should be fixed someday too. BTW modprobe dry-run (even the real modprobe) is not reliable. Moreover now we respect blacklisted modules (-b). This error handling is not only useful to let the test-suite succeed on broken systems but also to not fail all "scsi_debug tests" after just one of them failed to umount something. Signed-off-by: Ruediger Meier --- tests/functions.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tests/functions.sh') diff --git a/tests/functions.sh b/tests/functions.sh index 7232adf46..85f0e0fac 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -587,15 +587,23 @@ function ts_scsi_debug_init { local devname TS_DEVICE="none" - modprobe --dry-run --quiet scsi_debug &>/dev/null - [ "$?" == 0 ] || ts_skip "missing scsi_debug module" + # dry run is not realy reliable, real modprobe may still fail + modprobe --dry-run --quiet scsi_debug &>/dev/null \ + || ts_skip "missing scsi_debug module (dry-run)" - rmmod scsi_debug &> /dev/null - modprobe scsi_debug $* - [ "$?" == 0 ] || ts_die "Cannot init device" + # skip if still in use or removal of modules not supported at all + modprobe -r scsi_debug &>/dev/null \ + || ts_skip "cannot remove scsi_debug module (rmmod)" + + modprobe -b scsi_debug $* &>/dev/null \ + || ts_skip "cannot load scsi_debug module (modprobe)" + + # it might be still not loaded, modprobe.conf or whatever + lsmod | grep -q "^scsi_debug " \ + || ts_skip "scsi_debug module not loaded (lsmod)" devname=$(grep --with-filename scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}') - [ "x${devname}" == "x" ] && ts_die "Cannot find device" + [ "x${devname}" == "x" ] && ts_die "cannot find scsi_debug device" sleep 1 udevadm settle -- cgit v1.2.3-55-g7522