summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorKarel Zak2016-03-09 15:08:50 +0100
committerKarel Zak2016-03-09 15:08:50 +0100
commitedcf032b30994256f79d531e92b4a51a4f720e78 (patch)
tree19f61e6ceb0a9ba8b7acab1eef7093a84ca81082 /tests/functions.sh
parentMerge branch 'port-osx' of https://github.com/rudimeier/util-linux (diff)
parenttests: fix non-working udevadm settle for scsi_debug (diff)
downloadkernel-qcow2-util-linux-edcf032b30994256f79d531e92b4a51a4f720e78.tar.gz
kernel-qcow2-util-linux-edcf032b30994256f79d531e92b4a51a4f720e78.tar.xz
kernel-qcow2-util-linux-edcf032b30994256f79d531e92b4a51a4f720e78.zip
Merge branch 'test-fixes' of https://github.com/rudimeier/util-linux
* 'test-fixes' of https://github.com/rudimeier/util-linux: tests: fix non-working udevadm settle for scsi_debug tests: hotfix, wait for scsi_debug partion tests: don't use mkfs.btrfs option -f tests: ignore swapon warnings tests: udevadm settle before losetup -d
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 {