summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
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 {