]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: fix non-working udevadm settle for scsi_debug
authorRuediger Meier <rudi@debian-amd64>
Wed, 9 Mar 2016 11:26:38 +0000 (11:26 +0000)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 9 Mar 2016 13:41:10 +0000 (14:41 +0100)
We don't sleep anymore since 01b38917. This does not work
on Debian 7 (wheezy)/linux-3.2. Is it the kernel's or udev's
fault?

We simmply add a better sleep again plus some todos for later
improvements.

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

index 5d54efd96d5939fa5b98010a7bce8ba62d7c66b2..74622b0682ebf5a9c7d7e040b357ca6ebd478736 100644 (file)
@@ -629,6 +629,7 @@ function ts_fdisk_clean {
 
 function ts_scsi_debug_init {
        local devname
+       local t
        TS_DEVICE="none"
 
        # dry run is not really reliable, real modprobe may still fail
@@ -639,6 +640,10 @@ function ts_scsi_debug_init {
        modprobe -r scsi_debug &>/dev/null \
                || ts_skip "cannot remove scsi_debug module (rmmod)"
 
+       # TODO validate that all devices are gone, add function ts_scsi_debug_rmmod
+       # to be used by the tests too. Tests which produce non-removable scsi
+       # devices should fail!
+
        modprobe -b scsi_debug "$@" &>/dev/null \
                || ts_skip "cannot load scsi_debug module (modprobe)"
 
@@ -648,10 +653,18 @@ function ts_scsi_debug_init {
 
        udevadm settle
 
-       devname=$(grep --with-filename scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
-       [ "x${devname}" == "x" ] && ts_die "cannot find scsi_debug device"
+       # wait for device if udevadm settle does not work
+       for t in 0 0.02 0.05 0.1 1; do
+               sleep $t
+               devname=$(grep --with-filename scsi_debug /sys/block/*/device/model) && break
+       done
+       [ -n "${devname}" ] || ts_die "timeout waiting for scsi_debug device"
 
+       devname=$(echo $devname | awk -F '/' '{print $4}')
        TS_DEVICE="/dev/${devname}"
+
+       # TODO validate that device is really up, for now just a warning on stderr
+       test -b $TS_DEVICE || echo "warning: scsi_debug device is still down"
 }
 
 function ts_resolve_host {