]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: unlocks on failed ts_scsi_debug_init
authorKarel Zak <kzak@redhat.com>
Thu, 7 Dec 2017 14:08:29 +0000 (15:08 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 7 Dec 2017 14:08:29 +0000 (15:08 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh

index c32770b90d50c84f9a7f3a155503815c3ebbf023..ef11a893e9edb554bf146273dbcda9d9f6be19fd 100644 (file)
@@ -719,7 +719,7 @@ function ts_lock {
        # Don't lock again
        fd=$(ts_get_lock_fd $$ $lockfile)
        if [ -n "$fd" ]; then
-               echo "${resource} already locked!"
+               echo "[$$ $TS_TESTNAME] ${resource} already locked!"
                return 0
        fi
 
@@ -728,7 +728,7 @@ function ts_lock {
        eval "exec $fd>$lockfile"
        flock --exclusive --timeout 30 $fd || ts_skip "failed to lock $resource"
 
-       echo "[$$] Locked $lockfile"
+       ###echo "[$$ $TS_TESTNAME] Locked   $resource"
 }
 
 function ts_unlock {
@@ -742,7 +742,7 @@ function ts_unlock {
 
        fd=$(ts_get_lock_fd $$ $lockfile)
        if [ -n "$fd" ]; then
-               echo "[$$] Unlocking $lockfile"
+               ###echo "[$$ $TS_TESTNAME] Unlocked $resource"
                eval "exec $fd<&-"
        fi
 }
@@ -760,8 +760,11 @@ function ts_scsi_debug_init {
 
        # skip if still in use or removal of modules not supported at all
        # We don't want a slow timeout here so we don't use ts_scsi_debug_rmmod!
-       modprobe -r scsi_debug &>/dev/null \
-               || ts_skip "cannot remove scsi_debug module (rmmod)"
+       modprobe -r scsi_debug &>/dev/null
+       if [ "$?" -eq 1 ]; then
+               ts_unlock "scsi_debug"
+               ts_skip "cannot remove scsi_debug module (rmmod)"
+       fi
 
        modprobe -b scsi_debug "$@" &>/dev/null \
                || ts_skip "cannot load scsi_debug module (modprobe)"