From 2ecc299070da4a6c4db0c7c5a84da990a07cd095 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 4 Nov 2011 21:28:51 +0100 Subject: [PATCH] tests: add a helper function * tests/t-lib-helpers.sh (wait_for_dev_to_disappear_): New function. --- tests/t-lib-helpers.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh index bb41139..3c41e7b 100644 --- a/tests/t-lib-helpers.sh +++ b/tests/t-lib-helpers.sh @@ -378,6 +378,21 @@ wait_for_dev_to_appear_() return 1 } +# Like the above, but don't hard-code the max timeout. +wait_for_dev_to_disappear_() +{ + local file=$1 + local n_sec=$2 + local i=0 + local incr=1 + while :; do + ls "$file" > /dev/null 2>&1 || return 0 + sleep .1 2>/dev/null || { sleep 1; incr=10; } + i=$(expr $i + $incr); test $i -ge $($n_sec \* 10) && break + done + return 1 +} + device_mapper_required_() { . "$abs_top_srcdir/tests/lvm-utils.sh" \ -- 2.11.0