]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: cleanup ts_scsi_debug_init
authorRuediger Meier <ruediger.meier@ga-group.nl>
Sun, 11 May 2014 20:48:16 +0000 (22:48 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 13 May 2014 15:37:28 +0000 (17:37 +0200)
Sort out global and local vars. Now we set TS_DEVICE globally
to be use later.
Skip really quiet if modprobe fails.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/functions.sh

index 867cdaa2394c16609b770383371fdbe90b8475d5..db1b921f87d0e9c8379ef612630a8a1ede8e0091 100644 (file)
@@ -558,21 +558,22 @@ function ts_fdisk_clean {
 }
 
 function ts_scsi_debug_init {
+       local devname
+       TS_DEVICE="none"
 
-       modprobe --dry-run --quiet scsi_debug
+       modprobe --dry-run --quiet scsi_debug &>/dev/null
        [ "$?" == 0 ] || ts_skip "missing scsi_debug module"
 
        rmmod scsi_debug &> /dev/null
        modprobe scsi_debug $*
        [ "$?" == 0 ] || ts_die "Cannot init device"
 
-       DEVNAME=$(grep --with-filename scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
-       [ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
-
-       DEVICE="/dev/${DEVNAME}"
+       devname=$(grep --with-filename scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
+       [ "x${devname}" == "x" ] && ts_die "Cannot find device"
 
        sleep 1
        udevadm settle
 
-       echo $DEVICE
+       TS_DEVICE="/dev/${devname}"
+       echo "$TS_DEVICE"
 }