diff options
| author | Brian Behlendorf <behlendorf1@llnl.gov> | 2010-09-11 04:44:17 +0000 |
|---|---|---|
| committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2010-09-12 03:54:41 +0000 |
| commit | 2c4834f87af4beec4b16157622c85d2850cce25f (patch) | |
| tree | fd389b2c63285dd28249b23fe63d054ec884938e /scripts/common.sh.in | |
| parent | ac063c48ae12061bbe0f66b3a9d641239782ae62 (diff) | |
Wait up to timeout seconds for udev devicezfs-0.5.1
Occasional failures were observed in zconfig.sh because udev
could be delayed for a few seconds. To handle this the wait_udev
function has been added to wait for timeout seconds for an
expected device before returning an error. By default callers
currently use a 30 seconds timeout which should be much longer
than udev ever needs but not so long to worry the test suite
is hung.
Diffstat (limited to 'scripts/common.sh.in')
| -rw-r--r-- | scripts/common.sh.in | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/common.sh.in b/scripts/common.sh.in index 65e897d8549c..57508be9fe73 100644 --- a/scripts/common.sh.in +++ b/scripts/common.sh.in @@ -441,3 +441,20 @@ run_test() { skip_one_test ${TEST_NUM} "${TEST_NAME}" fi } + +wait_udev() { + local DEVICE=$1 + local DELAY=$2 + local COUNT=0 + + while [ ! -e ${DEVICE} ]; do + if [ ${COUNT} -gt ${DELAY} ]; then + return 1 + fi + + let COUNT=${COUNT}+1 + sleep 1 + done + + return 0 +} |
