]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: ts_scsi_debug_init skip instead of die
authorRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 21 May 2014 23:37:17 +0000 (01:37 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Mon, 26 May 2014 22:06:43 +0000 (00:06 +0200)
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 <ruediger.meier@ga-group.nl>
tests/functions.sh

index 7232adf46eb74b1db7c701045bf84030f0eb6392..85f0e0fac896c1a9fed2ff49d7fd64e4ccb51b3a 100644 (file)
@@ -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