summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorRuediger Meier2016-03-09 12:26:38 +0100
committerRuediger Meier2016-03-09 14:41:10 +0100
commit8d323f0dd6863c8705fc1939faef6a228f05ccc7 (patch)
treeefbab049c95e02f7505f8a740b24049e4e27e203 /tests/functions.sh
parenttests: hotfix, wait for scsi_debug partion (diff)
downloadkernel-qcow2-util-linux-8d323f0dd6863c8705fc1939faef6a228f05ccc7.tar.gz
kernel-qcow2-util-linux-8d323f0dd6863c8705fc1939faef6a228f05ccc7.tar.xz
kernel-qcow2-util-linux-8d323f0dd6863c8705fc1939faef6a228f05ccc7.zip
tests: fix non-working udevadm settle for scsi_debug
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>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index 5d54efd96..74622b068 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -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 {