From 8d323f0dd6863c8705fc1939faef6a228f05ccc7 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Wed, 9 Mar 2016 11:26:38 +0000 Subject: 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 --- tests/functions.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/functions.sh') 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 { -- cgit v1.2.3-55-g7522